Commit e8090a44 authored by Celine Mercier's avatar Celine Mercier

Fixed the ultimate bug with embl (and genbank) parsers: raising any

exception in a python generator makes it unable to resume. So now,
exceptions are not raised but printed, then functions return None and
that's handled at higher level.
parent 832f5828
......@@ -5,6 +5,7 @@ import os
from obitools3.apps.progress cimport ProgressBar # @UnresolvedImport
from obitools3.dms.view.view cimport View
from obitools3.dms.view import RollbackException
from obitools3.dms.view.typed_view.view_NUC_SEQS cimport View_NUC_SEQS
from obitools3.dms.column.column cimport Column
from obitools3.dms.obiseq cimport Nuc_Seq
......@@ -153,6 +154,13 @@ def run(config):
i = 0
for entry in entries :
if entry is None: # error or exception handled at lower level, not raised because Python generators can't resume after any exception is raised
if config['obi']['skiperror']:
raise RollbackException("obi import error, rollbacking view", view)
if NUC_SEQS_view:
......@@ -45,7 +45,7 @@ def emblParser(bytes text):
s =
s = _cleanSeq.sub(b'', s).upper()
acs =
acs = acs.replace(b';', b' ')
acs = acs.split()
......@@ -55,11 +55,11 @@ def emblParser(bytes text):
de =
de = _cleanDe.sub(b' ', de).strip().strip(b'.')
except AttributeError,e:
raise e
except Exception as e:
print("\nCould not import sequence id:", text.split()[1], "(error raised:", e, ")")
# Do not raise any Exception if you need the possibility to resume the generator
# (Python generators can't resume after any exception is raised)
return None
tags = {}
extractTaxon(ft, tags)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment