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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
49c1e0d4
Verified
Commit
49c1e0d4
authored
1 year ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: Moved get_subschema to xlsx_utils
parent
4a507ac1
No related branches found
No related tags found
2 merge requests
!107
Release v0.11.0
,
!103
xlsx -> json conversion
Pipeline
#50557
passed
1 year ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/table_json_conversion/convert.py
+3
-12
3 additions, 12 deletions
src/caosadvancedtools/table_json_conversion/convert.py
src/caosadvancedtools/table_json_conversion/xlsx_utils.py
+15
-0
15 additions, 0 deletions
src/caosadvancedtools/table_json_conversion/xlsx_utils.py
with
18 additions
and
12 deletions
src/caosadvancedtools/table_json_conversion/convert.py
+
3
−
12
View file @
49c1e0d4
...
...
@@ -224,23 +224,14 @@ This includes:
# Finally: convert to target type
return
self
.
PARSER
[
subschema
.
get
(
"
type
"
,
"
string
"
)](
value
)
def
_get_subschema
(
self
,
path
:
list
[
str
],
schema
:
Union
[
dict
,
list
]
=
None
)
->
dict
:
def
_get_subschema
(
self
,
path
:
list
[
str
],
schema
:
dict
=
None
)
->
dict
:
"""
Return the sub schema at ``path``.
"""
if
schema
is
None
:
schema
=
self
.
_schema
assert
schema
is
not
None
assert
isinstance
(
schema
,
dict
)
if
path
:
if
schema
[
"
type
"
]
==
"
object
"
:
next_schema
=
schema
[
"
properties
"
][
path
[
0
]]
return
self
.
_get_subschema
(
path
=
path
[
1
:],
schema
=
next_schema
)
if
schema
[
"
type
"
]
==
"
array
"
:
items
=
schema
[
"
items
"
]
if
"
enum
"
in
items
:
return
schema
next_schema
=
items
[
"
properties
"
][
path
[
0
]]
return
self
.
_get_subschema
(
path
=
path
[
1
:],
schema
=
next_schema
)
return
schema
return
xlsx_utils
.
get_subschema
(
path
,
schema
)
def
_group_foreign_paths
(
foreign
:
list
[
list
],
common
:
list
[
str
])
->
list
[
SimpleNamespace
]:
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/table_json_conversion/xlsx_utils.py
+
15
−
0
View file @
49c1e0d4
...
...
@@ -260,6 +260,21 @@ def get_row_type_column_index(sheet: Worksheet):
raise
ValueError
(
"
The column which defines row types (COL_TYPE, PATH, ...) is missing
"
)
def
get_subschema
(
path
:
list
[
str
],
schema
:
dict
)
->
dict
:
"""
Return the sub schema at ``path``.
"""
if
path
:
if
schema
[
"
type
"
]
==
"
object
"
:
next_schema
=
schema
[
"
properties
"
][
path
[
0
]]
return
get_subschema
(
path
=
path
[
1
:],
schema
=
next_schema
)
if
schema
[
"
type
"
]
==
"
array
"
:
items
=
schema
[
"
items
"
]
if
"
enum
"
in
items
:
return
schema
next_schema
=
items
[
"
properties
"
][
path
[
0
]]
return
get_subschema
(
path
=
path
[
1
:],
schema
=
next_schema
)
return
schema
def
get_worksheet_for_path
(
path
:
list
[
str
],
defining_path_index
:
dict
[
str
,
list
[
list
[
str
]]])
->
str
:
"""
Find the sheet name which corresponds to the given path.
"""
for
sheetname
,
paths
in
defining_path_index
.
items
():
...
...
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