legend-pydataobj 1.14.1__py3-none-any.whl → 1.14.3__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: legend_pydataobj
3
- Version: 1.14.1
3
+ Version: 1.14.3
4
4
  Summary: LEGEND Python Data Objects
5
5
  Author: The LEGEND Collaboration
6
6
  Maintainer: The LEGEND Collaboration
@@ -1,6 +1,6 @@
1
- legend_pydataobj-1.14.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
1
+ legend_pydataobj-1.14.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
2
2
  lgdo/__init__.py,sha256=fkRv79kdtBasw31gPVK9SdLQ2vEEajTV2t3UPDvFg9o,3206
3
- lgdo/_version.py,sha256=dJRV9pQgpOiwiRbOfIEKw29vLhc6CuMVTXwqoHaRZvM,513
3
+ lgdo/_version.py,sha256=NzEEMglzBvMvu9NyIM5lnzzARmP98REW0HB5Kp9fzqg,513
4
4
  lgdo/cli.py,sha256=s_EWTBWW76l7zWb6gaTSTjiT-0RzzcYEmjeFEQCVxfk,4647
5
5
  lgdo/lgdo_utils.py,sha256=6a2YWEwpyEMXlAyTHZMO01aqxy6SxJzPZkGNWKNWuS0,2567
6
6
  lgdo/logging.py,sha256=82wIOj7l7xr3WYyeHdpSXbbjzHJsy-uRyKYUYx2vMfQ,1003
@@ -14,14 +14,14 @@ lgdo/compression/utils.py,sha256=W2RkBrxPpXlat84dnU9Ad7d_tTws0irtGl7O1dNWjnk,114
14
14
  lgdo/compression/varlen.py,sha256=bjyxhHzfpi6PIPy-Uc47W8_LrRbFoJLJ2kVeD5nhyqo,15125
15
15
  lgdo/lh5/__init__.py,sha256=smHTawINIiogHNfYJq3aPvtxleTnBMdPADRCdc1wea8,748
16
16
  lgdo/lh5/concat.py,sha256=BZCgK7TWPKK8fMmha8K83d3bC31FVO1b5LOW7x-Ru1s,6186
17
- lgdo/lh5/core.py,sha256=ER5tAEevD5--xEm_kNHpeHC9hcSaSBFHW3qohyvuvmM,14120
17
+ lgdo/lh5/core.py,sha256=vcYZBJ8QFcfzCl80wmgg9uD2bdYBBG8bytcFj-MZpJ0,14109
18
18
  lgdo/lh5/datatype.py,sha256=ry3twFaosuBoskiTKqtBYRMk9PQAf403593xKaItfog,1827
19
19
  lgdo/lh5/exceptions.py,sha256=Q374YeqajpptVCYfxJYrThiPZSnfpdbGV3qVwoUuEFo,1697
20
20
  lgdo/lh5/iterator.py,sha256=vuN98pa-xHDWXM2GMxvMxFEJGfHatMX6ajqnaP55PuY,20680
21
21
  lgdo/lh5/settings.py,sha256=cmPd6ZvneAF5sFMA1qf-9g_YSSygJcQSRmZDp1_sBEU,1001
22
- lgdo/lh5/store.py,sha256=HJuDjWQ8ztrKDoyWW3cplhtWDnz3J4a-Fe2WF4fzOY4,8676
23
- lgdo/lh5/tools.py,sha256=EZTCj3TMMp4Rnocq1F0QeO1yYHzx4yMR7l_Em4G7sC4,6503
24
- lgdo/lh5/utils.py,sha256=hxPoaG25MOhuu7emrw2xzx3zerl-GzeMWdlfoQmLiYo,6667
22
+ lgdo/lh5/store.py,sha256=nW8hwamd5yfaskuYaMrnWT7I-H7UiwQTXWHRpnfd9l4,8837
23
+ lgdo/lh5/tools.py,sha256=v1nmQl3hV4pES6Gu5jiDS7Ov7k4ZcP8d-3Gc5-snmrU,7038
24
+ lgdo/lh5/utils.py,sha256=PPdOcqBCMqDsHy5vpQIoThoeFRtZHN4DL7IDKzucUxU,6905
25
25
  lgdo/lh5/_serializers/__init__.py,sha256=eZzxMp1SeZWG0PkEXUiCz3XyprQ8EmelHUmJogC8xYE,1263
26
26
  lgdo/lh5/_serializers/read/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  lgdo/lh5/_serializers/read/array.py,sha256=uWfMCihfAmW2DE2ewip2qCK_kvQC_mb2zvOv26uzijc,1000
@@ -33,7 +33,7 @@ lgdo/lh5/_serializers/read/utils.py,sha256=YfSqPO-83A1XvhhuULxQ0Qz2A5ODa3sb7ApNx
33
33
  lgdo/lh5/_serializers/read/vector_of_vectors.py,sha256=765P8mElGArAaEPkHTAUXFQ47t1_3-3BQAete0LckBQ,7207
