dcicutils 8.8.4.1b3__py3-none-any.whl → 8.8.4.1b4__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- dcicutils/file_utils.py +10 -4
- dcicutils/http_utils.py +5 -0
- dcicutils/misc_utils.py +16 -0
- dcicutils/zip_utils.py +5 -0
- {dcicutils-8.8.4.1b3.dist-info → dcicutils-8.8.4.1b4.dist-info}/METADATA +4 -4
- {dcicutils-8.8.4.1b3.dist-info → dcicutils-8.8.4.1b4.dist-info}/RECORD +9 -9
- {dcicutils-8.8.4.1b3.dist-info → dcicutils-8.8.4.1b4.dist-info}/LICENSE.txt +0 -0
- {dcicutils-8.8.4.1b3.dist-info → dcicutils-8.8.4.1b4.dist-info}/WHEEL +0 -0
- {dcicutils-8.8.4.1b3.dist-info → dcicutils-8.8.4.1b4.dist-info}/entry_points.txt +0 -0
dcicutils/file_utils.py
CHANGED
@@ -58,15 +58,21 @@ def search_for_file(file: str,
|
|
58
58
|
return None if single else []
|
59
59
|
|
60
60
|
|
61
|
-
def normalize_file_path(path: str,
|
61
|
+
def normalize_file_path(path: str, home_directory: bool = True) -> str:
|
62
|
+
"""
|
63
|
+
Normalizes the given file path name and returns. Does things like remove multiple
|
64
|
+
consecutive slashes and redundant/unnecessary parent paths; if the home_directory
|
65
|
+
argument is True (the default) then also handles the special tilde home directory
|
66
|
+
component/convention and uses this in the result if applicable.
|
67
|
+
"""
|
62
68
|
if not isinstance(path, str) or not path:
|
63
69
|
path = os.getcwd()
|
64
70
|
path = os.path.normpath(path)
|
65
|
-
home_directory = os.path.expanduser("~")
|
66
|
-
if path.startswith("~"):
|
71
|
+
home_directory = os.path.expanduser("~") if home_directory is True else None
|
72
|
+
if home_directory and path.startswith("~"):
|
67
73
|
path = os.path.join(home_directory, path[2 if path.startswith("~/") else 1:])
|
68
74
|
path = os.path.abspath(path)
|
69
|
-
if
|
75
|
+
if home_directory and (os.name == "posix"):
|
70
76
|
if path.startswith(home_directory) and path != home_directory:
|
71
77
|
path = "~/" + pathlib.Path(path).relative_to(home_directory).as_posix()
|
72
78
|
return path
|
dcicutils/http_utils.py
CHANGED
@@ -6,6 +6,11 @@ from dcicutils.tmpfile_utils import temporary_file
|
|
6
6
|
|
7
7
|
@contextmanager
|
8
8
|
def download(url: str, suffix: Optional[str] = None, binary: bool = True) -> Optional[str]:
|
9
|
+
"""
|
10
|
+
Context manager to ownload the given URL into a temporary file and yields the file
|
11
|
+
path to it. An optional file suffix may be specified. Defaults to binary file mode;
|
12
|
+
if this is not desired then pass False as the binary argument.
|
13
|
+
"""
|
9
14
|
with temporary_file(suffix=suffix) as file:
|
10
15
|
response = requests.get(url, stream=True)
|
11
16
|
with open(file, "wb" if binary is True else "w") as f:
|
dcicutils/misc_utils.py
CHANGED
@@ -14,6 +14,7 @@ import json
|
|
14
14
|
import logging
|
15
15
|
import math
|
16
16
|
import os
|
17
|
+
import platform
|
17
18
|
import pytz
|
18
19
|
import re
|
19
20
|
import rfc3986.validators
|
@@ -2682,3 +2683,18 @@ def get_app_specific_directory() -> str:
|
|
2682
2683
|
N.B. This is has been tested on MacOS and Linux but not on Windows.
|
2683
2684
|
"""
|
2684
2685
|
return appdirs.user_data_dir()
|
2686
|
+
|
2687
|
+
|
2688
|
+
def get_os_name() -> str:
|
2689
|
+
if os_name := platform.system():
|
2690
|
+
if os_name == "Darwin": return "osx" # noqa
|
2691
|
+
elif os_name == "Linux": return "linux" # noqa
|
2692
|
+
elif os_name == "Windows": return "windows" # noqa
|
2693
|
+
return ""
|
2694
|
+
|
2695
|
+
|
2696
|
+
def get_cpu_architecture_name() -> str:
|
2697
|
+
if os_architecture_name := platform.machine():
|
2698
|
+
if os_architecture_name == "x86_64": return "amd64" # noqa
|
2699
|
+
return os_architecture_name
|
2700
|
+
return ""
|
dcicutils/zip_utils.py
CHANGED
@@ -51,6 +51,11 @@ def unpack_gz_file_to_temporary_file(file: str, suffix: Optional[str] = None) ->
|
|
51
51
|
|
52
52
|
def extract_file_from_zip(zip_file: str, file_to_extract: str,
|
53
53
|
destination_file: str, raise_exception: bool = True) -> bool:
|
54
|
+
"""
|
55
|
+
Extracts from the given zip file, the given file to extract, writing it to the
|
56
|
+
given destination file. Returns True if all is well, otherwise False, or if the
|
57
|
+
raise_exception argument is True (the default), then raises and exception on error.
|
58
|
+
"""
|
54
59
|
try:
|
55
60
|
if not (destination_directory := os.path.dirname(destination_file)):
|
56
61
|
destination_directory = os.getcwd()
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: dcicutils
|
3
|
-
Version: 8.8.4.
|
3
|
+
Version: 8.8.4.1b4
|
4
4
|
Summary: Utility package for interacting with the 4DN Data Portal and other 4DN resources
|
5
5
|
Home-page: https://github.com/4dn-dcic/utils
|
6
6
|
License: MIT
|
7
7
|
Author: 4DN-DCIC Team
|
8
8
|
Author-email: support@4dnucleome.org
|
9
|
-
Requires-Python: >=3.8,<3.
|
9
|
+
Requires-Python: >=3.8,<3.13
|
10
10
|
Classifier: Development Status :: 4 - Beta
|
11
11
|
Classifier: Intended Audience :: Developers
|
12
12
|
Classifier: Intended Audience :: Science/Research
|
@@ -26,8 +26,8 @@ Requires-Dist: PyJWT (>=2.6.0,<3.0.0)
|
|
26
26
|
Requires-Dist: PyYAML (>=6.0.1,<7.0.0)
|
27
27
|
Requires-Dist: appdirs (>=1.4.4,<2.0.0)
|
28
28
|
Requires-Dist: aws-requests-auth (>=0.4.2,<1)
|
29
|
-
Requires-Dist: boto3 (>=1.
|
30
|
-
Requires-Dist: botocore (>=1.
|
29
|
+
Requires-Dist: boto3 (>=1.34.90,<2.0.0)
|
30
|
+
Requires-Dist: botocore (>=1.34.90,<2.0.0)
|
31
31
|
Requires-Dist: chardet (>=5.2.0,<6.0.0)
|
32
32
|
Requires-Dist: docker (>=4.4.4,<5.0.0)
|
33
33
|
Requires-Dist: elasticsearch (==7.13.4)
|
@@ -28,10 +28,10 @@ dcicutils/es_utils.py,sha256=ZksLh5ei7kRUfiFltk8sd2ZSfh15twbstrMzBr8HNw4,7541
|
|
28
28
|
dcicutils/exceptions.py,sha256=4giQGtpak-omQv7BP6Ckeu91XK5fnDosC8gfdmN_ccA,9931
|
29
29
|
dcicutils/ff_mocks.py,sha256=6RKS4eUiu_Wl8yP_8V0CaV75w4ZdWxdCuL1CVlnMrek,36918
|
30
30
|
dcicutils/ff_utils.py,sha256=oIhuZPnGtfwj6bWyCc1u23JbMB_6InPp01ZqUOljd8M,73123
|
31
|
-
dcicutils/file_utils.py,sha256=
|
31
|
+
dcicutils/file_utils.py,sha256=v8-cdOv6a-8CVbaKvUcEOFjWYVXPtrU8AZgBZ_T9ytU,3653
|
32
32
|
dcicutils/function_cache_decorator.py,sha256=XMyiEGODVr2WoAQ68vcoX_9_Xb9p8pZXdXl7keU8i2g,10026
|
33
33
|
dcicutils/glacier_utils.py,sha256=Q4CVXsZCbP-SoZIsZ5NMcawDfelOLzbQnIlQn-GdlTo,34149
|
34
|
-
dcicutils/http_utils.py,sha256=
|
34
|
+
dcicutils/http_utils.py,sha256=RB0x9hRMZM9Xd1x00c5J0iUzUdYzIQR0XKFiQ94HWO0,807
|
35
35
|
dcicutils/jh_utils.py,sha256=Gpsxb9XEzggF_-Eq3ukjKvTnuyb9V1SCSUXkXsES4Kg,11502
|
36
36
|
dcicutils/kibana/dashboards.json,sha256=wHMB_mpJ8OaYhRRgvpZuihaB2lmSF64ADt_8hkBWgQg,16225
|
37
37
|
dcicutils/kibana/readme.md,sha256=3KmHF9FH6A6xwYsNxRFLw27q0XzHYnjZOlYUnn3VkQQ,2164
|
@@ -44,7 +44,7 @@ dcicutils/license_policies/park-lab-gpl-pipeline.jsonc,sha256=vLZkwm3Js-kjV44nug
|
|
44
44
|
dcicutils/license_policies/park-lab-pipeline.jsonc,sha256=9qlY0ASy3iUMQlr3gorVcXrSfRHnVGbLhkS427UaRy4,283
|
45
45
|
dcicutils/license_utils.py,sha256=d1cq6iwv5Ju-VjdoINi6q7CPNNL7Oz6rcJdLMY38RX0,46978
|
46
46
|
dcicutils/log_utils.py,sha256=7pWMc6vyrorUZQf-V-M3YC6zrPgNhuV_fzm9xqTPph0,10883
|
47
|
-
dcicutils/misc_utils.py,sha256=
|
47
|
+
dcicutils/misc_utils.py,sha256=lbvH1ahdTw1DZUhkP-SN1bqZo3Qg8NNs2cCUNtaVbMs,105516
|
48
48
|
dcicutils/obfuscation_utils.py,sha256=fo2jOmDRC6xWpYX49u80bVNisqRRoPskFNX3ymFAmjw,5963
|
49
49
|
dcicutils/opensearch_utils.py,sha256=V2exmFYW8Xl2_pGFixF4I2Cc549Opwe4PhFi5twC0M8,1017
|
50
50
|
dcicutils/portal_object_utils.py,sha256=gDXRgPsRvqCFwbC8WatsuflAxNiigOnqr0Hi93k3AgE,15422
|
@@ -72,9 +72,9 @@ dcicutils/tmpfile_utils.py,sha256=n95XF8dZVbQRSXBZTGToXXfSs3JUVRyN6c3ZZ0nhAWI,14
|
|
72
72
|
dcicutils/trace_utils.py,sha256=g8kwV4ebEy5kXW6oOrEAUsurBcCROvwtZqz9fczsGRE,1769
|
73
73
|
dcicutils/validation_utils.py,sha256=cMZIU2cY98FYtzK52z5WUYck7urH6JcqOuz9jkXpqzg,14797
|
74
74
|
dcicutils/variant_utils.py,sha256=2H9azNx3xAj-MySg-uZ2SFqbWs4kZvf61JnK6b-h4Qw,4343
|
75
|
-
dcicutils/zip_utils.py,sha256=
|
76
|
-
dcicutils-8.8.4.
|
77
|
-
dcicutils-8.8.4.
|
78
|
-
dcicutils-8.8.4.
|
79
|
-
dcicutils-8.8.4.
|
80
|
-
dcicutils-8.8.4.
|
75
|
+
dcicutils/zip_utils.py,sha256=_Y9EmL3D2dUZhxucxHvrtmmlbZmK4FpSsHEb7rGSJLU,3265
|
76
|
+
dcicutils-8.8.4.1b4.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
|
77
|
+
dcicutils-8.8.4.1b4.dist-info/METADATA,sha256=cddMbLW_q0x49LbY99E3nCOHwzVpoNUk7cYmzrwSPhk,3396
|
78
|
+
dcicutils-8.8.4.1b4.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
79
|
+
dcicutils-8.8.4.1b4.dist-info/entry_points.txt,sha256=51Q4F_2V10L0282W7HFjP4jdzW4K8lnWDARJQVFy_hw,270
|
80
|
+
dcicutils-8.8.4.1b4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|