dcicutils 8.7.2.1b5__py3-none-any.whl → 8.7.2.1b7__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
dcicutils/data_readers.py CHANGED
@@ -170,7 +170,15 @@ class Excel:
170
170
  if self._workbook is None:
171
171
  self._workbook = openpyxl.load_workbook(self._file, data_only=True)
172
172
  self.sheet_names = [sheet_name for sheet_name in self._workbook.sheetnames
173
- if self._include_hidden_sheets or (self._workbook[sheet_name].sheet_state != "hidden")]
173
+ if not self.is_hidden_sheet(self._workbook[sheet_name])]
174
+
175
+ def is_hidden_sheet(self, sheet: openpyxl.worksheet.worksheet.Worksheet) -> bool:
176
+ if not self._include_hidden_sheets:
177
+ if sheet.sheet_state == "hidden":
178
+ return True
179
+ if sheet.title.startswith("(") and sheet.title.endswith(")"):
180
+ return True
181
+ return False
174
182
 
175
183
  def __del__(self) -> None:
176
184
  if (workbook := self._workbook) is not None:
@@ -13,9 +13,11 @@ class PortalObject:
13
13
 
14
14
  _PROPERTY_DELETION_SENTINEL = RowReader.CELL_DELETION_SENTINEL
15
15
 
16
- def __init__(self, portal_object: dict, portal: Portal = None, type: Optional[str] = None) -> None:
17
- self._data = portal_object
18
- self._portal = portal
16
+ def __init__(self, data: dict, portal: Portal = None,
17
+ schema: Optional[Union[dict, Schema]] = None, type: Optional[str] = None) -> None:
18
+ self._data = data if isinstance(data, dict) else {}
19
+ self._portal = portal if isinstance(portal, Portal) else None
20
+ self._schema = schema if isinstance(schema, dict) else (schema.data if isinstance(schema, Schema) else None)
19
21
  self._type = type if isinstance(type, str) and type else None
20
22
 
21
23
  @property
@@ -29,7 +31,7 @@ class PortalObject:
29
31
  @property
30
32
  @lru_cache(maxsize=1)
31
33
  def type(self) -> Optional[str]:
32
- return self._type or Portal.get_schema_type(self._data)
34
+ return self._type or Portal.get_schema_type(self._data) or (Schema(self._schema).type if self._schema else None)
33
35
 
34
36
  @property
35
37
  @lru_cache(maxsize=1)
@@ -44,7 +46,7 @@ class PortalObject:
44
46
  @property
45
47
  @lru_cache(maxsize=1)
46
48
  def schema(self) -> Optional[dict]:
47
- return self._portal.get_schema(self.type) if self._portal else None
49
+ return self._schema if self._schema else (self._portal.get_schema(self.type) if self._portal else None)
48
50
 
49
51
  def copy(self) -> PortalObject:
50
52
  return PortalObject(deepcopy(self.data), portal=self.portal, type=self.type)
dcicutils/schema_utils.py CHANGED
@@ -191,7 +191,9 @@ class Schema:
191
191
 
192
192
  def __init__(self, schema: dict, type: Optional[str] = None) -> None:
193
193
  self._data = schema if isinstance(schema, dict) else (schema.data if isinstance(schema, Schema) else {})
194
- self._type = (type if isinstance(type, str) else "") or Schema.type_name(self._data.get("title", ""))
194
+ self._type = ((type if isinstance(type, str) else "") or
195
+ Schema.type_name(self._data.get("title", "")) or
196
+ Schema.type_name(self._data.get("$id", "")))
195
197
 
196
198
  @property
197
199
  def data(self) -> dict:
