dcicutils 8.7.0.1b28__py3-none-any.whl → 8.7.0.1b29__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.
@@ -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.1b28
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
@@ -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.1b28.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
69
- dcicutils-8.7.0.1b28.dist-info/METADATA,sha256=pNdoWloEdcv9nbbh3c4pEFjsd0oT6mR1VVp8fr278Ls,3315
70
- dcicutils-8.7.0.1b28.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
71
- dcicutils-8.7.0.1b28.dist-info/entry_points.txt,sha256=8wbw5csMIgBXhkwfgsgJeuFcoUc0WsucUxmOyml2aoA,209
72
- dcicutils-8.7.0.1b28.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,,