Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dccXMLJSONConv
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
DigitalDynamicMeasurement
dccXMLJSONConv
Commits
e7a19bef
Commit
e7a19bef
authored
4 months ago
by
Benedikt
Browse files
Options
Downloads
Patches
Plain Diff
fixed return of JSONtoXML for no error case
parent
a0fd8d31
No related branches found
No related tags found
No related merge requests found
Pipeline
#50887
passed
4 months ago
Stage: test
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
src/dccXMLJSONConv/dccConv.py
+5
-0
5 additions, 0 deletions
src/dccXMLJSONConv/dccConv.py
tests/test_dccXMLJSONConv.py
+2
-1
2 additions, 1 deletion
tests/test_dccXMLJSONConv.py
with
8 additions
and
2 deletions
pyproject.toml
+
1
−
1
View file @
e7a19bef
...
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
...
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
[project]
name
=
"dccXMLJSONConv"
name
=
"dccXMLJSONConv"
version
=
"3.0.0.dev
6
"
version
=
"3.0.0.dev
7
"
description
=
"Python module for converting XML DCC (https://www.ptb.de/dcc/) to JSON and vice versa"
description
=
"Python module for converting XML DCC (https://www.ptb.de/dcc/) to JSON and vice versa"
authors
=
[{name
=
"Benedikt Seeger,Thomas Bruns, Vanessa Stehr"
,
email
=
"benedikt.seeger@ptb.de"
}]
authors
=
[{name
=
"Benedikt Seeger,Thomas Bruns, Vanessa Stehr"
,
email
=
"benedikt.seeger@ptb.de"
}]
license
=
{
text
=
"LGPL-2.1-or-later"
}
license
=
{
text
=
"LGPL-2.1-or-later"
}
...
...
This diff is collapsed.
Click to expand it.
src/dccXMLJSONConv/dccConv.py
+
5
−
0
View file @
e7a19bef
...
@@ -133,6 +133,11 @@ class XMLSchemaConverter:
...
@@ -133,6 +133,11 @@ class XMLSchemaConverter:
return
xml_str
,
converted_element
,
conversion_result
[
1
]
return
xml_str
,
converted_element
,
conversion_result
[
1
]
else
:
else
:
raise
Exception
(
f
"
Validation errors:
{
errors
}
"
)
raise
Exception
(
f
"
Validation errors:
{
errors
}
"
)
elif
len
(
errors
)
==
0
:
#evrything is fine
converted_element
=
conversion_result
[
0
]
# we take all since we had a complete XML tree
xml_str
=
xmlschema
.
etree_tostring
(
converted_element
,
namespaces
=
self
.
schema
.
namespaces
)
return
xml_str
,
conversion_result
[
0
],
conversion_result
[
1
]
except
Exception
as
e
:
except
Exception
as
e
:
warnings
.
warn
(
f
"
JSON->XML Validation error:
{
e
}
. Attempting template insertion.
"
)
warnings
.
warn
(
f
"
JSON->XML Validation error:
{
e
}
. Attempting template insertion.
"
)
dictKeys
=
list
(
input_data
.
keys
())
dictKeys
=
list
(
input_data
.
keys
())
...
...
This diff is collapsed.
Click to expand it.
tests/test_dccXMLJSONConv.py
+
2
−
1
View file @
e7a19bef
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU Lesser General Public License
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import
pytest
import
pytest
from
dccXMLJSONConv.dccConv
import
XMLToJson
,
JSONToXML
from
dccXMLJSONConv.dccConv
import
XMLToJson
,
JSONToXML
,
DictToXML
import
os
import
os
import
json
import
json
def
test_XMLToJson
():
def
test_XMLToJson
():
...
@@ -40,5 +40,6 @@ def test_XMLToJsonFunction():
...
@@ -40,5 +40,6 @@ def test_XMLToJsonFunction():
print
(
xml
)
print
(
xml
)
print
(
"
DONE
"
)
print
(
"
DONE
"
)
#TODO add this as testcase with an file in this repo
#TODO add this as testcase with an file in this repo
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