dcicutils 8.13.3.1b25__tar.gz → 8.13.3.1b26__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/PKG-INFO +1 -1
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/misc_utils.py +68 -58
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/structured_data.py +7 -7
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/pyproject.toml +1 -1
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/LICENSE.txt +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/README.rst +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/__init__.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/base.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/beanstalk_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/bundle_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/captured_output.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/cloudformation_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/codebuild_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/command_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/common.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/contribution_scripts.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/contribution_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/creds_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/data_readers.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/data_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/datetime_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/deployment_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/diff_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/docker_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/ecr_scripts.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/ecr_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/ecs_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/env_base.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/env_manager.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/env_scripts.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/env_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/env_utils_legacy.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/es_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/exceptions.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/ff_mocks.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/ff_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/file_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/function_cache_decorator.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/glacier_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/hack_for_elasticsearch_numpy_usage.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/http_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/jh_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/kibana/dashboards.json +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/kibana/readme.md +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/lang_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/license_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/log_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/obfuscation_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/opensearch_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/portal_object_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/portal_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/progress_bar.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/project_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/qa_checkers.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/qa_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/redis_tools.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/redis_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/s3_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/schema_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/scripts/publish_to_pypi.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/scripts/run_license_checker.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/scripts/update_portal_object.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/scripts/view_portal_object.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/secrets_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/sheet_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/snapshot_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/ssl_certificate_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/submitr/progress_constants.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/task_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/tmpfile_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/trace_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/validation_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/variant_utils.py +0 -0
- {dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/zip_utils.py +0 -0
@@ -986,53 +986,61 @@ def str_to_bool(x: Optional[str]) -> Optional[bool]:
|
|
986
986
|
raise ValueError(f"An argument to str_or_bool must be a string or None: {x!r}")
|
987
987
|
|
988
988
|
|
989
|
-
def to_integer(value: str,
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
"
|
1014
|
-
"
|
989
|
+
def to_integer(value: str,
|
990
|
+
allow_commas: bool = False,
|
991
|
+
allow_multiplier_suffix: bool = False,
|
992
|
+
fallback: Optional[Union[int, float]] = None) -> Optional[int]:
|
993
|
+
return to_number(value, fallback=fallback, as_float=False,
|
994
|
+
allow_commas=allow_commas,
|
995
|
+
allow_multiplier_suffix=allow_multiplier_suffix)
|
996
|
+
|
997
|
+
|
998
|
+
def to_float(value: str,
|
999
|
+
allow_commas: bool = False,
|
1000
|
+
allow_multiplier_suffix: bool = False,
|
1001
|
+
fallback: Optional[Union[int, float]] = None) -> Optional[int]:
|
1002
|
+
return to_number(value, fallback=fallback, as_float=True,
|
1003
|
+
allow_commas=allow_commas,
|
1004
|
+
allow_multiplier_suffix=allow_multiplier_suffix)
|
1005
|
+
|
1006
|
+
|
1007
|
+
_TO_NUMBER_MULTIPLIER_K = 1000
|
1008
|
+
_TO_NUMBER_MULTIPLIER_M = 1000 * _TO_NUMBER_MULTIPLIER_K
|
1009
|
+
_TO_NUMBER_MULTIPLIER_G = 1000 * _TO_NUMBER_MULTIPLIER_M
|
1010
|
+
_TO_NUMBER_MULTIPLIER_T = 1000 * _TO_NUMBER_MULTIPLIER_G
|
1011
|
+
|
1012
|
+
_TO_NUMBER_MULTIPLIER_SUFFIXES = {
|
1013
|
+
"K": _TO_NUMBER_MULTIPLIER_K,
|
1014
|
+
"KB": _TO_NUMBER_MULTIPLIER_K,
|
1015
|
+
"M": _TO_NUMBER_MULTIPLIER_M,
|
1016
|
+
"MB": _TO_NUMBER_MULTIPLIER_M,
|
1017
|
+
"G": _TO_NUMBER_MULTIPLIER_G,
|
1018
|
+
"GB": _TO_NUMBER_MULTIPLIER_G,
|
1019
|
+
"T": _TO_NUMBER_MULTIPLIER_T,
|
1020
|
+
"TB": _TO_NUMBER_MULTIPLIER_T
|
1015
1021
|
}
|
1016
1022
|
|
1017
1023
|
|
1018
1024
|
def to_number(value: str,
|
1025
|
+
as_float: bool = False,
|
1019
1026
|
allow_commas: bool = False,
|
1020
1027
|
allow_multiplier_suffix: bool = False,
|
1021
|
-
allow_float: bool = False,
|
1022
1028
|
fallback: Optional[Union[int, float]] = None) -> Optional[Union[int, float]]:
|
1023
|
-
|
1024
1029
|
"""
|
1025
|
-
Converts the
|
1026
|
-
If allow_commas is True
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
If the string is not well formated then returns None.
|
1030
|
+
Converts the given string value to an int, or float if as_float is True, or None if malformed.
|
1031
|
+
If allow_commas is True then allow commas (only) every three digits. If allow_multiplier_suffix
|
1032
|
+
is True allow any of K, KB; or M, MB; or G, or GB; or T, TB (case-insensitive), to mean multiply
|
1033
|
+
value by one thousand; one million; one billion; or one trillion; respectively. If as_float is True
|
1034
|
+
then value is parsed and returned as a float rather than int. Note that even if as_float is False,
|
1035
|
+
values that might look like a float, can be an int, for example, "1.5K", returns 1500 as an int;
|
1036
|
+
but "1.5002K" returns None, i.e. since 1.5002K is 1500.2 which is not an int.
|
1033
1037
|
"""
|
1038
|
+
|
1034
1039
|
if not (isinstance(value, str) and (value := value.strip())):
|
1035
|
-
|
1040
|
+
if as_float is True:
|
1041
|
+
return float(value) if isinstance(value, (float, int)) else fallback
|
1042
|
+
else:
|
1043
|
+
return value if isinstance(value, int) else fallback
|
1036
1044
|
|
1037
1045
|
value_multiplier = 1
|
1038
1046
|
value_negative = False
|
@@ -1048,21 +1056,28 @@ def to_number(value: str,
|
|
1048
1056
|
|
1049
1057
|
if allow_multiplier_suffix is True:
|
1050
1058
|
value_upper = value.upper()
|
1051
|
-
for suffix in
|
1059
|
+
for suffix in _TO_NUMBER_MULTIPLIER_SUFFIXES:
|
1052
1060
|
if value_upper.endswith(suffix):
|
1053
|
-
value_multiplier *=
|
1061
|
+
value_multiplier *= _TO_NUMBER_MULTIPLIER_SUFFIXES[suffix]
|
1054
1062
|
if not (value := value[:-len(suffix)].strip()):
|
1055
1063
|
return fallback
|
1056
1064
|
break
|
1057
1065
|
|
1058
|
-
if
|
1066
|
+
if (allow_multiplier_suffix is True) or (as_float is True):
|
1067
|
+
# Allow for example "1.5K" to mean 1500 (integer).
|
1059
1068
|
if (dot_index := value.rfind(".")) >= 0:
|
1060
1069
|
if value_fraction := value[dot_index + 1:].strip():
|
1061
1070
|
try:
|
1062
1071
|
value_fraction = float(f"0.{value_fraction}")
|
1063
1072
|
except Exception:
|
1064
1073
|
return fallback
|
1065
|
-
value
|
1074
|
+
if not (value := value[:dot_index].strip()):
|
1075
|
+
if not value_fraction:
|
1076
|
+
return fallback
|
1077
|
+
value = "0"
|
1078
|
+
elif (as_float is not True) and (value_dot_zero_suffix := re.search(r"\.0*$", value)):
|
1079
|
+
# Allow for example "123.00" to mean 123 (integer).
|
1080
|
+
value = value[:value_dot_zero_suffix.start()]
|
1066
1081
|
|
1067
1082
|
if (allow_commas is True) and ("," in value):
|
1068
1083
|
if not re.fullmatch(r"(-?\d{1,3}(,\d{3})*)", value):
|
@@ -1072,28 +1087,23 @@ def to_number(value: str,
|
|
1072
1087
|
if not value.isdigit():
|
1073
1088
|
return fallback
|
1074
1089
|
|
1075
|
-
|
1090
|
+
value = float(value) if as_float is True else int(value)
|
1076
1091
|
|
1077
1092
|
if value_fraction:
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1093
|
+
value_float = (float(value) + value_fraction) * float(value_multiplier)
|
1094
|
+
if as_float is True:
|
1095
|
+
value = value_float
|
1096
|
+
else:
|
1097
|
+
value = int(value_float)
|
1098
|
+
if value_float != value:
|
1099
|
+
return fallback
|
1100
|
+
else:
|
1101
|
+
value *= value_multiplier
|
1081
1102
|
|
1082
1103
|
if value_negative:
|
1083
|
-
|
1084
|
-
|
1085
|
-
if allow_float is True:
|
1086
|
-
if result == int(result):
|
1087
|
-
result = int(result)
|
1088
|
-
|
1089
|
-
return result
|
1104
|
+
value = -value
|
1090
1105
|
|
1091
|
-
|
1092
|
-
def to_float(value: str, fallback: Optional[Any] = None) -> Optional[Any]:
|
1093
|
-
try:
|
1094
|
-
return float(value)
|
1095
|
-
except Exception:
|
1096
|
-
return fallback
|
1106
|
+
return value
|
1097
1107
|
|
1098
1108
|
|
1099
1109
|
def to_boolean(value: str, fallback: Optional[Any]) -> Optional[Any]:
|
@@ -13,7 +13,7 @@ from dcicutils.data_readers import CsvReader, Excel, RowReader
|
|
13
13
|
from dcicutils.datetime_utils import normalize_date_string, normalize_datetime_string
|
14
14
|
from dcicutils.misc_utils import (create_dict, create_readonly_object, is_uuid, load_json_if,
|
15
15
|
merge_objects, remove_empty_properties, right_trim, split_string,
|
16
|
-
to_boolean, to_enum,
|
16
|
+
to_boolean, to_enum, to_float, to_integer, VirtualApp)
|
17
17
|
from dcicutils.portal_object_utils import PortalObject
|
18
18
|
from dcicutils.portal_utils import Portal as PortalBase
|
19
19
|
from dcicutils.submitr.progress_constants import PROGRESS_PARSE as PROGRESS
|
@@ -727,9 +727,9 @@ class Schema(SchemaBase):
|
|
727
727
|
allow_multiplier_suffix = typeinfo.get("allow_multiplier_suffix") is True
|
728
728
|
def map_integer(value: str, src: Optional[str]) -> Any: # noqa
|
729
729
|
nonlocal allow_commas, allow_multiplier_suffix
|
730
|
-
return
|
731
|
-
|
732
|
-
|
730
|
+
return to_integer(value, fallback=value,
|
731
|
+
allow_commas=allow_commas,
|
732
|
+
allow_multiplier_suffix=allow_multiplier_suffix)
|
733
733
|
return map_integer
|
734
734
|
|
735
735
|
def _map_function_number(self, typeinfo: dict) -> Callable:
|
@@ -737,9 +737,9 @@ class Schema(SchemaBase):
|
|
737
737
|
allow_multiplier_suffix = typeinfo.get("allow_multiplier_suffix") is True
|
738
738
|
def map_number(value: str, src: Optional[str]) -> Any: # noqa
|
739
739
|
nonlocal allow_commas, allow_multiplier_suffix
|
740
|
-
return
|
741
|
-
|
742
|
-
|
740
|
+
return to_float(value, fallback=value,
|
741
|
+
allow_commas=allow_commas,
|
742
|
+
allow_multiplier_suffix=allow_multiplier_suffix)
|
743
743
|
return map_number
|
744
744
|
|
745
745
|
def _map_function_string(self, typeinfo: dict) -> Callable:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "dcicutils"
|
3
|
-
version = "8.13.3.
|
3
|
+
version = "8.13.3.1b26" # TODO: To become 8.14.0
|
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
|
{dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/hack_for_elasticsearch_numpy_usage.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/license_policies/c4-infrastructure.jsonc
RENAMED
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/dcicutils/license_policies/park-lab-common.jsonc
RENAMED
File without changes
|
File without changes
|
{dcicutils-8.13.3.1b25 → dcicutils-8.13.3.1b26}/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
|