Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def find_resource(self, uri, resource_namespaces, object_store, parent_obj, typedURI=False):
persistentIdentity = ''
for ns in resource_namespaces:
# Assume the parent object is TopLevel and form the compliant URI
if typedURI is True:
compliant_uri = os.path.join(ns, parseClassName(self._rdf_type), uri)
else:
compliant_uri = os.path.join(ns, uri)
compliant_uri += os.sep
compliant_uri = URIRef(compliant_uri)
persistent_id_matches = []
if Config.getOption('verbose') is True:
print('Searching for TopLevel: ' + compliant_uri)
for obj in object_store:
if compliant_uri in obj.identity:
persistent_id_matches.append(obj)
# Sort objects with same persistentIdentity by version
# TODO is this right?
persistent_id_matches.sort(key=sort_version)
# If objects matching the persistentIdentity were found, return the most recent version
if len(persistent_id_matches) > 0:
return persistent_id_matches[-1]
# Assume the object is not TopLevel # TODO Not sure what this is for
if SBOL_PERSISTENT_IDENTITY in parent_obj.properties:
persistentIdentity = parent_obj.properties[SBOL_PERSISTENT_IDENTITY][0]
if SBOL_VERSION in parent_obj.properties:
version = parent_obj.properties[SBOL_VERSION][0]
compliant_uri = URIRef(os.path.join(persistentIdentity, uri, version))
def setHomespace(ns):
Config.setHomespace(ns)
def setFileFormat(file_format):
Config.setFileFormat(file_format)
def getFileFormat():
return Config.getFileFormat()