From 28dcfc6e744b376e51b8bbf4521150eced7d4bc6 Mon Sep 17 00:00:00 2001 From: John Readey Date: Tue, 4 Feb 2025 23:02:09 +0800 Subject: [PATCH] fix flake8 errors --- src/h5json/hdf5db.py | 3 +-- src/h5json/objid.py | 18 +++++++----------- test/unit/objid_test.py | 1 - 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/h5json/hdf5db.py b/src/h5json/hdf5db.py index 676dbef..f23dc3a 100644 --- a/src/h5json/hdf5db.py +++ b/src/h5json/hdf5db.py @@ -13,7 +13,6 @@ import time import h5py import numpy as np -import uuid import os.path as op import os import json @@ -1902,7 +1901,7 @@ def listToRef(self, data): # object reference should be in the form: / for prefix in ("datasets", "groups", "datatypes"): if data.startswith(prefix): - uuid_ref = data[len(prefix) :] + uuid_ref = data[len(prefix):] if len(uuid_ref) == (UUID_LEN + 1) and uuid_ref.startswith("/"): obj = self.getObjectByUuid(prefix, uuid_ref[1:]) if obj: diff --git a/src/h5json/objid.py b/src/h5json/objid.py index 7a98a5b..598790e 100644 --- a/src/h5json/objid.py +++ b/src/h5json/objid.py @@ -24,7 +24,6 @@ UUID_LEN = 36 # length for uuid strings - def _getStorageProtocol(uri): """ returns 's3://', 'file://', or 'https://...net/' prefix if present. If the prefix is in the form: https://myaccount.blob.core.windows.net/mycontainer @@ -55,7 +54,8 @@ def _getBaseName(uri): return uri else: return uri[len(protocol):] - + + def _getPrefixForCollection(collection): """ Return prefix character for given collection type """ collection = collection.lower() @@ -146,16 +146,15 @@ def getRootObjId(id): def createObjId(obj_type=None, root_id=None): - """ create a new objid - + """ create a new objid + if obj_type is None, return just a bare uuid. Otherwise a hsds v2 schema obj_id will be created. In this case obj_type should be one of "groups", "datasets", "datatypes", "chunks". If rootid is - None, a root group obj_id will be created. Otherwise the + None, a root group obj_id will be created. Otherwise the obj_id will be a an id that has root_id as it's root. """ - prefix = None if obj_type is None: # just return a regular uuid @@ -374,7 +373,7 @@ def getCollectionForId(obj_id): def validateUuid(id, obj_class=None): - """ verify the UUID is well-formed + """ verify the UUID is well-formed schema can be: None: expecting ordinary UUID "v1": expecting HSDS v1 format @@ -388,7 +387,7 @@ def validateUuid(id, obj_class=None): if len(id) == UUID_LEN: if obj_class: # expected a prefix - raise ValueError(f"obj_id: {id} not valid for collection: {obj_class}") + raise ValueError(f"obj_id: {id} not valid for collection: {obj_class}") else: # does this have a v1 schema hash tag? # e.g.: "a49be-g-314d61b8-9954-11e6-a733-3c15c2da029e", @@ -480,6 +479,3 @@ def getUuidFromId(id): return id[2:] else: raise ValueError(f"Unexpected obj_id: {id}") - - - \ No newline at end of file diff --git a/test/unit/objid_test.py b/test/unit/objid_test.py index 7c02482..af4ac21 100755 --- a/test/unit/objid_test.py +++ b/test/unit/objid_test.py @@ -10,7 +10,6 @@ # request a copy from help@hdfgroup.org. # ############################################################################## import unittest -import sys from h5json.objid import isRootObjId, isValidUuid, validateUuid from h5json.objid import createObjId, getCollectionForId