diff --git a/h5pyd/_apps/hsls.py b/h5pyd/_apps/hsls.py index 1b234f5..e566ac9 100644 --- a/h5pyd/_apps/hsls.py +++ b/h5pyd/_apps/hsls.py @@ -228,21 +228,7 @@ def dump(name, obj, visited=None): if cfg["showattrs"] and class_name in ("Dataset", "Table", "Group", "Datatype"): # dump attributes for the object - for attr_name in obj.attrs: - attr = obj.attrs[attr_name] - el = "..." # show this if the attribute is too large - if isinstance(attr, np.ndarray): - rank = len(attr.shape) - else: - rank = 0 # scalar data - if rank > 1: - val = "[" * rank + el + "]" * rank - print(" attr: {0:24} {1}".format(attr_name, val)) - elif rank == 1 and attr.shape[0] > 1: - val = "[{},{}]".format(attr[0], el) - print(" attr: {0:24} {1}".format(attr_name, val)) - else: - print(" attr: {0:24} {1}".format(attr_name, attr)) + dumpAttrs(obj) if visited is not None and obj_id is not None: visited[obj_id] = name @@ -290,6 +276,26 @@ def dumpAcls(obj): dumpACL(acl) +def dumpAttrs(obj): + """ print attributes of the given obj """ + + for attr_name in obj.attrs: + attr = obj.attrs[attr_name] + el = "..." # show this if the attribute is too large + if isinstance(attr, np.ndarray): + rank = len(attr.shape) + else: + rank = 0 # scalar data + if rank > 1: + val = "[" * rank + el + "]" * rank + print(" attr: {0:24} {1}".format(attr_name, val)) + elif rank == 1 and attr.shape[0] > 1: + val = "[{},{}]".format(attr[0], el) + print(" attr: {0:24} {1}".format(attr_name, val)) + else: + print(" attr: {0:24} {1}".format(attr_name, attr)) + + def getFolder(domain): username = cfg["hs_username"] password = cfg["hs_password"] @@ -652,6 +658,10 @@ def main(): dump(h5path, obj) continue + if cfg["showattrs"]: + # dump attributes for root group + dumpAttrs(grp) + if depth < 0: # recursive visited = {} # dict of id to h5path