hygeos-core 1.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- core/__init__.py +8 -0
- core/ascii_table.py +268 -0
- core/auth.py +4 -0
- core/cache.py +10 -0
- core/condor.py +9 -0
- core/config.py +131 -0
- core/conftest.py +4 -0
- core/dates.py +71 -0
- core/deptree.py +4 -0
- core/deptree_prefect.py +4 -0
- core/download.py +4 -0
- core/env.py +194 -0
- core/files/__init__.py +5 -0
- core/files/cache.py +334 -0
- core/files/fileutils.py +392 -0
- core/files/lock.py +50 -0
- core/files/save.py +100 -0
- core/files/uncompress.py +268 -0
- core/fileutils.py +11 -0
- core/ftp.py +12 -0
- core/fuzzy.py +61 -0
- core/geo/__init__.py +3 -0
- core/geo/convert.py +36 -0
- core/geo/naming.py +56 -0
- core/geo/patterns.csv +30 -0
- core/geo/product_name.py +132 -0
- core/import_utils.py +21 -0
- core/interpolate.py +1058 -0
- core/lock.py +4 -0
- core/log.py +279 -0
- core/masks.py +42 -0
- core/monitor.py +370 -0
- core/network/auth.py +32 -0
- core/network/download.py +63 -0
- core/network/ftp.py +182 -0
- core/process/blockwise.py +918 -0
- core/process/condor.py +73 -0
- core/process/deptree.py +604 -0
- core/process/deptree_prefect.py +134 -0
- core/progressbar.py +387 -0
- core/pseudoinverse.py +40 -0
- core/pytest_utils.py +5 -0
- core/save.py +4 -0
- core/static/Exceptions.py +11 -0
- core/static/__init__.py +6 -0
- core/static/abstract.py +74 -0
- core/static/constraint.py +146 -0
- core/static/interface.py +183 -0
- core/static/parametrized.py +9 -0
- core/static/singleton.py +42 -0
- core/static/virtual.py +6 -0
- core/table.py +129 -0
- core/tests/conftest.py +355 -0
- core/tests/graphics.py +194 -0
- core/tests/pytest_utils.py +16 -0
- core/tools.py +1274 -0
- core/uncompress.py +4 -0
- core/xrtags.py +62 -0
- hygeos_core-1.3.2.dist-info/METADATA +23 -0
- hygeos_core-1.3.2.dist-info/RECORD +63 -0
- hygeos_core-1.3.2.dist-info/WHEEL +4 -0
- hygeos_core-1.3.2.dist-info/licenses/LICENSE +202 -0
- hygeos_core-1.3.2.dist-info/licenses/NOTICE +13 -0
core/__init__.py
ADDED
core/ascii_table.py
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import time
|
|
2
|
+
from typing import Literal
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ascii_table:
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
A class to represent a table for displaying data in a formatted way.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
class style:
|
|
12
|
+
"""
|
|
13
|
+
A class to define the style of a table using specific characters.
|
|
14
|
+
"""
|
|
15
|
+
def __init__(self,
|
|
16
|
+
inner_vbar = True,
|
|
17
|
+
inner_hbar = False,
|
|
18
|
+
h_padding = 1,
|
|
19
|
+
v_padding = 0,
|
|
20
|
+
style: Literal["squared", "rounded", "simple", "double"] = "squared",
|
|
21
|
+
):
|
|
22
|
+
|
|
23
|
+
styles = dict(
|
|
24
|
+
squared = "─│┌┐└┘├┤┬┴┼",
|
|
25
|
+
rounded = "─│╭╮╰╯├┤┬┴┼",
|
|
26
|
+
simple = "-|+++++++++",
|
|
27
|
+
double = "═║╔╗╚╝╠╣╦╩╬",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
self.style = styles[style]
|
|
31
|
+
|
|
32
|
+
self.inner_vbar = inner_vbar
|
|
33
|
+
self.inner_hbar = inner_hbar
|
|
34
|
+
self.h_padding = h_padding
|
|
35
|
+
self.v_padding = v_padding
|
|
36
|
+
|
|
37
|
+
# internal config
|
|
38
|
+
self.h = self.style[0] # horizontal char
|
|
39
|
+
self.v = self.style[1] # vertical char
|
|
40
|
+
self.tl = self.style[2] # corner top left
|
|
41
|
+
self.tr = self.style[3] # corner top right
|
|
42
|
+
self.bl = self.style[4] # corner bot left
|
|
43
|
+
self.br = self.style[5] # corner bot right
|
|
44
|
+
self.ml = self.style[6] # mid left
|
|
45
|
+
self.mr = self.style[7] # mid right
|
|
46
|
+
self.mt = self.style[8] # mid top
|
|
47
|
+
self.mb = self.style[9] # mid bot
|
|
48
|
+
self.cr = self.style[10] # cross
|
|
49
|
+
|
|
50
|
+
self.live_print_target_time = 0.100 # s
|
|
51
|
+
|
|
52
|
+
def __init__(self, df, style=style(), colors={}, sides={}, max_width: int|None=35):
|
|
53
|
+
"""
|
|
54
|
+
Ascii table constructor
|
|
55
|
+
df: source table, pd.DataFrame
|
|
56
|
+
style: allows to override the styling of the table
|
|
57
|
+
colors: is a dictionnary of core.log.rgb colors like {column: rgb.green}
|
|
58
|
+
|
|
59
|
+
Basic usage:
|
|
60
|
+
ascii_table(res).print()
|
|
61
|
+
"""
|
|
62
|
+
self.df = df
|
|
63
|
+
self._style = style
|
|
64
|
+
|
|
65
|
+
df_str = df.astype(str)
|
|
66
|
+
self.columns: list[str] = df_str.columns
|
|
67
|
+
self.spaces: list[int] = df_str[self.columns].apply(
|
|
68
|
+
lambda col: max(len(col.name), col.str.len().max())
|
|
69
|
+
).tolist()
|
|
70
|
+
|
|
71
|
+
# NOTE: could use interactive / dynamic ranges, more complex tough
|
|
72
|
+
# self.terminal = shutil.get_terminal_size()
|
|
73
|
+
|
|
74
|
+
# lowercase the columns keys
|
|
75
|
+
colors = {k.lower(): v for k, v in colors.items()}
|
|
76
|
+
sides = {k.lower(): v for k, v in sides.items()}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
for c in self.columns:
|
|
80
|
+
if c.lower() not in colors: # no colors by default
|
|
81
|
+
colors[c.lower()] = None
|
|
82
|
+
|
|
83
|
+
if c.lower() not in sides: # left side by default
|
|
84
|
+
sides[c.lower()] = "left"
|
|
85
|
+
|
|
86
|
+
self.colors = [colors[i.lower()] for i in self.columns]
|
|
87
|
+
self.sides = [sides[i.lower()] for i in self.columns]
|
|
88
|
+
|
|
89
|
+
# limiting column max width
|
|
90
|
+
self.max_width = max_width
|
|
91
|
+
if max_width is not None:
|
|
92
|
+
for i, v in enumerate(self.spaces):
|
|
93
|
+
if v > max_width:
|
|
94
|
+
self.spaces[i] = max_width
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def print(self, live_print=False, no_color=False):
|
|
99
|
+
s = self.to_string(live_print, no_color)
|
|
100
|
+
print(s)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def to_string(self, live_print=False, no_color=True):
|
|
104
|
+
"""
|
|
105
|
+
Generates an ascii representation of the dataset provided in the constructor.
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
# NOTE: does not (yet) handle line reduction with ellipsis
|
|
109
|
+
# ellipsis_char = "‥" # "…" # two dots variants seems more readable
|
|
110
|
+
# width_footprint = sum(self.widths) + 3*len(self.widths) + 1
|
|
111
|
+
# width_overshoot = width_footprint - self.terminal.columns
|
|
112
|
+
|
|
113
|
+
# config
|
|
114
|
+
ivb = self._style.inner_vbar
|
|
115
|
+
ihb = self._style.inner_hbar
|
|
116
|
+
hp = self._style.h_padding
|
|
117
|
+
vp = self._style.v_padding
|
|
118
|
+
|
|
119
|
+
# style characters
|
|
120
|
+
h = self._style.h # horizontal
|
|
121
|
+
v = self._style.v # vertical
|
|
122
|
+
tl = self._style.tl # top left corner
|
|
123
|
+
tr = self._style.tr # top right corner
|
|
124
|
+
bl = self._style.bl # bottom left
|
|
125
|
+
br = self._style.br # bottom right
|
|
126
|
+
mr = self._style.mr # mid right
|
|
127
|
+
mt = self._style.mt # mid top
|
|
128
|
+
ml = self._style.ml # mid left
|
|
129
|
+
mb = self._style.mb # mid bottom
|
|
130
|
+
cr = self._style.cr # cross
|
|
131
|
+
|
|
132
|
+
max_width = self.max_width
|
|
133
|
+
|
|
134
|
+
spaces = self.spaces.copy()
|
|
135
|
+
colors = self.colors.copy()
|
|
136
|
+
sides = self.sides.copy()
|
|
137
|
+
|
|
138
|
+
# Precompute common strings
|
|
139
|
+
hhp = h * hp
|
|
140
|
+
shp = ' ' * hp
|
|
141
|
+
h_line = h * (hp * 2 + 1) # For cases without inner bars
|
|
142
|
+
|
|
143
|
+
def _line_separator(pos):
|
|
144
|
+
"""
|
|
145
|
+
Generates an ascii separator line for the table based on position.
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
if pos == "mid":
|
|
149
|
+
|
|
150
|
+
ivbc = cr if ivb else h # cross if inner vertical bars, line otherwise
|
|
151
|
+
sep = hhp + ivbc + hhp # construct mid separator (not on the outer side)
|
|
152
|
+
if not ivb: sep = hhp # if no vertical bar, reduce padding
|
|
153
|
+
|
|
154
|
+
mids = [h*w for w in spaces]
|
|
155
|
+
line = ml + hhp + sep.join(mids) + hhp + mr
|
|
156
|
+
return line
|
|
157
|
+
|
|
158
|
+
if pos == "top":
|
|
159
|
+
|
|
160
|
+
ivbc = mt if ivb else h
|
|
161
|
+
sep = hhp + ivbc + hhp
|
|
162
|
+
if not ivb: sep = hhp
|
|
163
|
+
|
|
164
|
+
mids = [h*w for w in spaces]
|
|
165
|
+
line = tl + hhp + sep.join(mids) + hhp + tr
|
|
166
|
+
return line
|
|
167
|
+
|
|
168
|
+
if pos == "bot":
|
|
169
|
+
|
|
170
|
+
ivbc = mb if ivb else h
|
|
171
|
+
sep = hhp + ivbc + hhp
|
|
172
|
+
if not ivb: sep = hhp
|
|
173
|
+
|
|
174
|
+
mids = [h*w for w in spaces]
|
|
175
|
+
line = bl + hhp + sep.join(mids) + hhp + br
|
|
176
|
+
return line
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def _line_padding():
|
|
180
|
+
"""
|
|
181
|
+
Generates an ascii padding line for the table.
|
|
182
|
+
"""
|
|
183
|
+
|
|
184
|
+
ivbc = v if ivb else h
|
|
185
|
+
sep = shp + ivbc + shp
|
|
186
|
+
if not ihb: sep = shp
|
|
187
|
+
|
|
188
|
+
mids = [" "*w for w in spaces]
|
|
189
|
+
line = ml + shp + sep.join(mids) + shp + mr
|
|
190
|
+
return line
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _color_str(s, i):
|
|
194
|
+
c = colors[i]
|
|
195
|
+
|
|
196
|
+
if c is not None:
|
|
197
|
+
return c(s)
|
|
198
|
+
return s
|
|
199
|
+
|
|
200
|
+
def _format_str(s):
|
|
201
|
+
|
|
202
|
+
l = max_width
|
|
203
|
+
if len(s) > l:
|
|
204
|
+
s = s[:l-1] + "‥"
|
|
205
|
+
return s
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
# disable for performance reason
|
|
209
|
+
if not max_width:
|
|
210
|
+
_format_str = lambda x: x
|
|
211
|
+
|
|
212
|
+
# disable colors
|
|
213
|
+
if no_color:
|
|
214
|
+
_color_str = lambda x, y: x
|
|
215
|
+
|
|
216
|
+
def _line_content(line):
|
|
217
|
+
"""
|
|
218
|
+
Generates an ascii content line for the table.
|
|
219
|
+
"""
|
|
220
|
+
|
|
221
|
+
ivbc = v if ivb else h
|
|
222
|
+
sep = shp + ivbc + shp
|
|
223
|
+
if not ivb: sep = shp
|
|
224
|
+
|
|
225
|
+
def align_text(text, width, side):
|
|
226
|
+
return text.ljust(width) if side == "left" else text.rjust(width)
|
|
227
|
+
|
|
228
|
+
mids = [
|
|
229
|
+
_color_str(align_text(_format_str(str(w)), spaces[i], sides[i]), i)
|
|
230
|
+
for i, w in enumerate(line)
|
|
231
|
+
]
|
|
232
|
+
line = v + shp + sep.join(mids) + shp + v
|
|
233
|
+
return line
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
"""
|
|
237
|
+
Main routine using the previous subroutines
|
|
238
|
+
Iterates over each lines of the dataframe and builds the ascii representation
|
|
239
|
+
"""
|
|
240
|
+
|
|
241
|
+
entries = self.df[self.columns].values
|
|
242
|
+
lines = []
|
|
243
|
+
|
|
244
|
+
headers = [s.capitalize() for s in self.columns]
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
itr = self._style.live_print_target_time / len(self.df)
|
|
248
|
+
itr = min(itr, 0.015)
|
|
249
|
+
fn = lines.append if not live_print else lambda x: (time.sleep(itr), print(x, flush=True))
|
|
250
|
+
|
|
251
|
+
fn("")
|
|
252
|
+
fn(_line_separator("top" ))
|
|
253
|
+
fn(_line_content(headers))
|
|
254
|
+
fn(_line_separator("mid" ))
|
|
255
|
+
for j, e in enumerate(entries):
|
|
256
|
+
|
|
257
|
+
for i in range(vp): fn(_line_padding("mid"))
|
|
258
|
+
fn(_line_content(e))
|
|
259
|
+
for i in range(vp): fn(_line_padding("mid"))
|
|
260
|
+
if ihb:
|
|
261
|
+
fn(_line_separator("mid"))
|
|
262
|
+
|
|
263
|
+
fn(_line_separator("bot"))
|
|
264
|
+
fn("")
|
|
265
|
+
|
|
266
|
+
if not live_print:
|
|
267
|
+
message = "\n".join(lines)
|
|
268
|
+
return message
|
core/auth.py
ADDED
core/cache.py
ADDED
core/condor.py
ADDED
core/config.py
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Optional, Any
|
|
3
|
+
from copy import deepcopy
|
|
4
|
+
import toml
|
|
5
|
+
|
|
6
|
+
from core.static import constraint
|
|
7
|
+
from core.static import interface
|
|
8
|
+
from core import log
|
|
9
|
+
|
|
10
|
+
from warnings import warn
|
|
11
|
+
|
|
12
|
+
warn('core.config will be deprecated.', DeprecationWarning)
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
Generic project configuration module.
|
|
16
|
+
Simpler version of core.config module, more generic
|
|
17
|
+
Config path need to be passed as argument
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
class Config:
|
|
21
|
+
|
|
22
|
+
@interface
|
|
23
|
+
def new_from_toml(config_path: Path, allow_empty_if_no_file: bool = False):
|
|
24
|
+
|
|
25
|
+
file_found = config_path.is_file() and config_path.name.endswith(".toml")
|
|
26
|
+
|
|
27
|
+
if not file_found and not allow_empty_if_no_file:
|
|
28
|
+
raise RuntimeError(f"Invalid config file path {config_path}")
|
|
29
|
+
|
|
30
|
+
configuration = {} if not file_found else toml.load(config_path)
|
|
31
|
+
|
|
32
|
+
return Config(configuration)
|
|
33
|
+
|
|
34
|
+
@interface
|
|
35
|
+
def new_from_dict(config_dict: dict):
|
|
36
|
+
return Config(config_dict)
|
|
37
|
+
|
|
38
|
+
@interface
|
|
39
|
+
def copy(self):
|
|
40
|
+
return Config(deepcopy(self.config_dict))
|
|
41
|
+
|
|
42
|
+
@interface
|
|
43
|
+
def __init__(self, config_dict: dict):
|
|
44
|
+
self.config_dict: dict = config_dict
|
|
45
|
+
|
|
46
|
+
@interface
|
|
47
|
+
def get_subsection(self, subsection: str=None, default:dict=None) -> dict:
|
|
48
|
+
"""
|
|
49
|
+
Returns the specified toml subsection
|
|
50
|
+
returns the root if None provided
|
|
51
|
+
"""
|
|
52
|
+
config_ptr = self.config_dict # get config content
|
|
53
|
+
|
|
54
|
+
# Section or nested subsection
|
|
55
|
+
if subsection is not None:
|
|
56
|
+
sections = subsection.split('.')
|
|
57
|
+
|
|
58
|
+
# find subsection
|
|
59
|
+
for sub in sections:
|
|
60
|
+
if sub in config_ptr:
|
|
61
|
+
config_ptr = config_ptr[sub]
|
|
62
|
+
else:
|
|
63
|
+
if default is not None:
|
|
64
|
+
return default
|
|
65
|
+
raise KeyError(f"Missing section [{subsection}] in config file")
|
|
66
|
+
return config_ptr
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@interface
|
|
70
|
+
def ingest(self, config_dict, override=True):
|
|
71
|
+
"""
|
|
72
|
+
Ingest a configuration, if override is true then doubled keys are overriden by new config
|
|
73
|
+
otherwise only add missing keys from new config
|
|
74
|
+
keeping the keys defined in configuration and not overriden by itself.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
if isinstance(config_dict, dict): # already a dict
|
|
78
|
+
pass
|
|
79
|
+
elif isinstance(config_dict, Config):
|
|
80
|
+
config_dict = config_dict.config_dict
|
|
81
|
+
else:
|
|
82
|
+
log.error(f"Unexpected argument type \'{type(config_dict)}\', expected dict or Config object", e=ValueError)
|
|
83
|
+
|
|
84
|
+
for k, v in config_dict.items(): # iterate provided defaults keys, vals
|
|
85
|
+
if k in self.config_dict: # if the key is not already defined
|
|
86
|
+
if not override:
|
|
87
|
+
continue
|
|
88
|
+
self.config_dict[k] = v
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@interface
|
|
92
|
+
def get(
|
|
93
|
+
self,
|
|
94
|
+
key: str,
|
|
95
|
+
subsection: str = None,
|
|
96
|
+
*,
|
|
97
|
+
default=None,
|
|
98
|
+
) -> Any:
|
|
99
|
+
"""
|
|
100
|
+
Returns the key if present in the config file.
|
|
101
|
+
If not present and no default provided: raises an error
|
|
102
|
+
if default is provided (different than None): return default instead
|
|
103
|
+
|
|
104
|
+
auto cast values to Path objects if its key starts with 'dir_' and its type is str
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
config_dict_ptr = self.get_subsection(subsection=subsection)
|
|
108
|
+
|
|
109
|
+
# key managing
|
|
110
|
+
if key not in config_dict_ptr:
|
|
111
|
+
if default is not None:
|
|
112
|
+
return default
|
|
113
|
+
else:
|
|
114
|
+
mess = "root section" if subsection is None else f"section [{subsection}]"
|
|
115
|
+
raise KeyError( f"Missing key \'{key}\' in {mess} of in config file")
|
|
116
|
+
|
|
117
|
+
# get value
|
|
118
|
+
value = config_dict_ptr[key]
|
|
119
|
+
|
|
120
|
+
# auto convert value to path if its key starts with 'dir_'
|
|
121
|
+
if type(value) is str and key.startswith("dir_"):
|
|
122
|
+
value = Path(value)
|
|
123
|
+
|
|
124
|
+
return value
|
|
125
|
+
|
|
126
|
+
def __str__(self):
|
|
127
|
+
return str(self.config_dict)
|
|
128
|
+
|
|
129
|
+
@interface
|
|
130
|
+
def __getitem__(self, key: str, subsection=None):
|
|
131
|
+
return self.get(key=key, subsection=subsection)
|
core/conftest.py
ADDED
core/dates.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from datetime import datetime, timedelta, date
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def round_date(date, h):
|
|
5
|
+
"""
|
|
6
|
+
Round a date to the bracketing hours, by steps of `h` hours
|
|
7
|
+
"""
|
|
8
|
+
assert isinstance(h, int)
|
|
9
|
+
day = datetime(date.year, date.month, date.day)
|
|
10
|
+
d0 = day + timedelta(hours=h*(date.hour//h))
|
|
11
|
+
d1 = d0 + timedelta(hours=h)
|
|
12
|
+
return (d0, d1)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def closest(date, h):
|
|
16
|
+
"""
|
|
17
|
+
Round a date to the closest hour, by steps of `h` hours
|
|
18
|
+
"""
|
|
19
|
+
assert isinstance(h, int)
|
|
20
|
+
d0 = round_date(date, h)[0]
|
|
21
|
+
if date - d0 < timedelta(hours=float(h)/2.):
|
|
22
|
+
return d0
|
|
23
|
+
else:
|
|
24
|
+
return d0 + timedelta(hours=h)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def date_range(date_start: date, date_end: date) -> list[date]:
|
|
28
|
+
"""
|
|
29
|
+
Returns a list of days starting from date_start, up to date_end included
|
|
30
|
+
"""
|
|
31
|
+
days_list = [date_start + i*timedelta(days=1) for i in range((date_end - date_start).days + 1)]
|
|
32
|
+
return days_list
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def time_range(start: datetime, end: datetime, step: timedelta) -> list[datetime]:
|
|
36
|
+
"""
|
|
37
|
+
Returns a list of datetime starting from start, up to end included
|
|
38
|
+
"""
|
|
39
|
+
assert end > start
|
|
40
|
+
dt = (end - start) // step
|
|
41
|
+
datelist = [start + i*step for i in range(dt)]
|
|
42
|
+
if end not in datelist: datelist += [end]
|
|
43
|
+
return datelist
|
|
44
|
+
|
|
45
|
+
def now_isofmt():
|
|
46
|
+
"""
|
|
47
|
+
Returns now in iso format
|
|
48
|
+
"""
|
|
49
|
+
return datetime.now().isoformat()
|
|
50
|
+
|
|
51
|
+
def duration(s):
|
|
52
|
+
"""
|
|
53
|
+
Returns a timedelta from a string `s`
|
|
54
|
+
"""
|
|
55
|
+
if s.endswith('w'):
|
|
56
|
+
return timedelta(weeks=float(s[:-1]))
|
|
57
|
+
elif s.endswith('d'):
|
|
58
|
+
return timedelta(days=float(s[:-1]))
|
|
59
|
+
elif s.endswith('h'):
|
|
60
|
+
return timedelta(hours=float(s[:-1]))
|
|
61
|
+
else:
|
|
62
|
+
raise Exception(f'Can not convert "{s}"')
|
|
63
|
+
|
|
64
|
+
def get_month_range(year: int, month: int):
|
|
65
|
+
"""
|
|
66
|
+
Returns a couple of date corresponding to start and end of the month
|
|
67
|
+
"""
|
|
68
|
+
assert month <= 12, f'Invalid month, got {month}'
|
|
69
|
+
start = date(year, month, 1)
|
|
70
|
+
next_month = date(year+1,1,1) if month==12 else date(year,month+1,1)
|
|
71
|
+
return start, next_month-timedelta(1)
|
core/deptree.py
ADDED
core/deptree_prefect.py
ADDED
core/download.py
ADDED