Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edds_process
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
Service Desk
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
RPW
edds_process
Commits
906c6289
Commit
906c6289
authored
5 years ago
by
Bonnin Xavier
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop'
parents
e9c7c4ab
b5239ad1
Branches
Branches containing commit
Tags
0.6.2
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+4
-0
4 additions, 0 deletions
CHANGELOG.md
edds_process/response/make.py
+49
-1
49 additions, 1 deletion
edds_process/response/make.py
edds_process/response/parse.py
+1
-0
1 addition, 0 deletions
edds_process/response/parse.py
with
54 additions
and
1 deletion
CHANGELOG.md
+
4
−
0
View file @
906c6289
CHANGELOG
====================
0.
6.2
-----
*
Add make_param_xml() method
0.
6.1
-----
*
Rename etree_to_dict() to xml_to_dict() and use dicttoxml module instead
...
...
This diff is collapsed.
Click to expand it.
edds_process/response/make.py
+
49
−
1
View file @
906c6289
...
...
@@ -7,7 +7,7 @@ import xmltodict
from
edds_process.globals
import
LOGGER
__all__
=
[
'
make_tmraw_xml
'
,
'
make_tcreport_xml
'
]
__all__
=
[
'
make_tmraw_xml
'
,
'
make_tcreport_xml
'
,
'
make_param_xml
'
]
def
make_tmraw_xml
(
packets
,
output_file
,
overwrite
=
False
,
...
...
@@ -102,3 +102,51 @@ def make_tcreport_xml(tcreport_list, output_file,
return
os
.
path
.
isfile
(
output_file
)
def
make_param_xml
(
param_list
,
output_file
,
overwrite
=
False
,
logger
=
LOGGER
):
"""
Create a MOC DDS Param XML file with input ParamSampleListElement elements.
:param param_list: List of ParamSampleListElement XML Elements
to save into the DDS XML file (provided as dictionary)
:param output_file: Path and name of the output DDS XML file
:param overwrite: If True then replace existing output file, else abort output file production
:return: True if output file has been successfully generated, False otherwise.
"""
if
os
.
path
.
isfile
(
output_file
)
and
not
overwrite
:
logger
.
warning
(
f
'
{
output_file
}
already exists, skip output file production!
'
)
return
output_file
elif
os
.
path
.
isfile
(
output_file
)
and
overwrite
:
logger
.
debug
(
f
'
{
output_file
}
already exists and will be replaced!
'
)
else
:
logger
.
debug
(
f
'
Writing
{
output_file
}
with
{
len
(
param_list
)
}
element(s)
'
)
# Prepare input dictionary to be serialized by dicttoxml
param_data
=
{
'
Response
'
:
{
'
ParamResponse
'
:
{
'
ParamSampleList
'
:
{
'
ParamSampleListElement
'
:
param_list
}}}}
# Build XML snippet from input param element list
param_xml
=
xmltodict
.
unparse
(
param_data
)
# Remove the first line (<?xml version="1.0" encoding="utf-8"?>)
# automatically added by xmltodict.unparse() method
param_xml
=
param_xml
.
split
(
'
\n
'
)[
1
]
# Add header and root parts
param_xml
=
'
<?xml version=
"
1.0
"
encoding=
"
UTF-8
"
standalone=
"
yes
"
?>
'
\
f
'
<ns2:ResponsePart xmlns:ns2=
"
http://edds.egos.esa/model
"
>
'
\
f
'
{
param_xml
}
</ns2:ResponsePart>
'
# Create output Param XML file
logger
.
debug
(
f
'
Saving output EDDS Param XML file
{
output_file
}
'
)
with
open
(
output_file
,
"
w
"
)
as
fw
:
fw
.
write
(
param_xml
)
return
os
.
path
.
isfile
(
output_file
)
This diff is collapsed.
Click to expand it.
edds_process/response/parse.py
+
1
−
0
View file @
906c6289
...
...
@@ -221,4 +221,5 @@ def count_packets(xml_file, file_type=None,
return
[]
tree
=
ET
.
parse
(
xml_file
)
return
len
(
tree
.
findall
(
f
'
.//
{
element_name
}
'
))
\ No newline at end of file
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