Importing language csv now handles empty rows

This commit is contained in:
Ruben van de Ven 2019-12-17 16:38:04 +01:00
parent d0cd1a25d7
commit a4292a3387
1 changed files with 14 additions and 1 deletions

View File

@ -234,7 +234,20 @@ class Toolbox:
raise Exception("Not all required fieldnames are given in csv: id, translation, regex_translation")
for row in reader:
node = [node for node in story if node['@id'] == row['id']][0]
if not any(row.values()):
logger.info(f"Skipping empty row")
continue
if not row['id']:
logger.critical(f"Skipping row without ID, but with data: {list(row.values())}")
continue
try:
node = [node for node in story if node['@id'] == row['id']][0]
except Exception as e:
logger.critical(f"Exception finding node id {row}")
logger.exception(e)
raise(e)
if node['@type'] == 'Msg':
if len(row['translation']) < 1 and len(node['text']) > 0:
logger.warning(f"Skipping empty translation for message {node['@id']} \"{node['text']}\"")