dcicutils 8.7.0.1b27__py3-none-any.whl → 8.7.0.1b29__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,6 +33,15 @@ class PortalObject:
33
33
  return []
34
34
  return get_identifying_properties(schema)
35
35
 
36
+ @property
37
+ @lru_cache(maxsize=1)
38
+ def uuid(self) -> Optional[str]:
39
+ return PortalObject.get_uuid(self._object)
40
+
41
+ @staticmethod
42
+ def get_uuid(portal_object: dict) -> Optional[str]:
43
+ return portal_object.get("uuid") if isinstance(portal_object, dict) else None
44
+
36
45
  @property
37
46
  @lru_cache(maxsize=1)
38
47
  def identifying_properties(self) -> List[str]:
@@ -89,16 +98,17 @@ class PortalObject:
89
98
  if identifying_paths := self.identifying_paths:
90
99
  return identifying_paths[0]
91
100
 
92
- def lookup(self, include_identifying_path: bool = False) -> Optional[Union[Tuple[dict, str], dict]]:
93
- return self._lookup() if include_identifying_path else self._lookup()[0]
101
+ def lookup(self, include_identifying_path: bool = False,
102
+ raw: bool = False) -> Optional[Union[Tuple[dict, str], dict]]:
103
+ return self._lookup(raw=raw) if include_identifying_path else self._lookup(raw=raw)[0]
94
104
 
95
105
  def lookup_identifying_path(self) -> Optional[str]:
96
106
  return self._lookup()[1]
97
107
 
98
- def _lookup(self) -> Tuple[Optional[dict], Optional[str]]:
108
+ def _lookup(self, raw: bool = False) -> Tuple[Optional[dict], Optional[str]]:
99
109
  try:
100
110
  for identifying_path in self.identifying_paths:
101
- if (value := self._portal.get(identifying_path)) and (value.status_code == 200):
111
+ if (value := self._portal.get(identifying_path, raw=raw)) and (value.status_code == 200):
102
112
  return value.json(), identifying_path
103
113
  except Exception:
104
114
  pass
@@ -1,5 +1,6 @@
1
1
  import copy
2
2
  from functools import lru_cache
3
+ import glob
3
4
  import json
4
5
  from jsonschema import Draft7Validator as SchemaValidator
5
6
  import os
@@ -111,6 +112,14 @@ class StructuredDataSet:
111
112
  result.append({"type": type_name, "file": file_name})
112
113
  return result
113
114
 
115
+ def upload_files_located(self,
116
+ location: Union[str, Optional[List[str]]] = None, recursive: bool = False) -> List[str]:
117
+ upload_files = copy.deepcopy(self.upload_files)
118
+ for upload_file in upload_files:
119
+ if file_path := _search_for_file(upload_file["file"], location=location, recursive=recursive):
120
+ upload_file["path"] = file_path
121
+ return upload_files
122
+
114
123
  def _load_file(self, file: str) -> None:
115
124
  # Returns a dictionary where each property is the name (i.e. the type) of the data,
116
125
  # and the value is array of dictionaries for the data itself. Handle these kinds of files:
@@ -641,3 +650,23 @@ def _split_dotted_string(value: str):
641
650
 
642
651
  def _split_array_string(value: str, unique: bool = False):
643
652
  return split_string(value, ARRAY_VALUE_DELIMITER_CHAR, ARRAY_VALUE_DELIMITER_ESCAPE_CHAR, unique=unique)
653
+
654
+
655
+ def _search_for_file(file: str,
656
+ location: Union[str, Optional[List[str]]] = None, recursive: bool = False) -> Optional[str]:
657
+ if isinstance(file, str) or not file:
658
+ if not location:
659
+ location = "."
660
+ if location:
661
+ if isinstance(location, str):
662
+ location = [location]
663
+ if isinstance(location, list):
664
+ for directory in location:
665
+ if isinstance(directory, str) and os.path.exists(os.path.join(directory, file)):
666
+ return os.path.normpath(os.path.join(directory, file))
667
+ if recursive:
668
+ if not file.startswith("**/"):
669
+ file = "**/" + file
670
+ files = glob.glob(file, recursive=recursive)
671
+ if files:
672
+ return files[0]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcicutils
3
- Version: 8.7.0.1b27
3
+ Version: 8.7.0.1b29
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
@@ -43,7 +43,7 @@ dcicutils/log_utils.py,sha256=7pWMc6vyrorUZQf-V-M3YC6zrPgNhuV_fzm9xqTPph0,10883
43
43
  dcicutils/misc_utils.py,sha256=bMRWWxdbhuF3PKdCZEH-H4U1ecgT3Nag3EL92D9XGoY,100973
