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
217bbaf2
Verified
Commit
217bbaf2
authored
3 years ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
DOC: Added docstring, fixed a few typos.
parent
0e2a2c52
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!39
Release 0.4.0
,
!36
Revert "Revert "Merge branch 'f-extend-yaml-model' into 'dev'""
Pipeline
#20745
passed
3 years ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/models/parser.py
+28
-7
28 additions, 7 deletions
src/caosadvancedtools/models/parser.py
unittests/test_parser.py
+1
-1
1 addition, 1 deletion
unittests/test_parser.py
with
29 additions
and
8 deletions
src/caosadvancedtools/models/parser.py
+
28
−
7
View file @
217bbaf2
...
...
@@ -25,7 +25,8 @@ import yaml
from
.data_model
import
DataModel
# Keywords which are allowed in data model descriptions.
KEYWORDS
=
[
"
parent
"
,
# TODO: can we remove that, see: #36
KEYWORDS
=
[
"
parent
"
,
# deprecated, use inherit_from_* instead:
# https://gitlab.com/caosdb/caosdb-advanced-user-tools/-/issues/36
"
importance
"
,
"
datatype
"
,
# for example TEXT, INTEGER or REFERENCE
"
unit
"
,
...
...
@@ -37,7 +38,8 @@ KEYWORDS = ["parent", # TODO: can we remove that, see: #36
"
inherit_from_suggested
"
,
"
inherit_from_obligatory
"
,
"
role
"
,
"
value
"
,
]
"
value
"
,
]
# TODO: check whether it's really ignored
# These KEYWORDS are not forbidden as properties, but merely ignored.
...
...
@@ -112,9 +114,9 @@ def parse_model_from_string(string):
class
Parser
(
object
):
def
__init__
(
self
):
"""
Initialize an empty parer object and initialize
the dictionary of entities and the list of treated elements.
"""
Initialize an empty parser object and initialize the dictionary of entities and the list of
treated elements.
"""
self
.
model
=
{}
self
.
treated
=
[]
...
...
@@ -311,7 +313,25 @@ class Parser(object):
raise
def
_add_to_recordtype
(
self
,
ent_name
,
props
,
importance
):
"""
Add properties to a RecordType.
"""
"""
Add properties to a RecordType.
Parameters
----------
ent_name : str
The name of the entity to which the properties shall be added.
props : dict [str -> dict or :doc:`Entity`]
The properties, indexed by their names. Properties may be given as :doc:`Entity` objects
or as dictionaries.
importance
The importance as used in :doc:`Entity.add_property`.
Returns
-------
None
"""
for
n
,
e
in
props
.
items
():
if
n
in
KEYWORDS
:
...
...
@@ -326,9 +346,10 @@ class Parser(object):
if
isinstance
(
e
,
dict
):
if
"
datatype
"
in
e
and
_get_listdatatype
(
e
[
"
datatype
"
])
is
not
None
:
# Reuse the existing datatype for lists.
datatype
=
db
.
LIST
(
_get_listdatatype
(
e
[
"
datatype
"
]))
else
:
#
i
gnore a possible e["datatype"] here if it's not a list
#
I
gnore a possible e["datatype"] here if it's not a list
# since it has been treated in the definition of the
# property (entity) already
datatype
=
None
...
...
This diff is collapsed.
Click to expand it.
unittests/test_parser.py
+
1
−
1
View file @
217bbaf2
...
...
@@ -408,7 +408,7 @@ def test_issue_72():
https://gitlab.indiscale.com/caosdb/src/caosdb-advanced-user-tools/-/issues/72
In some cases, faulty values would be read in for properties without a
secified value.
s
p
ecified value.
"""
model
=
"""
...
...
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