Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
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 Crawler
Commits
43d4dd66
Commit
43d4dd66
authored
2 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: Fix missing name argumentin JSONFileConverter.create_children
parent
91c1d829
No related branches found
No related tags found
No related merge requests found
Pipeline
#31388
passed
2 years ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caoscrawler/converters.py
+19
-11
19 additions, 11 deletions
src/caoscrawler/converters.py
with
19 additions
and
11 deletions
src/caoscrawler/converters.py
+
19
−
11
View file @
43d4dd66
...
...
@@ -546,7 +546,8 @@ def convert_basic_element(element: Union[list, dict, bool, int, float, str, None
return
NoneElement
(
name
)
else
:
raise
NotImplementedError
(
msg_prefix
+
f
"
The object that has an unexpected type:
{
type
(
element
)
}
\n
"
msg_prefix
+
f
"
The object that has an unexpected type:
{
type
(
element
)
}
\n
"
f
"
The object is:
\n
{
str
(
element
)
}
"
)
...
...
@@ -579,7 +580,8 @@ class DictElementConverter(Converter):
def
create_children
(
self
,
generalStore
:
GeneralStore
,
element
:
StructureElement
):
# TODO: See comment on types and inheritance
if
not
isinstance
(
element
,
DictElement
):
raise
ValueError
(
"
create_children was called with wrong type of StructureElement
"
)
raise
ValueError
(
"
create_children was called with wrong type of StructureElement
"
)
return
self
.
_create_children_from_dict
(
element
.
value
)
...
...
@@ -638,14 +640,16 @@ class JSONFileConverter(Converter):
def
create_children
(
self
,
generalStore
:
GeneralStore
,
element
:
StructureElement
):
# TODO: See comment on types and inheritance
if
not
isinstance
(
element
,
File
):
raise
ValueError
(
"
create_children was called with wrong type of StructureElement
"
)
raise
ValueError
(
"
create_children was called with wrong type of StructureElement
"
)
with
open
(
element
.
path
,
'
r
'
)
as
json_file
:
json_data
=
json
.
load
(
json_file
)
if
"
validate
"
in
self
.
definition
and
self
.
definition
[
"
validate
"
]:
validate_against_json_schema
(
json_data
,
self
.
definition
[
"
validate
"
])
validate_against_json_schema
(
json_data
,
self
.
definition
[
"
validate
"
])
structure_element
=
convert_basic_element
(
json_data
,
"
The JSON File contained content that was parsed to a Python object
"
"
with an unexpected type.
"
)
json_data
,
name
=
element
.
name
+
"
_child_dict
"
,
msg_prefix
=
"
The JSON File contained
"
"
content that was parsed to a Python object
with an unexpected type.
"
)
return
[
structure_element
]
...
...
@@ -665,13 +669,15 @@ class YAMLFileConverter(Converter):
def
create_children
(
self
,
generalStore
:
GeneralStore
,
element
:
StructureElement
):
# TODO: See comment on types and inheritance
if
not
isinstance
(
element
,
File
):
raise
ValueError
(
"
create_children was called with wrong type of StructureElement
"
)
raise
ValueError
(
"
create_children was called with wrong type of StructureElement
"
)
with
open
(
element
.
path
,
'
r
'
)
as
yaml_file
:
yaml_data
=
yaml
.
safe_load
(
yaml_file
)
if
"
validate
"
in
self
.
definition
and
self
.
definition
[
"
validate
"
]:
validate_against_json_schema
(
yaml_data
,
self
.
definition
[
"
validate
"
])
validate_against_json_schema
(
yaml_data
,
self
.
definition
[
"
validate
"
])
structure_element
=
convert_basic_element
(
yaml_data
,
"
The YAML File contained content that was parsed to a Python object
"
yaml_data
,
msg_prefix
=
"
The YAML File contained content that was parsed to a Python object
"
"
with an unexpected type.
"
)
return
[
structure_element
]
...
...
@@ -689,7 +695,8 @@ def match_name_and_value(definition, name, value):
"""
if
"
match_name
"
in
definition
:
if
"
match
"
in
definition
:
raise
RuntimeError
(
f
"
Do not supply both,
'
match_name
'
and
'
match
'
.
"
)
raise
RuntimeError
(
f
"
Do not supply both,
'
match_name
'
and
'
match
'
.
"
)
m1
=
re
.
match
(
definition
[
"
match_name
"
],
name
)
if
m1
is
None
:
...
...
@@ -760,7 +767,8 @@ class _AbstractScalarValueElementConverter(Converter):
and
not
isinstance
(
element
,
BooleanElement
)
and
not
isinstance
(
element
,
IntegerElement
)
and
not
isinstance
(
element
,
FloatElement
)):
raise
ValueError
(
"
create_children was called with wrong type of StructureElement
"
)
raise
ValueError
(
"
create_children was called with wrong type of StructureElement
"
)
return
match_name_and_value
(
self
.
definition
,
element
.
name
,
element
.
value
)
def
_typecheck
(
self
,
element
:
StructureElement
,
allowed_matches
:
dict
):
...
...
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