34
34
  lgdo/lh5/_serializers/write/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  lgdo/lh5/_serializers/write/array.py,sha256=qzRNPQ4mtvc7HYPE3vUcM6bi7lWYnolNStdJVcDfzPU,3174
36
- lgdo/lh5/_serializers/write/composite.py,sha256=Cm9q0xVk27fmmrAeAp1q18E7VP7UwHako01115XdFHg,12964
36
+ lgdo/lh5/_serializers/write/composite.py,sha256=LKRXRP5LVzrHUnFKDcKSn2nxfzdLwBWcFsp4HXT2vKo,12953
37
37
  lgdo/lh5/_serializers/write/scalar.py,sha256=JPt_fcdTKOSFp5hfJdcKIfK4hxhcD8vhOlvDF-7btQ8,763
38
38
  lgdo/lh5/_serializers/write/vector_of_vectors.py,sha256=puGQX9XF5P_5DVbm_Cc6TvPrsDywgBLSYtkqFNltbB4,3493
39
39
  lgdo/types/__init__.py,sha256=DNfOErPiAZg-7Gygkp6ZKAi20Yrm1mfderZHvKo1Y4s,821
@@ -49,8 +49,8 @@ lgdo/types/table.py,sha256=huhgpzdAUx0bRaEaitwnb-Ve7oAu5B6zxPK5EXPUfg0,20233
49
49
  lgdo/types/vectorofvectors.py,sha256=k1LwNnX3TcRAhOujj85kNkfZN0MXZYL9aaMUbr82JlE,26910
50
50
  lgdo/types/vovutils.py,sha256=LW3ZcwECxVYxxcFadAtY3nnK-9-rk8Xbg_m8hY30lo4,10708
51
51
  lgdo/types/waveformtable.py,sha256=9S_NMg894NZTGt2pLuskwH4-zQ5EbLnzWI6FVui6fXE,9827
52
- legend_pydataobj-1.14.1.dist-info/METADATA,sha256=zkJj_GxpFmtHsxmgZOxN2hjUxEZduPKpswZoIS_Kq54,44443
53
- legend_pydataobj-1.14.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
54
- legend_pydataobj-1.14.1.dist-info/entry_points.txt,sha256=0KWfnwbuwhNn0vPUqARukjp04Ca6lzfZBSirouRmk7I,76
55
- legend_pydataobj-1.14.1.dist-info/top_level.txt,sha256=KyR-EUloqiXcQ62IWnzBmtInDtvsHl4q2ZJAZgTcLXE,5
56
- legend_pydataobj-1.14.1.dist-info/RECORD,,
52
+ legend_pydataobj-1.14.3.dist-info/METADATA,sha256=rIkDQcuhcusPO0b0wqT9ycAsY7B8Tc95MSE_bYFly-w,44443
53
+ legend_pydataobj-1.14.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
54
+ legend_pydataobj-1.14.3.dist-info/entry_points.txt,sha256=0KWfnwbuwhNn0vPUqARukjp04Ca6lzfZBSirouRmk7I,76
55
+ legend_pydataobj-1.14.3.dist-info/top_level.txt,sha256=KyR-EUloqiXcQ62IWnzBmtInDtvsHl4q2ZJAZgTcLXE,5
56
+ legend_pydataobj-1.14.3.dist-info/RECORD,,
lgdo/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '1.14.1'
21
- __version_tuple__ = version_tuple = (1, 14, 1)
20
+ __version__ = version = '1.14.3'
21
+ __version_tuple__ = version_tuple = (1, 14, 3)
@@ -59,7 +59,7 @@ def _h5_write_lgdo(
59
59
  try:
60
60
  fh = h5py.File(lh5_file, mode=mode, **file_kwargs)
61
61
  except OSError as oe:
62
- raise LH5EncodeError(str(oe), lh5_file, None) from oe
62
+ raise LH5EncodeError(oe, lh5_file) from oe
63
63
 
64
64
  opened_here = True
65
65
  else:
lgdo/lh5/core.py CHANGED
@@ -118,7 +118,7 @@ def read(
118
118
  try:
119
119
  lh5_file = h5py.File(str(Path(lh5_file)), mode="r", locking=locking)
120
120
  except (OSError, FileExistsError) as oe:
121
- raise LH5DecodeError(str(oe), lh5_file, None) from oe
121
+ raise LH5DecodeError(oe, lh5_file) from oe
122
122
 
123
123
  close_after = True
124
124
  try:
lgdo/lh5/store.py CHANGED
@@ -19,6 +19,7 @@ from numpy.typing import ArrayLike
19
19
  from .. import types
20
20
  from . import _serializers, utils
21
21
  from .core import read
22
+ from .exceptions import LH5DecodeError
22
23
 
23
24
  log = logging.getLogger(__name__)
24
25
 
@@ -125,7 +126,10 @@ class LH5Store:
125
126
  "fs_page_size": page_buffer,
126
127
  }
127
128
  )
128
- h5f = h5py.File(full_path, mode, **file_kwargs)
129
+ try:
130
+ h5f = h5py.File(full_path, mode, **file_kwargs)
131
+ except (OSError, FileExistsError) as oe:
132
+ raise LH5DecodeError(oe, full_path) from oe
129
133
 
