dcicutils 8.8.3.1b12__tar.gz → 8.8.3.1b13__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/PKG-INFO +1 -1
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/data_readers.py +11 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/datetime_utils.py +110 -1
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/progress_bar.py +3 -1
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/pyproject.toml +1 -1
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/LICENSE.txt +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/README.rst +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/__init__.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/base.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/beanstalk_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/bundle_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/captured_output.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/cloudformation_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/codebuild_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/command_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/common.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/contribution_scripts.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/contribution_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/creds_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/data_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/deployment_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/diff_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/docker_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/ecr_scripts.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/ecr_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/ecs_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/env_base.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/env_manager.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/env_scripts.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/env_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/env_utils_legacy.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/es_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/exceptions.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/ff_mocks.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/ff_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/file_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/function_cache_decorator.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/glacier_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/jh_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/kibana/dashboards.json +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/kibana/readme.md +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/lang_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/license_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/log_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/misc_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/obfuscation_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/opensearch_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/portal_object_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/portal_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/project_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/qa_checkers.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/qa_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/redis_tools.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/redis_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/s3_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/schema_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/scripts/publish_to_pypi.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/scripts/run_license_checker.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/scripts/view_portal_object.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/secrets_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/sheet_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/snapshot_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/ssl_certificate_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/structured_data.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/submitr/progress_constants.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/task_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/tmpfile_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/trace_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/validation_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/variant_utils.py +0 -0
- {dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/zip_utils.py +0 -0
@@ -66,6 +66,13 @@ class RowReader(abc.ABC):
|
|
66
66
|
else:
|
67
67
|
return value
|
68
68
|
|
69
|
+
@property
|
70
|
+
def nrows(self) -> int:
|
71
|
+
nrows = 0
|
72
|
+
for row in self:
|
73
|
+
nrows += 1
|
74
|
+
return nrows
|
75
|
+
|
69
76
|
def open(self) -> None:
|
70
77
|
pass
|
71
78
|
|
@@ -192,6 +199,10 @@ class Excel:
|
|
192
199
|
return True
|
193
200
|
return False
|
194
201
|
|
202
|
+
@property
|
203
|
+
def nsheets(self) -> int:
|
204
|
+
return len(self.sheet_names)
|
205
|
+
|
195
206
|
def __del__(self) -> None:
|
196
207
|
if (workbook := self._workbook) is not None:
|
197
208
|
self._workbook = None
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from dcicutils.misc_utils import normalize_spaces
|
2
2
|
from datetime import datetime, timedelta, timezone
|
3
|
-
from
|
3
|
+
from dateutil import parser as datetime_parser
|
4
|
+
from typing import Optional, Tuple, Union
|
4
5
|
|
5
6
|
|
6
7
|
def parse_datetime_string(value: str) -> Optional[datetime]:
|
@@ -82,6 +83,32 @@ def normalize_date_string(value: str) -> Optional[str]:
|
|
82
83
|
return d.strftime("%Y-%m-%d") if d else None
|
83
84
|
|
84
85
|
|
86
|
+
def get_timezone(hours: int, minutes: Optional[int] = None) -> timezone:
|
87
|
+
try:
|
88
|
+
return timezone(timedelta(hours=hours, minutes=minutes or 0))
|
89
|
+
except Exception:
|
90
|
+
return timezone.utc
|
91
|
+
|
92
|
+
|
93
|
+
def get_timezone_hours_minutes(tz: timezone) -> Tuple[int, int]:
|
94
|
+
"""
|
95
|
+
Returns a tuple with the integer hours and minutes offset for the given timezone.
|
96
|
+
"""
|
97
|
+
tz_minutes = datetime.now(tz).utcoffset().total_seconds() / 60
|
98
|
+
return int(tz_minutes // 60), int(abs(tz_minutes % 60))
|
99
|
+
|
100
|
+
|
101
|
+
def get_utc_timezone() -> timezone:
|
102
|
+
return timezone.utc
|
103
|
+
|
104
|
+
|
105
|
+
def get_local_timezone() -> timezone:
|
106
|
+
"""
|
107
|
+
Returns current/local timezone as a datetime.timezone object.
|
108
|
+
"""
|
109
|
+
return datetime.now().astimezone().tzinfo
|
110
|
+
|
111
|
+
|
85
112
|
def get_local_timezone_string() -> str:
|
86
113
|
"""
|
87
114
|
Returns current/local timezone in format like: "-05:00".
|
@@ -96,3 +123,85 @@ def get_local_timezone_hours_minutes() -> Tuple[int, int]:
|
|
96
123
|
"""
|
97
124
|
tz_minutes = datetime.now(timezone.utc).astimezone().utcoffset().total_seconds() / 60
|
98
125
|
return int(tz_minutes // 60), int(abs(tz_minutes % 60))
|
126
|
+
|
127
|
+
|
128
|
+
def parse_datetime(value: str, utc: bool = False, tz: Optional[timezone] = None) -> Optional[datetime]:
|
129
|
+
"""
|
130
|
+
Parses the given string into a datetime, if possible, and returns that value,
|
131
|
+
or None if not able to parse. The timezone of the returned datetime will be the
|
132
|
+
local timezone; or if the given utc argument is True then it will be UTC; or if the
|
133
|
+
given tz argument is a datetime.timezone then return datetime will be in that timezone.
|
134
|
+
"""
|
135
|
+
if isinstance(value, datetime):
|
136
|
+
return value
|
137
|
+
elif not isinstance(value, str):
|
138
|
+
return None
|
139
|
+
try:
|
140
|
+
# This dateutil.parser handles quite a wide variety of formats and suits our needs.
|
141
|
+
value = datetime_parser.parse(value)
|
142
|
+
if utc is True:
|
143
|
+
# If the given utc argument is True then it trumps any tz argument if given.
|
144
|
+
tz = timezone.utc
|
145
|
+
if value.tzinfo is not None:
|
146
|
+
# The given value had an explicit timezone specified.
|
147
|
+
if isinstance(tz, timezone):
|
148
|
+
return value.astimezone(tz)
|
149
|
+
return value
|
150
|
+
return value.replace(tzinfo=tz if isinstance(tz, timezone) else get_local_timezone())
|
151
|
+
except Exception:
|
152
|
+
return None
|
153
|
+
|
154
|
+
|
155
|
+
def format_datetime(value: datetime,
|
156
|
+
utc: bool = False,
|
157
|
+
iso: bool = False,
|
158
|
+
ms: bool = False,
|
159
|
+
tz: Optional[Union[timezone, bool]] = None,
|
160
|
+
notz: bool = False,
|
161
|
+
noseconds: bool = False,
|
162
|
+
verbose: bool = False,
|
163
|
+
noseparator: bool = False,
|
164
|
+
noday: bool = False) -> Optional[str]:
|
165
|
+
"""
|
166
|
+
Returns the given datetime as a string in "YYYY:MM:DD hh:mm:ss tz" format, for
|
167
|
+
example "2024-04-17 15:42:26 EDT". If the given notz argument is True then omits
|
168
|
+
the timezone; if the noseconds argument is given the omits the seconds. If the given
|
169
|
+
verbose argument is True then returns a really verbose version of the datetime, for
|
170
|
+
example "Wednesday, April 17, 2024 | 15:42:26 EDT"; if the noseparator argument is
|
171
|
+
True then omits the "|" separator; if the noday argument is True then omits the day
|
172
|
+
of week part. The timezone of the returned datetime string will default to the local
|
173
|
+
one; if the given utc argument is True then it will be UTC; or if the given tz
|
174
|
+
argument is a datetime.timezone it will be in that timezone.
|
175
|
+
"""
|
176
|
+
if not isinstance(value, datetime):
|
177
|
+
if not isinstance(value, str) or not (value := parse_datetime(value)):
|
178
|
+
return None
|
179
|
+
try:
|
180
|
+
if utc is True:
|
181
|
+
tz = timezone.utc
|
182
|
+
elif not isinstance(tz, timezone):
|
183
|
+
tz = get_local_timezone()
|
184
|
+
if tz is True:
|
185
|
+
notz = False
|
186
|
+
elif tz is False:
|
187
|
+
notz = True
|
188
|
+
value = value.astimezone(tz)
|
189
|
+
if iso:
|
190
|
+
if notz is True:
|
191
|
+
value = value.replace(tzinfo=None)
|
192
|
+
if not (ms is True):
|
193
|
+
value = value.replace(microsecond=0)
|
194
|
+
return value.isoformat()
|
195
|
+
if noseconds is True:
|
196
|
+
ms = False
|
197
|
+
if verbose:
|
198
|
+
return value.strftime(
|
199
|
+
f"{'' if noday is True else '%A, '}%B %-d, %Y{'' if noseparator is True else ' |'}"
|
200
|
+
f" %-I:%M{'' if noseconds is True else ':%S'}"
|
201
|
+
f"{f'.%f' if ms is True else ''} %p{'' if notz is True else ' %Z'}")
|
202
|
+
else:
|
203
|
+
return value.strftime(
|
204
|
+
f"%Y-%m-%d %H:%M{'' if noseconds is True else ':%S'}"
|
205
|
+
f"{f'.%f' if ms is True else ''}{'' if notz is True else ' %Z'}")
|
206
|
+
except Exception:
|
207
|
+
return None
|
@@ -50,6 +50,7 @@ class ProgressBar:
|
|
50
50
|
def __init__(self, total: Optional[int] = None,
|
51
51
|
description: Optional[str] = None,
|
52
52
|
use_byte_size_for_rate: bool = False,
|
53
|
+
use_ascii: bool = False,
|
53
54
|
catch_interrupt: bool = True,
|
54
55
|
interrupt: Optional[Callable] = None,
|
55
56
|
interrupt_continue: Optional[Callable] = None,
|
@@ -66,6 +67,7 @@ class ProgressBar:
|
|
66
67
|
self._tidy_output_hack = (tidy_output_hack is True)
|
67
68
|
self._stop_requested = False
|
68
69
|
self._use_byte_size_for_rate = (use_byte_size_for_rate is True and self._tidy_output_hack)
|
70
|
+
self._use_ascii = (use_ascii is True)
|
69
71
|
# Interrupt handling. We do not do the actual (signal) interrupt setup
|
70
72
|
# in self._initialize as that could be called from a (sub) thread; and in
|
71
73
|
# Python we can only set a signal (SIGINT in our case) on the main thread.
|
@@ -103,7 +105,7 @@ class ProgressBar:
|
|
103
105
|
else:
|
104
106
|
bar_format = "{l_bar}{bar}| {n_fmt}/{total_fmt} | {rate_fmt} | {elapsed}{postfix} | ETA: {remaining} "
|
105
107
|
self._bar = TQDM(total=self._total, desc=self._description,
|
106
|
-
dynamic_ncols=True, bar_format=bar_format, unit="", file=sys.stdout)
|
108
|
+
dynamic_ncols=True, bar_format=bar_format, unit="", file=sys.stdout, ascii=self._use_ascii)
|
107
109
|
self._started = time.time()
|
108
110
|
if self._disabled:
|
109
111
|
self._bar.disable = True
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "dcicutils"
|
3
|
-
version = "8.8.3.
|
3
|
+
version = "8.8.3.1b13" # TODO: To become 8.8.4
|
4
4
|
description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
|
5
5
|
authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
|
6
6
|
license = "MIT"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/license_policies/c4-infrastructure.jsonc
RENAMED
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/license_policies/park-lab-common.jsonc
RENAMED
File without changes
|
{dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc
RENAMED
File without changes
|
{dcicutils-8.8.3.1b12 → dcicutils-8.8.3.1b13}/dcicutils/license_policies/park-lab-pipeline.jsonc
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|