Importing language csv now handles empty rows
This commit is contained in:
parent
d0cd1a25d7
commit
a4292a3387
1 changed files with 14 additions and 1 deletions
|
@ -234,7 +234,20 @@ class Toolbox:
|
||||||
raise Exception("Not all required fieldnames are given in csv: id, translation, regex_translation")
|
raise Exception("Not all required fieldnames are given in csv: id, translation, regex_translation")
|
||||||
|
|
||||||
for row in reader:
|
for row in reader:
|
||||||
|
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]
|
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 node['@type'] == 'Msg':
|
||||||
if len(row['translation']) < 1 and len(node['text']) > 0:
|
if len(row['translation']) < 1 and len(node['text']) > 0:
|
||||||
logger.warning(f"Skipping empty translation for message {node['@id']} \"{node['text']}\"")
|
logger.warning(f"Skipping empty translation for message {node['@id']} \"{node['text']}\"")
|
||||||
|
|
Loading…
Reference in a new issue