Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KADMOS
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LR-FPP-MDO
KADMOS
Commits
6e637742
Commit
6e637742
authored
7 years ago
by
Lukas Müller
Browse files
Options
Downloads
Patches
Plain Diff
Enhanced CMDOWS class with a hack for renaming duplicate uIDs
Former-commit-id: ddc5dd7436d4415b2429fed107b0564021e372ba
parent
00237714
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
kadmos/cmdows/__init__.py
+17
-0
17 additions, 0 deletions
kadmos/cmdows/__init__.py
with
17 additions
and
0 deletions
kadmos/cmdows/__init__.py
+
17
−
0
View file @
6e637742
...
...
@@ -111,3 +111,20 @@ class CMDOWS(object):
if
not
result
:
logger
.
info
(
'
The following uIDs do not exist although they are referred to:
'
+
'
,
'
.
join
(
invalids
))
return
result
def
resolve_uids
(
self
):
"""
Method to rename duplicate UIDs in a CMDOWS file
"""
logger
.
warning
(
'
The resolve_uids method is a hack and should not be used.
'
)
ids
=
[
element
.
attrib
[
'
uID
'
]
for
element
in
self
.
root
.
xpath
(
'
.//*[@uID]
'
)]
result
=
(
len
(
ids
)
==
len
(
set
(
ids
)))
if
not
result
:
duplicates
=
[
k
for
k
,
v
in
Counter
(
ids
).
items
()
if
v
>
1
]
for
duplicate
in
duplicates
:
duplicate_elements
=
self
.
root
.
xpath
(
'
.//*[@uID=
"'
+
duplicate
+
'"
]
'
)
for
duplicate_id
,
duplicate_element
in
enumerate
(
duplicate_elements
):
duplicate_element
.
attrib
[
'
uID
'
]
=
duplicate_element
.
attrib
[
'
uID
'
]
+
'
_
'
+
str
(
duplicate_id
)
def
save
(
self
,
pretty_print
=
False
):
"""
Method to save a manipulated CMDOWS file
"""
ElementTree
(
self
.
root
).
write
(
self
.
file
,
pretty_print
=
pretty_print
,
method
=
'
xml
'
,
xml_declaration
=
True
,
encoding
=
'
UTF-8
'
)
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