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
534db1c8
Commit
534db1c8
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
ENH: allow using the parser as cmd line tool
parent
6de42175
No related branches found
No related tags found
2 merge requests
!54
REL: Release 0.5.0
,
!50
ENH: allow using the parser as cmd line tool
Pipeline
#26553
passed
2 years ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosadvancedtools/models/parser.py
+23
-2
23 additions, 2 deletions
src/caosadvancedtools/models/parser.py
with
23 additions
and
2 deletions
src/caosadvancedtools/models/parser.py
+
23
−
2
View file @
534db1c8
...
...
@@ -36,6 +36,7 @@ Parents can be provided under the 'inherit_from_xxxx' keywords. The value needs
to be a list with the names. Here, NO NEW entities can be defined.
"""
import
json
import
argparse
import
re
import
sys
import
yaml
...
...
@@ -796,5 +797,25 @@ class JsonSchemaParser(Parser):
if
__name__
==
"
__main__
"
:
model
=
parse_model_from_yaml
(
'
data_model.yml
'
)
print
(
model
)
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
,
formatter_class
=
argparse
.
RawTextHelpFormatter
)
parser
.
add_argument
(
"
data_model
"
,
help
=
"
Path name of the data model file (yaml or json) to be used.
"
)
parser
.
add_argument
(
"
--sync
"
,
action
=
"
store_true
"
,
help
=
"
Whether or not to sync the data model with the server.
"
)
parser
.
add_argument
(
"
--noquestion
"
,
action
=
"
store_true
"
,
help
=
"
Whether or not to ask questions during synchronization.
"
)
parser
.
add_argument
(
"
--print
"
,
action
=
"
store_true
"
,
help
=
"
Whether or not to print the data model.
"
)
args
=
parser
.
parse_args
()
if
args
.
data_model
.
endswith
(
"
.json
"
):
model
=
parse_model_from_json_schema
(
args
.
data_model
)
elif
args
.
data_model
.
endswith
(
"
.yml
"
)
or
args
.
data_model
.
endswith
(
"
.yaml
"
):
model
=
parse_model_from_yaml
(
args
.
data_model
)
else
:
RuntimeError
(
"
did not recognize file ending
"
)
if
args
.
print
:
print
(
model
)
if
args
.
sync
:
model
.
sync_data_model
(
noquestion
=
args
.
noquestion
)
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