obi import: proper check for taxonomy name already existing in DMS when
importing a taxdump
This commit is contained in:
@ -123,20 +123,30 @@ def run(config):
|
||||
v = View
|
||||
else:
|
||||
v = None
|
||||
|
||||
|
||||
if config['obi']['taxdump']:
|
||||
dms_only=True
|
||||
|
||||
output = open_uri(config['obi']['outputURI'],
|
||||
input=False,
|
||||
newviewtype=v)
|
||||
newviewtype=v,
|
||||
dms_only=dms_only)
|
||||
if output is None:
|
||||
raise Exception("Could not create output view")
|
||||
|
||||
# Read taxdump
|
||||
if config['obi']['taxdump']: # The input is a taxdump to import in a DMS
|
||||
taxo = Taxonomy.open_taxdump(output[0], config['obi']['inputURI'])
|
||||
taxo.write(output[1])
|
||||
# Check if taxonomy name isn't already taken
|
||||
dms = output[0]
|
||||
taxo_name = output[1]
|
||||
if Taxonomy.exists(dms, taxo_name.split(b'/')[1]):
|
||||
raise Exception("Taxonomy name already exists in this DMS")
|
||||
taxo = Taxonomy.open_taxdump(dms, config['obi']['inputURI'])
|
||||
taxo.write(taxo_name)
|
||||
taxo.close()
|
||||
output[0].record_command_line(" ".join(sys.argv[1:]))
|
||||
output[0].close()
|
||||
dms.record_command_line(" ".join(sys.argv[1:]))
|
||||
dms.close()
|
||||
logger("info", "Done.")
|
||||
return
|
||||
|
||||
if entry_count >= 0:
|
||||
|
Reference in New Issue
Block a user