-
- Downloads
Připsání mailu do chybové hlášky při importu.
Closes #190
parent
61e22e2e
No related branches found
No related tags found
This commit is part of merge request !83. Comments created here will be created in the context of that merge request.
... | ... | @@ -69,6 +69,7 @@ class Import: |
gatekeeper: mo.rights.Gatekeeper | ||
new_user_ids: List[int] | ||
line_number: int = 0 | ||
row_name: Optional[str] = None | ||
def __init__(self): | ||
self.errors = [] | ||
... | ... | @@ -84,6 +85,9 @@ class Import: |
def error(self, msg: str) -> Any: | ||
if self.line_number > 0: | ||
if self.row_name: | ||
msg = f"Řádek {self.line_number} ({self.row_name}): {msg}" | ||
else: | ||
msg = f"Řádek {self.line_number}: {msg}" | ||
self.errors.append(msg) | ||
logger.info('Import: >> %s', msg) | ||
... | ... | @@ -376,6 +380,12 @@ class Import: |
except UnicodeDecodeError: | ||
return False | ||
def get_row_name(self, row: mo.csv.Row) -> Optional[str]: | ||
if row is not None and hasattr(row, 'email'): | ||
|
||
return row.email # type: ignore | ||
# čtení prvku potomka | ||
return None | ||
def generic_import(self, path: str) -> bool: | ||
charset = self.fmt.get_charset() | ||
if charset != 'utf-8' and self.check_utf8(path): | ||
... | ... | @@ -396,12 +406,14 @@ class Import: |
self.line_number = 2 | ||
for row in rows: | ||
self.row_name = self.get_row_name(row) | ||
self.cnt_rows += 1 | ||
self.import_row(row) | ||
if len(self.errors) >= 100: | ||
self.errors.append('Import přerušen pro příliš mnoho chyb') | ||
break | ||
self.line_number += 1 | ||
self.row_name = None | ||
return len(self.errors) == 0 | ||
... | ... |