130
134
  if self.keep_open:
131
135
  if isinstance(self.keep_open, int) and len(self.files) >= self.keep_open:
lgdo/lh5/tools.py CHANGED
@@ -8,6 +8,7 @@ from pathlib import Path
8
8
  import h5py
9
9
 
10
10
  from . import utils
11
+ from .exceptions import LH5DecodeError
11
12
  from .store import LH5Store
12
13
 
13
14
  log = logging.getLogger(__name__)
@@ -123,7 +124,10 @@ def show(
123
124
 
124
125
  # open file
125
126
  if isinstance(lh5_file, (str, Path)):
126
- lh5_file = h5py.File(utils.expand_path(Path(lh5_file)), "r", locking=False)
127
+ try:
128
+ lh5_file = h5py.File(utils.expand_path(Path(lh5_file)), "r", locking=False)
129
+ except (OSError, FileExistsError) as oe:
130
+ raise LH5DecodeError(oe, lh5_file) from oe
127
131
 
128
132
  # go to group
129
133
  if lh5_group != "/":
@@ -145,17 +149,27 @@ def show(
145
149
 
146
150
  # loop over keys
147
151
  while True:
148
- val = lh5_file[key]
149
- # we want to print the LGDO datatype
150
- dtype = val.attrs.get("datatype", default="no datatype")
151
- if dtype == "no datatype" and isinstance(val, h5py.Group):
152
- dtype = "HDF5 group"
153
-
154
- _attrs = ""
155
- if attrs:
156
- attrs_d = dict(val.attrs)
157
- attrs_d.pop("datatype", "")
158
- _attrs = "── " + str(attrs_d) if attrs_d else ""
152
+ is_link = False
153
+ link_type = lh5_file.get(key, getlink=True)
154
+ if isinstance(link_type, (h5py.SoftLink, h5py.ExternalLink)):
155
+ desc = f"-> {link_type.path}"
156
+ is_link = True
157
+
158
+ else:
159
+ val = lh5_file[key]
160
+
161
+ # we want to print the LGDO datatype
162
+ dtype = val.attrs.get("datatype", default="no datatype")
163
+ if dtype == "no datatype" and isinstance(val, h5py.Group):
164
+ dtype = "HDF5 group"
165
+
166
+ _attrs = ""
167
+ if attrs:
168
+ attrs_d = dict(val.attrs)
169
+ attrs_d.pop("datatype", "")
170
+ _attrs = "── " + str(attrs_d) if attrs_d else ""
171
+
172
+ desc = f"· {dtype} {_attrs}"
159
173
 
160
174
  # is this the last key?
161
175
  killme = False
@@ -167,9 +181,10 @@ def show(
167
181
  else:
168
182
  char = "├──"
169
183
 
170
- print(f"{indent}{char} \033[1m{key}\033[0m · {dtype} {_attrs}") # noqa: T201
184
+ print(f"{indent}{char} \033[1m{key}\033[0m {desc}") # noqa: T201
171
185
 
172
- if detail and isinstance(val, h5py.Dataset):
186
+ if not is_link and detail and isinstance(val, h5py.Dataset):
187
+ val = lh5_file[key]
173
188
  char = "| "
174
189
  if killme:
175
190
  char = " "
@@ -203,9 +218,9 @@ def show(
203
218
  print(toprint) # noqa: T201
204
219
 
205
220
  # if it's a group, call this function recursively
206
- if isinstance(val, h5py.Group):
221
+ if not is_link and isinstance(val, h5py.Group):
207
222
  show(
208
- val,
223
+ lh5_file[key],
209
224
  indent=indent + (" " if killme else "│ "),
210
225
  header=False,
211
226
  attrs=attrs,
lgdo/lh5/utils.py CHANGED
@@ -45,7 +45,10 @@ def read_n_rows(name: str, h5f: str | Path | h5py.File) -> int | None:
45
45
  Return ``None`` if `name` is a :class:`.Scalar` or a :class:`.Struct`.
46
46
  """
47
47
  if not isinstance(h5f, h5py.File):
48
- h5f = h5py.File(h5f, "r", locking=False)
48
+ try:
49
+ h5f = h5py.File(h5f, "r", locking=False)
50
+ except (OSError, FileExistsError) as oe:
51
+ raise LH5DecodeError(oe, h5f, None) from oe
49
52
 
50
53
  try:
51
54
  h5o = h5f[name].id
@@ -61,7 +64,10 @@ def read_size_in_bytes(name: str, h5f: str | Path | h5py.File) -> int | None:
61
64
  recursively through members of a Struct or Table
62
65
  """
63
66
  if not isinstance(h5f, h5py.File):
64
- h5f = h5py.File(h5f, "r", locking=False)
67
+ try:
68
+ h5f = h5py.File(h5f, "r", locking=False)
69
+ except (OSError, FileExistsError) as oe:
70
+ raise LH5DecodeError(oe, h5f) from oe
65
71
 
66
72
  try:
67
73
  h5o = h5f[name].id