44
44
  dcicutils/obfuscation_utils.py,sha256=fo2jOmDRC6xWpYX49u80bVNisqRRoPskFNX3ymFAmjw,5963
45
45
  dcicutils/opensearch_utils.py,sha256=V2exmFYW8Xl2_pGFixF4I2Cc549Opwe4PhFi5twC0M8,1017
46
- dcicutils/portal_object_utils.py,sha256=XtR8bZc2RUp857Mx8bLn9z71E9gD6F66uNorQ5LJUfE,4842
46
+ dcicutils/portal_object_utils.py,sha256=Ys_jfycB364KRGK8r15Qw61gZpqdasU5yPvsdYMwTes,5208
47
47
  dcicutils/portal_utils.py,sha256=jKYgZUYVdkg6VOs1hsiX4bSULLguOIBJFFRpvvZEklU,26704
48
48
  dcicutils/project_utils.py,sha256=qPdCaFmWUVBJw4rw342iUytwdQC0P-XKpK4mhyIulMM,31250
49
49
  dcicutils/qa_checkers.py,sha256=cdXjeL0jCDFDLT8VR8Px78aS10hwNISOO5G_Zv2TZ6M,20534
@@ -58,15 +58,15 @@ dcicutils/secrets_utils.py,sha256=8dppXAsiHhJzI6NmOcvJV5ldvKkQZzh3Fl-cb8Wm7MI,19
58
58
  dcicutils/sheet_utils.py,sha256=VlmzteONW5VF_Q4vo0yA5vesz1ViUah1MZ_yA1rwZ0M,33629
59
59
  dcicutils/snapshot_utils.py,sha256=ymP7PXH6-yEiXAt75w0ldQFciGNqWBClNxC5gfX2FnY,22961
60
60
  dcicutils/ssl_certificate_utils.py,sha256=F0ifz_wnRRN9dfrfsz7aCp4UDLgHEY8LaK7PjnNvrAQ,9707
61
- dcicutils/structured_data.py,sha256=-QcaVVbta9t5hIXVO0yKMDs8jQyrpvuEET0WFFkNFSM,33582
61
+ dcicutils/structured_data.py,sha256=aeFrqFkz_ij_wXouJBTZ71fnWr4OkymCwPcG8P5RG04,34849
62
62
  dcicutils/task_utils.py,sha256=MF8ujmTD6-O2AC2gRGPHyGdUrVKgtr8epT5XU8WtNjk,8082
63
63
  dcicutils/tmpfile_utils.py,sha256=n95XF8dZVbQRSXBZTGToXXfSs3JUVRyN6c3ZZ0nhAWI,1403
64
64
  dcicutils/trace_utils.py,sha256=g8kwV4ebEy5kXW6oOrEAUsurBcCROvwtZqz9fczsGRE,1769
65
65
  dcicutils/validation_utils.py,sha256=cMZIU2cY98FYtzK52z5WUYck7urH6JcqOuz9jkXpqzg,14797
66
66
  dcicutils/variant_utils.py,sha256=2H9azNx3xAj-MySg-uZ2SFqbWs4kZvf61JnK6b-h4Qw,4343
67
67
  dcicutils/zip_utils.py,sha256=rnjNv_k6L9jT2SjDSgVXp4BEJYLtz9XN6Cl2Fy-tqnM,2027
68
- dcicutils-8.7.0.1b27.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
69
- dcicutils-8.7.0.1b27.dist-info/METADATA,sha256=psBpoNxPqT778F7FDlNikbHq0U4DVTJvu1tr1NEz-As,3315
70
- dcicutils-8.7.0.1b27.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
71
- dcicutils-8.7.0.1b27.dist-info/entry_points.txt,sha256=8wbw5csMIgBXhkwfgsgJeuFcoUc0WsucUxmOyml2aoA,209
72
- dcicutils-8.7.0.1b27.dist-info/RECORD,,
68
+ dcicutils-8.7.0.1b29.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
69
+ dcicutils-8.7.0.1b29.dist-info/METADATA,sha256=qAWF7z9WUO4FKeKo158CYIUTXBFZgM9gqksX9bF4RWo,3315
70
+ dcicutils-8.7.0.1b29.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
71
+ dcicutils-8.7.0.1b29.dist-info/entry_points.txt,sha256=8wbw5csMIgBXhkwfgsgJeuFcoUc0WsucUxmOyml2aoA,209
72
+ dcicutils-8.7.0.1b29.dist-info/RECORD,,