Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
vl-dcc
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
vaclab
vl-dcc
Commits
8c332914
Commit
8c332914
authored
4 years ago
by
Rolf Niepraschk
Browse files
Options
Downloads
Patches
Plain Diff
seperate function "pretty_c14n" unsed in program "pretty_c14n.py"
parent
89f76333
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
pretty_c14n.py
+32
-0
32 additions, 0 deletions
pretty_c14n.py
trans.py
+19
-5
19 additions, 5 deletions
trans.py
with
51 additions
and
5 deletions
pretty_c14n.py
0 → 100755
+
32
−
0
View file @
8c332914
#!/usr/bin/env python3
import
sys
from
trans
import
pretty_c14n
def
error_and_exit
(
x
):
print
(
'
ERROR:
'
,
str
(
x
),
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
if
len
(
sys
.
argv
)
<
3
:
error_and_exit
(
'
too few arguments
'
)
if
sys
.
argv
[
1
]
==
sys
.
argv
[
2
]:
error_and_exit
(
'"
infile
"
and
"
outfile
"
must be different
'
)
infile
=
sys
.
argv
[
1
]
outfile
=
sys
.
argv
[
2
]
try
:
with
open
(
infile
,
'
r
'
)
as
f1
:
xml
=
f1
.
read
()
with
open
(
outfile
,
'
w
'
)
as
f2
:
err
,
xml
=
pretty_c14n
(
xml
)
if
err
:
error_and_exit
(
xml
)
f2
.
write
(
xml
)
except
Exception
as
error
:
error_and_exit
(
error
)
print
(
'
\n
File »
'
+
infile
+
'
« was successfully canonized to file »
'
+
\
outfile
+
'
«
\n
'
)
sys
.
exit
(
0
)
This diff is collapsed.
Click to expand it.
trans.py
+
19
−
5
View file @
8c332914
...
...
@@ -9,6 +9,20 @@ config = utils.config
from
pprint
import
pprint
def
pretty_c14n
(
_xml
):
xml
=
_xml
err
=
False
try
:
xml
=
etree
.
canonicalize
(
xml
,
with_comments
=
True
,
strip_text
=
True
)
# Bad side-effect of "prettify_xml": adds XML declaration again
xml
=
prettify_xml
(
xml
,
indent
=
2
,
debug
=
False
)
xml
=
etree
.
canonicalize
(
xml
,
with_comments
=
True
)
except
Exception
as
error
:
xml
=
str
(
error
)
err
=
True
return
err
,
xml
def
cert_to_xml
(
cert_doc
):
dcc_template
=
config
[
'
main_xml_template
'
]
###pprint(config)
...
...
@@ -22,12 +36,12 @@ def cert_to_xml(cert_doc):
cert_doc
[
'
DCC
'
][
'
administrativeData
'
][
'
dccSoftware
'
].
append
(
s
)
try
:
xml
=
render_template
(
dcc_template
,
doc
=
cert_doc
[
'
DCC
'
],
utils
=
utils
)
xml
=
etree
.
canonicalize
(
xml
,
with_comments
=
True
,
strip_text
=
True
)
# Bad side-effect: adds XML declaration again
xml
=
prettify_xml
(
xml
,
indent
=
2
,
debug
=
False
)
xml
=
etree
.
canonicalize
(
xml
,
with_comments
=
True
)
err
,
xml
=
pretty_c14n
(
xml
)
if
err
:
xml
=
'
<error>
'
+
xml
+
'
</error>
\n
'
except
Exception
as
error
:
xml
=
'
<error>
'
+
str
(
error
)
+
'
</error>
\n
'
return
xml
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