Skip to content
Snippets Groups Projects
Commit 4255b998 authored by Philipp Stadler's avatar Philipp Stadler
Browse files

feat!: add fields_static

BREAKING CHANGE: new required field
parent 40fd555c
Branches
No related tags found
No related merge requests found
......@@ -46,6 +46,7 @@ class ImportCsv(BaseModel):
file_patterns: list[str]|None
deck_name_pattern: str
fields_mapping: list[str]
fields_static: dict[str, str]
tags: list[str]
class ImportImages(BaseModel):
......@@ -329,7 +330,8 @@ class ApkgExporter:
tmp_deck,
import_csv.tags,
csv_path,
fields_mapping)
fields_mapping,
import_csv.fields_static)
self.move_to_target_decks(col, tmp_deck, deck_name, csv_path)
elif 'import_apkg' in content:
import_apkg : ImportApkg = content['import_apkg']
......@@ -375,7 +377,8 @@ class ApkgExporter:
tmp_deck: int,
tags: list[str],
csv_path: Path,
fields_mapping: list[str]):
fields_mapping: list[str],
fields_static: dict[str, str]):
with open(csv_path) as csv_file:
reader = csv.reader(csv_file, delimiter=';')
for row in reader:
......@@ -386,6 +389,8 @@ class ApkgExporter:
raise Exception(f'CSV row is missing {field} at index {idx}:\n{row}')
if field != 'guid':
note[field] = row[idx]
for field, value in fields_static.items():
note[field] = value
for tag in tags:
note.add_tag(tag)
col.add_note(note, tmp_deck)
......
......@@ -15,6 +15,7 @@ content:
- guid
- Question
- Answer
fields_static: {}
tags: []
resource_paths: []
......@@ -15,6 +15,7 @@ content:
- guid
- Question
- Answer
fields_static: {}
tags: []
resource_paths: []
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment