obi import: proper check for taxonomy name already existing in DMS when

importing a taxdump
This commit is contained in:
Celine Mercier
2019-09-17 13:41:49 +02:00
parent ad46056179
commit eb6c59dc1e

View File

@ -123,20 +123,30 @@ def run(config):
v = View v = View
else: else:
v = None v = None
if config['obi']['taxdump']:
dms_only=True
output = open_uri(config['obi']['outputURI'], output = open_uri(config['obi']['outputURI'],
input=False, input=False,
newviewtype=v) newviewtype=v,
dms_only=dms_only)
if output is None: if output is None:
raise Exception("Could not create output view") raise Exception("Could not create output view")
# Read taxdump # Read taxdump
if config['obi']['taxdump']: # The input is a taxdump to import in a DMS if config['obi']['taxdump']: # The input is a taxdump to import in a DMS
taxo = Taxonomy.open_taxdump(output[0], config['obi']['inputURI']) # Check if taxonomy name isn't already taken
taxo.write(output[1]) 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() taxo.close()
output[0].record_command_line(" ".join(sys.argv[1:])) dms.record_command_line(" ".join(sys.argv[1:]))
output[0].close() dms.close()
logger("info", "Done.")
return return
if entry_count >= 0: if entry_count >= 0: