Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
b8ab0b16
Commit
b8ab0b16
authored
1 year ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: refactor function for better code readability
parent
caceab21
No related branches found
Branches containing commit
No related tags found
Tags containing commit
4 merge requests
!100
WIP: Filling XLSX: Seems to be working.
,
!94
ENH: add framework for converting json schema into table templates
,
!93
Filling XLSX: Everything except multiple choice.
,
!92
ENH: xlsx template generator
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosadvancedtools/table_json_conversion/table_generator.py
+12
-22
12 additions, 22 deletions
...aosadvancedtools/table_json_conversion/table_generator.py
with
12 additions
and
22 deletions
src/caosadvancedtools/table_json_conversion/table_generator.py
+
12
−
22
View file @
b8ab0b16
...
...
@@ -113,30 +113,20 @@ class TableTemplateGenerator(ABC):
sheets
,
[
RTname
],
foreign_keys
)
return
sheets
def
_get_foreign_keys
(
self
,
foreign_
keys
:
dict
,
path
:
list
)
->
list
:
def
_get_foreign_keys
(
self
,
keys
:
dict
,
path
:
list
)
->
list
:
"""
returns the foreign keys that are needed at the location to which path points
"""
cpath
=
list
(
path
)
keys
=
foreign_keys
selected_keys
=
None
while
cpath
:
if
keys
is
None
:
raise
ValueError
(
f
"
A foreign key definition is missing for path:
"
f
"
\n
{
path
}
\n
{
foreign_keys
}
"
)
if
cpath
[
0
]
not
in
keys
:
raise
ValueError
(
f
"
A foreign key definition is missing for path:
\n
{
path
}
\n
{
keys
}
"
)
keys
=
keys
[
cpath
[
0
]]
if
isinstance
(
keys
,
list
):
selected_keys
,
keys
=
keys
,
None
else
:
selected_keys
,
keys
=
None
,
keys
cpath
=
cpath
[
1
:]
msg
=
(
f
"
A foreign key definition is missing for path:
\n
{
path
}
\n
{
keys
}
"
)
while
path
:
if
keys
is
None
or
path
[
0
]
not
in
keys
:
raise
ValueError
(
msg
)
keys
=
keys
[
path
[
0
]]
path
=
path
[
1
:]
if
isinstance
(
keys
,
dict
)
and
"
__this__
"
in
keys
:
selected_keys
=
keys
[
"
__this__
"
]
if
selected_keys
is
None
:
raise
ValueError
(
f
"
A foreign key definition is missing for path:
"
f
"
\n
{
path
}
\n
{
foreign_keys
}
"
)
return
selected_keys
return
keys
[
"
__this__
"
]
elif
isinstance
(
keys
,
list
):
return
keys
else
:
raise
ValueError
(
msg
)
def
_treat_schema_element
(
self
,
schema
:
dict
,
sheets
:
dict
=
None
,
path
:
list
=
None
,
foreign_keys
:
dict
=
None
,
level_in_sheet_name
:
int
=
1
,
...
...
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