@@ -139,7 +139,7 @@ def _get_portal_object(portal: Portal, uuid: str,
139
139
  response = portal.get(path, raw=raw, database=database)
140
140
  except Exception as e:
141
141
  if "404" in str(e) and "not found" in str(e).lower():
142
- _print("Portal object not found: {uuid}")
142
+ _print(f"Portal object not found: {uuid}")
143
143
  _exit_without_action()
144
144
  _exit_without_action(f"Exception getting Portal object: {uuid}\n{get_error_message(e)}")
145
145
  if not response:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcicutils
3
- Version: 8.7.2.1b5
3
+ Version: 8.7.2.1b7
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
@@ -10,7 +10,7 @@ dcicutils/common.py,sha256=YE8Mt5-vaZWWz4uaChSVhqGFbFtW5QKtnIyOr4zG4vM,3955
10
10
  dcicutils/contribution_scripts.py,sha256=0k5Gw1TumcD5SAcXVkDd6-yvuMEw-jUp5Kfb7FJH6XQ,2015
11
11
  dcicutils/contribution_utils.py,sha256=vYLS1JUB3sKd24BUxZ29qUBqYeQBLK9cwo8x3k64uPg,25653
12
12
  dcicutils/creds_utils.py,sha256=xrLekD49Ex0GOpL9n7LlJA4gvNcY7txTVFOSYD7LvEU,11113
13
- dcicutils/data_readers.py,sha256=6k2Pgcw62JbKcAYFUkMUUxoqAw2OTQTYyTW0qAYhSNA,6369
13
+ dcicutils/data_readers.py,sha256=A48f7H7upkePpRKfq8bEv1EGM5Jjdes1pyjnreatjh0,6666
14
14
  dcicutils/data_utils.py,sha256=k2OxOlsx7AJ6jF-YNlMyGus_JqSUBe4_n1s65Mv1gQQ,3098
15
15
  dcicutils/datetime_utils.py,sha256=EODDGAngp1yh2ZlDIuI7tB74JBJucw2DljqfPknzK0Y,4666
16
16
  dcicutils/deployment_utils.py,sha256=rcNUFMe_tsrG4CHEtgBe41cZx4Pk4JqISPsjrJRMoEs,68891
@@ -46,7 +46,7 @@ dcicutils/log_utils.py,sha256=7pWMc6vyrorUZQf-V-M3YC6zrPgNhuV_fzm9xqTPph0,10883
46
46
  dcicutils/misc_utils.py,sha256=zVc4urdVGgnWjQ4UQlrGH-URAzr2l_PwZWI3u_GJdFE,102210
47
47
  dcicutils/obfuscation_utils.py,sha256=fo2jOmDRC6xWpYX49u80bVNisqRRoPskFNX3ymFAmjw,5963
48
48
  dcicutils/opensearch_utils.py,sha256=V2exmFYW8Xl2_pGFixF4I2Cc549Opwe4PhFi5twC0M8,1017
49
- dcicutils/portal_object_utils.py,sha256=cez8sLu9dyk5f4TrR2QoOPPjCK0m_Sns1FeW5gbdbVw,12686
49
+ dcicutils/portal_object_utils.py,sha256=6QYVsmIVH-GUgZnws0Ob2d-THtiHERETx_OrLKNn0vA,13015
50
50
  dcicutils/portal_utils.py,sha256=WA0KfBYYLXJmG-TVUPbBiwSfI-3phU07F5Fy79cJEWs,27684
51
51
  dcicutils/project_utils.py,sha256=qPdCaFmWUVBJw4rw342iUytwdQC0P-XKpK4mhyIulMM,31250
52
52
  dcicutils/qa_checkers.py,sha256=cdXjeL0jCDFDLT8VR8Px78aS10hwNISOO5G_Zv2TZ6M,20534
@@ -54,10 +54,10 @@ dcicutils/qa_utils.py,sha256=TT0SiJWiuxYvbsIyhK9VO4uV_suxhB6CpuC4qPacCzQ,160208
54
54
  dcicutils/redis_tools.py,sha256=qkcSNMtvqkpvts-Cm9gWhneK523Q_oHwhNUud1be1qk,7055
55
55
  dcicutils/redis_utils.py,sha256=VJ-7g8pOZqR1ZCtdcjKz3-6as2DMUcs1b1zG6wSprH4,6462
56
56
  dcicutils/s3_utils.py,sha256=LauLFQGvZLfpBJ81tYMikjLd3SJRz2R_FrL1n4xSlyI,28868
57
- dcicutils/schema_utils.py,sha256=Ky1KCrHYbDR4qd1prHBKJvO8Z_1x1xVUup1SsQsVP24,10002
57
+ dcicutils/schema_utils.py,sha256=IhtozG2jQ7bFyn54iPEdmDrHoCf3ryJXeXvPJRBXNn0,10095
58
58
  dcicutils/scripts/publish_to_pypi.py,sha256=LFzNHIQK2EXFr88YcfctyA_WKEBFc1ElnSjWrCXedPM,13889
59
59
  dcicutils/scripts/run_license_checker.py,sha256=z2keYnRDZsHQbTeo1XORAXSXNJK5axVzL5LjiNqZ7jE,4184
60
- dcicutils/scripts/view_portal_object.py,sha256=ouH1lCz3RYl_FyLmCsg2yHHSQ-dQ2QfN7j8IheqjxxE,8244
60
+ dcicutils/scripts/view_portal_object.py,sha256=QZqNtXIDmgyVZEAYRNSpjCRLPwP-TUyFqcBx2La-nUo,8245
61
61
  dcicutils/secrets_utils.py,sha256=8dppXAsiHhJzI6NmOcvJV5ldvKkQZzh3Fl-cb8Wm7MI,19745
62
62
  dcicutils/sheet_utils.py,sha256=VlmzteONW5VF_Q4vo0yA5vesz1ViUah1MZ_yA1rwZ0M,33629
63
63
  dcicutils/snapshot_utils.py,sha256=ymP7PXH6-yEiXAt75w0ldQFciGNqWBClNxC5gfX2FnY,22961
@@ -69,8 +69,8 @@ dcicutils/trace_utils.py,sha256=g8kwV4ebEy5kXW6oOrEAUsurBcCROvwtZqz9fczsGRE,1769
69
69
  dcicutils/validation_utils.py,sha256=cMZIU2cY98FYtzK52z5WUYck7urH6JcqOuz9jkXpqzg,14797
70
70
  dcicutils/variant_utils.py,sha256=2H9azNx3xAj-MySg-uZ2SFqbWs4kZvf61JnK6b-h4Qw,4343
71
71
  dcicutils/zip_utils.py,sha256=rnjNv_k6L9jT2SjDSgVXp4BEJYLtz9XN6Cl2Fy-tqnM,2027
72
- dcicutils-8.7.2.1b5.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
73
- dcicutils-8.7.2.1b5.dist-info/METADATA,sha256=ll_LWXvj31u5gWf3GJ0k9yrsdnmo0eaQ8KTA8haQT1o,3356
74
- dcicutils-8.7.2.1b5.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
75
- dcicutils-8.7.2.1b5.dist-info/entry_points.txt,sha256=51Q4F_2V10L0282W7HFjP4jdzW4K8lnWDARJQVFy_hw,270
76
- dcicutils-8.7.2.1b5.dist-info/RECORD,,
72
+ dcicutils-8.7.2.1b7.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
73
+ dcicutils-8.7.2.1b7.dist-info/METADATA,sha256=QPMBO-ACtYso8RGVZNhcN3t5o2mDUFvlBviU6Q6bIXk,3356
74
+ dcicutils-8.7.2.1b7.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
75
+ dcicutils-8.7.2.1b7.dist-info/entry_points.txt,sha256=51Q4F_2V10L0282W7HFjP4jdzW4K8lnWDARJQVFy_hw,270
76
+ dcicutils-8.7.2.1b7.dist-info/RECORD,,