Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
APKG Builder
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kartenaale
Build
APKG Builder
Commits
4255b998
Commit
4255b998
authored
9 months ago
by
Philipp Stadler
Browse files
Options
Downloads
Patches
Plain Diff
feat!: add fields_static
BREAKING CHANGE: new required field
parent
40fd555c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
export_apkgs.py
+7
-2
7 additions, 2 deletions
export_apkgs.py
test/fixtures/csv/.apkg-spec.yaml
+1
-0
1 addition, 0 deletions
test/fixtures/csv/.apkg-spec.yaml
test/fixtures/csv_updated_content/.apkg-spec.yaml
+1
-0
1 addition, 0 deletions
test/fixtures/csv_updated_content/.apkg-spec.yaml
with
9 additions
and
2 deletions
export_apkgs.py
+
7
−
2
View file @
4255b998
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
test/fixtures/csv/.apkg-spec.yaml
+
1
−
0
View file @
4255b998
...
...
@@ -15,6 +15,7 @@ content:
-
guid
-
Question
-
Answer
fields_static
:
{}
tags
:
[]
resource_paths
:
[]
This diff is collapsed.
Click to expand it.
test/fixtures/csv_updated_content/.apkg-spec.yaml
+
1
−
0
View file @
4255b998
...
...
@@ -15,6 +15,7 @@ content:
-
guid
-
Question
-
Answer
fields_static
:
{}
tags
:
[]
resource_paths
:
[]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment