Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce NotFoundError for backward and forward compatibility #47

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions sequences_to_features/sequences_to_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
from sbol import *
from flashtext import KeywordProcessor

# Set up the not found error for catching
try:
# SBOLError is in the native python module
NotFoundError = SBOLError
except NameError:
# The swig wrapper raises RuntimeError on not found
NotFoundError = RuntimeError


def load_sbol(sbol_file):
logging.info('Loading %s', sbol_file)

Expand Down Expand Up @@ -237,9 +246,9 @@ def copy_component_definition(cls, comp_definition, source_doc, sink_doc, import
else:
try:
sink_doc.getComponentDefinition(comp_definition.identity)

return None
except RuntimeError:
except NotFoundError:
definition_copy = comp_definition.copy(sink_doc)

definition_copy.sequences = list(comp_definition.sequences)
Expand Down Expand Up @@ -280,7 +289,7 @@ def copy_component_definition(cls, comp_definition, source_doc, sink_doc, import
for seq_URI in comp_definition.sequences:
try:
sink_doc.getSequence(seq_URI)
except RuntimeError:
except NotFoundError:
seq = source_doc.getSequence(seq_URI)

seq.copy(sink_doc)
Expand Down