Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
ogs
OpenGeoSys Tools
ogs-utils
Commits
de7774d2
Commit
de7774d2
authored
6 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
wip some ideas and snippets
parent
e925b904
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
xml/createMediaTree.py
+96
-0
96 additions, 0 deletions
xml/createMediaTree.py
xml/xmlstarlet_examples.txt
+45
-0
45 additions, 0 deletions
xml/xmlstarlet_examples.txt
with
141 additions
and
0 deletions
xml/createMediaTree.py
0 → 100644
+
96
−
0
View file @
de7774d2
#!/bin/python
import
sys
import
subprocess
def
addMedia
(
input
,
out
):
xml_path
=
"
//OpenGeoSysProject/time_loop
"
ex
=
"
xmlstarlet ed --insert
"
+
xml_path
+
"
--type elem -n media
"
+
input
process
=
subprocess
.
Popen
(
ex
.
split
(),
stdout
=
subprocess
.
PIPE
)
output_stream
,
errors
=
process
.
communicate
()
output
=
output_stream
.
decode
()
outfile
=
open
(
out
,
'
w
'
)
outfile
.
write
(
output
)
def
addMedium
(
input
,
out
,
medium_id
):
xml_path
=
"
//OpenGeoSysProject/media
"
xml_medium_node
=
"
medium_
"
+
str
(
medium_id
)
ex
=
"
xmlstarlet ed --subnode
"
+
xml_path
+
"
--type elem -n
"
+
xml_medium_node
+
"
"
+
input
process
=
subprocess
.
Popen
(
ex
.
split
(),
stdout
=
subprocess
.
PIPE
)
output_stream
,
errors
=
process
.
communicate
()
output
=
output_stream
.
decode
()
outfile
=
open
(
'
/tmp/
'
+
xml_medium_node
+
'
_t1.prj
'
,
'
w
'
)
outfile
.
write
(
output
)
xml_medium
=
xml_path
+
"
/
"
+
xml_medium_node
ex
=
"
xmlstarlet ed --subnode
"
+
xml_medium
+
"
--type attr -n id -v
"
+
str
(
medium_id
)
+
"
/tmp/
"
+
xml_medium_node
+
"
_t1.prj
"
process
=
subprocess
.
Popen
(
ex
.
split
(),
stdout
=
subprocess
.
PIPE
)
output_stream
,
errors
=
process
.
communicate
()
output
=
output_stream
.
decode
()
outfile
=
open
(
'
/tmp/
'
+
xml_medium_node
+
'
_t2.prj
'
,
'
w
'
)
outfile
.
write
(
output
)
addPhases
(
'
/tmp/
'
+
xml_medium_node
+
'
_t2.prj
'
,
'
/tmp/
'
+
xml_medium_node
+
'
_t2_phases.prj
'
,
xml_medium
)
rename_cmd
=
"
xmlstarlet ed --rename
"
+
xml_medium
+
"
-v medium /tmp/
"
+
xml_medium_node
+
"
_t2_phases.prj
"
process
=
subprocess
.
Popen
(
rename_cmd
.
split
(),
stdout
=
subprocess
.
PIPE
)
output_stream
,
errors
=
process
.
communicate
()
output
=
output_stream
.
decode
()
outfile
=
open
(
out
,
'
w
'
)
outfile
.
write
(
output
)
def
addPhases
(
input
,
out
,
xml_path
):
ex
=
"
xmlstarlet ed --subnode
"
+
xml_path
+
"
--type elem -n phases
"
+
input
process
=
subprocess
.
Popen
(
ex
.
split
(),
stdout
=
subprocess
.
PIPE
)
output_stream
,
errors
=
process
.
communicate
()
output
=
output_stream
.
decode
()
file_name
=
'
/tmp/media_medium_phases.prj
'
outfile
=
open
(
file_name
,
'
w
'
)
outfile
.
write
(
output
)
addPhase
(
file_name
,
out
,
'
AqueousLiquid
'
,
"
//OpenGeoSysProject/media/medium/phases
"
)
def
addPhase
(
input
,
out
,
phase
,
xml_path
):
ex
=
"
xmlstarlet ed --subnode
"
+
xml_path
+
"
--type elem -n phase
"
+
input
process
=
subprocess
.
Popen
(
ex
.
split
(),
stdout
=
subprocess
.
PIPE
)
output_stream
,
errors
=
process
.
communicate
()
output
=
output_stream
.
decode
()
outfile
=
open
(
out
,
'
w
'
)
outfile
.
write
(
output
)
# phase
xml_path
=
"
//OpenGeoSysProject/media/medium/phases/phase
"
ex
=
"
xmlstarlet ed --subnode
"
+
xml_path
+
"
--type elem -n type -v
"
+
phase
+
"
"
+
out
process
=
subprocess
.
Popen
(
ex
.
split
(),
stdout
=
subprocess
.
PIPE
)
output_stream
,
errors
=
process
.
communicate
()
output
=
output_stream
.
decode
()
outfile
=
open
(
out
,
'
w
'
)
outfile
.
write
(
output
)
def
addProperties
(
input
,
out
,
phase
):
xml_path
=
"
//OpenGeoSysProject/media/medium/phases/phase
"
ex
=
"
xmlstarlet ed --subnode
"
+
xml_path
+
"
--type elem -n properties
"
+
input
process
=
subprocess
.
Popen
(
ex
.
split
(),
stdout
=
subprocess
.
PIPE
)
output_stream
,
errors
=
process
.
communicate
()
output
=
output_stream
.
decode
()
outfile
=
open
(
out
,
'
w
'
)
outfile
.
write
(
output
)
def
addMediumProperties
(
input
,
out
):
xml_path
=
"
//OpenGeoSysProject/media/medium
"
ex
=
"
xmlstarlet ed --subnode
"
+
xml_path
+
"
--type elem -n properties
"
+
input
process
=
subprocess
.
Popen
(
ex
.
split
(),
stdout
=
subprocess
.
PIPE
)
output_stream
,
errors
=
process
.
communicate
()
output
=
output_stream
.
decode
()
outfile
=
open
(
out
,
'
w
'
)
outfile
.
write
(
output
)
### create media xml tree
addMedia
(
sys
.
argv
[
1
],
'
/tmp/media.prj
'
)
addMedium
(
'
/tmp/media.prj
'
,
'
/tmp/medium_0.prj
'
,
0
)
addMedium
(
'
/tmp/medium_0.prj
'
,
'
/tmp/medium_1.prj
'
,
1
)
exit
()
addPhase
(
'
/tmp/phases.prj
'
,
'
/tmp/phase.prj
'
,
'
AqueousLiquid
'
)
addProperties
(
'
/tmp/phase.prj
'
,
'
/tmp/aqueous_properties.prj
'
,
'
AqueousLiquid
'
)
addMediumProperties
(
'
/tmp/aqueous_properties.prj
'
,
'
/tmp/medium_properties.prj
'
)
This diff is collapsed.
Click to expand it.
xml/xmlstarlet_examples.txt
0 → 100644
+
45
−
0
View file @
de7774d2
xmlstarlet sel -t -m "//*[parameter]" th_decovalex.prj
xmlstarlet sel -t -c "//*[parameter]" th_decovalex.prj
xmlstarlet sel -t -v "//*[parameter]" th_decovalex.prj
xmlstarlet sel -t -c "//*[parameter]" th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter" th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter/name" th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter/name[]" th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter/name[1]" th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter/name[2]" th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter/name[text()==mu1]" th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter/name[text()=mu1]" th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter/name[text()='mu1']" th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter/name[text()='mu1'].." th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter/name[text()='mu1']/.." th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter/name[text()='mu1']/.." -m "*" th_decovalex.prj
xmlstarlet sel -t -c "//*/parameter/name[text()='mu1']/.." -c "/.." th_decovalex.prj
xmlstarlet sel -t -m "//*/parameter/name[text()='mu1']/.." -c "/.." th_decovalex.prj
xmlstarlet sel -t -m "//*/parameter/name[text()='mu1']/.." -c "./.." th_decovalex.prj
xmlstarlet sel -t -m "//*/parameter/name[text()='mu1']/.." -c "./.." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name[text()='mu1']" -c "./.." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name[text()='mu1']/.." -c "./name" th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name[text()='mu1']/.." -v "./name" th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name[text()='mu1']/.." -v "./type" th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name[text()='mu1']/.." -c "./value" th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name[text()='mu1']/.." -c "./value|values" th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name[text()='mu1']/.." -m "./type[text()='Constant']" -c "." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name[text()='mu1']/.." -m "./type[text()='Constant']" -c "./.." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name/.." -m "./type[text()='Constant']" -c "./.." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name/.." -m "./type[text()!='Constant']" -c "./.." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name/.." -m "./[type!='Constant']" -c "./.." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name/.." -m "./[value>0]" -c "./.." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter/name/.." -m ".[value>0]" -c "./.." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter[value>0]" -c "./.." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter[value>0]" -c "./" th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter[value>0]" -c "." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter[name=='mu1']" -c "." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter[name='mu1']" -c "." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter[name='mu1' and type='Constant']" -c "." th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter[name='mu1' and type='Constant']" -v "./value" th_decovalex.prj | less
xmlstarlet sel -t -m "//*/parameter[name='mu1' and type='Constant']" -v "./value|values" th_decovalex.prj | less
man xmlstarlen
man xmlstarlet
xmlstarlet sel -t -m "//*/parameter[name='mu1' and type='Constant']" -v "./value|values" th_decovalex.prj -C| less
xmlstarlet -C sel -t -m "//*/parameter[name='mu1' and type='Constant']" -v "./value|values" th_decovalex.prj| less
xmlstarlet sel -C -t -m "//*/parameter[name='mu1' and type='Constant']" -v "./value|values" th_decovalex.prj| less
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