Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
d2e90e15
Verified
Commit
d2e90e15
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add utility function to generate a copyright year string
parent
1fb529e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!146
Resolve "Add licence information page"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/util/core_helpers.py
+14
-0
14 additions, 0 deletions
aleksis/core/util/core_helpers.py
with
14 additions
and
0 deletions
aleksis/core/util/core_helpers.py
+
14
−
0
View file @
d2e90e15
from
datetime
import
datetime
,
timedelta
from
itertools
import
groupby
from
operator
import
itemgetter
import
os
import
pkgutil
from
importlib
import
import_module
...
...
@@ -12,6 +14,18 @@ from django.utils import timezone
from
django.utils.functional
import
lazy
def
copyright_years
(
years
:
Sequence
[
int
],
seperator
:
str
=
"
,
"
,
joiner
:
str
=
"
–
"
)
->
str
:
"""
Takes a sequence of integegers and produces a string with ranges
>>>
copyright_years
([
1999
,
2000
,
2001
,
2005
,
2007
,
2008
,
2009
])
'
1999–2001, 2005, 2007–2009
'
"""
ranges
=
[
list
(
map
(
itemgetter
(
1
),
group
))
for
_
,
group
in
groupby
(
enumerate
(
years
),
lambda
e
:
e
[
1
]
-
e
[
0
])]
years_strs
=
[
str
(
range_
[
0
])
if
len
(
range_
)
==
1
else
joiner
.
join
([
str
(
range_
[
0
]),
str
(
range_
[
-
1
])])
for
range_
in
ranges
]
return
seperator
.
join
(
years_strs
)
def
dt_show_toolbar
(
request
:
HttpRequest
)
->
bool
:
from
debug_toolbar.middleware
import
show_toolbar
# noqa
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment