Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
public
satella
Commits
98de1aed
Unverified
Commit
98de1aed
authored
8 months ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
fix build
parent
ee4bfd22
No related branches found
No related tags found
No related merge requests found
Pipeline
#62422
passed with stages
in 1 minute and 52 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
satella/coding/structures/dictionaries/cache_dict.py
+33
-0
33 additions, 0 deletions
satella/coding/structures/dictionaries/cache_dict.py
with
33 additions
and
0 deletions
satella/coding/structures/dictionaries/cache_dict.py
+
33
−
0
View file @
98de1aed
...
@@ -11,6 +11,39 @@ from satella.coding.typing import K, V, NoArgCallable
...
@@ -11,6 +11,39 @@ from satella.coding.typing import K, V, NoArgCallable
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
_TIME_MODIFIERS
=
[
(
'
s
'
,
1
),
(
'
m
'
,
60
),
(
'
h
'
,
60
*
60
),
(
'
d
'
,
24
*
60
*
60
),
(
'
w
'
,
7
*
24
*
60
*
60
)
]
def
_parse_time_string
(
s
:
tp
.
Union
[
int
,
float
,
str
])
->
float
:
"""
Parse a time string into seconds, so eg.
'
30m
'
will be equal to 1800, and so will
be
'
30 min
'
.
This will correctly parse:
- seconds
- minutes
- hours
- days
- weeks
.. warning:: This does not handle fractions of a second!
:param s: time string or time value in seconds
:return: value in seconds
"""
if
isinstance
(
s
,
(
int
,
float
)):
return
s
for
modifier
,
multiple
in
_TIME_MODIFIERS
:
if
modifier
in
s
:
return
float
(
s
[:
s
.
index
(
modifier
)])
*
multiple
return
float
(
s
)
class
CacheDict
(
tp
.
Mapping
[
K
,
V
]):
class
CacheDict
(
tp
.
Mapping
[
K
,
V
]):
"""
"""
...
...
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