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
a9353737
Commit
a9353737
authored
4 months ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
ENH(scanner): allow recursive references to records on the same level in the cfood
parent
0e4e1283
No related branches found
No related tags found
2 merge requests
!217
TST: Make NamedTemporaryFiles Windows-compatible
,
!192
Support recursive definitions in scanner
Pipeline
#59130
failed
4 months 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/converters.py
+43
-8
43 additions, 8 deletions
src/caoscrawler/converters/converters.py
with
43 additions
and
8 deletions
src/caoscrawler/converters/converters.py
+
43
−
8
View file @
a9353737
...
...
@@ -249,11 +249,34 @@ out: tuple
return
(
propvalue
,
propunit
,
collection_mode
)
def
create_records
(
values
:
GeneralStore
,
records
:
RecordStore
,
def_records
:
dict
):
# list of keys to identify, which variables have been set by which paths:
# the items are tuples:
# 0: record name
# 1: property name
def
create_records
(
values
:
GeneralStore
,
records
:
RecordStore
,
def_records
:
dict
)
->
list
[
tuple
[
str
,
str
]]:
"""
Create records in GeneralStore `values` and RecordStore `records` as given
by the definition in `def_records`.
This function will be called during scanning using the cfood definition.
It also should be used by CustomConverters to set records as automatic substitution
and other crawler features are applied automatically.
Arguments:
----------
values: GeneralStore
This GeneralStore will be used to access variables that are needed during variable substitution
in setting the properties of records and files.
Furthermore, the records that are generated in this function will be stored in this GeneralStore
**additionally to** storing them in the RecordStore given as the second argument to this function.
records: RecordStore
The RecordStore where the generated records will be stored.
Returns:
--------
A list of tuples containing the record names (1st element of tuple) and respective property names
as 2nd element of the tuples. This list will be used by the scanner for creating the debug tree.
"""
keys_modified
=
[]
for
name
,
record
in
def_records
.
items
():
...
...
@@ -286,11 +309,22 @@ def create_records(values: GeneralStore, records: RecordStore, def_records: dict
if
(
role
==
"
Record
"
and
"
parents
"
not
in
record
):
c_record
.
add_parent
(
name
)
c_record
=
records
[
name
]
if
isinstance
(
record
,
str
):
raise
RuntimeError
(
"
dict expected, but found str: {}
"
.
format
(
record
))
# We do a second run over the def_records, here. Having finished the first run
# for creating the records (in the variable and records stores) makes sure that
# records, that are defined on this level can already be accessed during variable substitution
# in the properties that will be set in the next block.
for
name
,
record
in
def_records
.
items
():
# See above:
if
record
is
None
:
record
=
{}
c_record
=
records
[
name
]
# Set the properties:
for
key
,
value
in
record
.
items
():
if
key
==
"
parents
"
or
key
==
"
role
"
:
continue
...
...
@@ -320,7 +354,8 @@ def create_records(values: GeneralStore, records: RecordStore, def_records: dict
c_record
.
add_property
(
name
=
key
,
value
=
propvalue
,
unit
=
propunit
)
else
:
if
collection_mode
==
"
list
"
:
if
propunit
and
c_record
.
get_property
(
key
).
unit
and
propunit
!=
c_record
.
get_property
(
key
).
unit
:
if
(
propunit
and
c_record
.
get_property
(
key
).
unit
and
propunit
!=
c_record
.
get_property
(
key
).
unit
):
raise
RuntimeError
(
f
"
Property
'
{
key
}
'
has contradictory units:
"
f
"
{
propunit
}
and
{
c_record
.
get_property
(
key
).
unit
}
"
...
...
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