Skip to content

Commit

Permalink
fix flake8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jreadey committed Feb 4, 2025
1 parent be22083 commit 28dcfc6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/h5json/hdf5db.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import time
import h5py
import numpy as np
import uuid
import os.path as op
import os
import json
Expand Down Expand Up @@ -1902,7 +1901,7 @@ def listToRef(self, data):
# object reference should be in the form: <collection_name>/<uuid>
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:
Expand Down
18 changes: 7 additions & 11 deletions src/h5json/objid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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",
Expand Down Expand Up @@ -480,6 +479,3 @@ def getUuidFromId(id):
return id[2:]
else:
raise ValueError(f"Unexpected obj_id: {id}")



1 change: 0 additions & 1 deletion test/unit/objid_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 28dcfc6

Please sign in to comment.