Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ApplicationCore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
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
ChimeraTK Mirror
ApplicationCore
Commits
75f3da9e
Commit
75f3da9e
authored
5 years ago
by
Martin Christoph Hierholzer
Browse files
Options
Downloads
Patches
Plain Diff
added tool to generate a wiki table from the variable household XML file
parent
66ac9fb8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/variableHousoldToWikiTable.py
+57
-0
57 additions, 0 deletions
tools/variableHousoldToWikiTable.py
with
57 additions
and
0 deletions
tools/variableHousoldToWikiTable.py
0 → 100755
+
57
−
0
View file @
75f3da9e
#!/usr/bin/python3
import
xml.etree.ElementTree
as
ET
def
findCommonPrefix
(
string1
,
string2
):
length
=
min
(
len
(
string1
),
len
(
string2
)
)
for
i
in
range
(
length
):
if
string1
[
i
]
!=
string2
[
i
]
:
return
string1
[
0
:
i
-
1
]
if
len
(
string1
)
<
len
(
string2
)
:
return
string1
else
:
return
string2
def
parseDirectory
(
directory
,
cwd
,
stripDescriptionPrefix
)
:
for
elem
in
directory
.
findall
(
"
{https://github.com/ChimeraTK/ApplicationCore}variable
"
)
:
varname
=
elem
.
attrib
[
"
name
"
]
vartype
=
elem
.
find
(
"
{https://github.com/ChimeraTK/ApplicationCore}value_type
"
).
text
vardirection
=
elem
.
find
(
"
{https://github.com/ChimeraTK/ApplicationCore}direction
"
).
text
varunit
=
elem
.
find
(
"
{https://github.com/ChimeraTK/ApplicationCore}unit
"
).
text
vardescription
=
elem
.
find
(
"
{https://github.com/ChimeraTK/ApplicationCore}description
"
).
text
if
not
vardescription
:
vardescription
=
""
varlength
=
int
(
elem
.
find
(
"
{https://github.com/ChimeraTK/ApplicationCore}numberOfElements
"
).
text
)
if
vardirection
==
"
control_system_to_application
"
:
thetype
=
vartype
+
"
(ro)
"
else
:
thetype
=
vartype
if
varlength
>
1
:
thetype
=
thetype
+
"
(
"
+
str
(
varlength
)
+
"
elements)
"
print
(
"
|
"
+
varname
+
"
|
"
+
vartype
+
"
|
"
+
thetype
+
"
|
"
+
vardescription
[
stripDescriptionPrefix
:]
+
"
|
"
)
for
elem
in
directory
.
findall
(
"
{https://github.com/ChimeraTK/ApplicationCore}directory
"
)
:
dirdescription
=
""
for
subelem
in
elem
.
findall
(
"
{https://github.com/ChimeraTK/ApplicationCore}variable
"
)
:
vardescription
=
subelem
.
find
(
"
{https://github.com/ChimeraTK/ApplicationCore}description
"
).
text
if
not
vardescription
:
vardescription
=
""
if
dirdescription
==
""
:
dirdescription
=
vardescription
else
:
dirdescription
=
findCommonPrefix
(
dirdescription
,
vardescription
)
print
(
"
^
"
+
cwd
+
"
/
"
+
elem
.
attrib
[
"
name
"
]
+
"
-
"
+
dirdescription
[:
-
2
]
+
"
||||
"
)
parseDirectory
(
elem
,
cwd
+
"
/
"
+
elem
.
attrib
[
"
name
"
],
len
(
dirdescription
)
+
1
)
print
(
"
^ PV name ^ Type ^ Unit ^ Description ^
"
)
tree
=
ET
.
parse
(
"
llrfctrl.xml
"
)
root
=
tree
.
getroot
()
parseDirectory
(
root
,
""
,
0
)
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