Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DSI Parser Frontend
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
DSI Parser Frontend
Commits
4cd1a234
Commit
4cd1a234
authored
8 months ago
by
Benedikt
Browse files
Options
Downloads
Patches
Plain Diff
added warnings to the invalide dict
parent
0a2753b6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
XMLUnitExtractor.py
+8
-4
8 additions, 4 deletions
XMLUnitExtractor.py
test_API.py
+5
-2
5 additions, 2 deletions
test_API.py
with
13 additions
and
6 deletions
XMLUnitExtractor.py
+
8
−
4
View file @
4cd1a234
...
@@ -37,15 +37,19 @@ def process_units(unit_dict):
...
@@ -37,15 +37,19 @@ def process_units(unit_dict):
if
unit
.
valid
:
if
unit
.
valid
:
valid_units
[
key
]
=
value
# Assuming you want to return the string value
valid_units
[
key
]
=
value
# Assuming you want to return the string value
else
:
else
:
invalid_units
[
key
]
=
value
invalid_units
[
key
]
=
{
"
unit
"
:
value
,
"
warnings
"
:
unit
.
warnings
}
print
(
f
"
Warning: Invalid unit at
{
key
}
with value:
{
value
}
"
)
print
(
f
"
Warning: Invalid unit at
{
key
}
with value:
{
value
}
"
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"
Error processing unit at
{
key
}
with value:
{
value
}
. Error:
{
e
}
"
)
print
(
f
"
Error processing unit at
{
key
}
with value:
{
value
}
. Error:
{
e
}
"
)
invalid_units
[
key
]
=
value
# Optionally store the raw value or create an error object
invalid_units
[
key
]
=
{
"
unit
"
:
value
,
"
error
"
:
str
(
e
)
}
return
valid_units
,
invalid_units
return
valid_units
,
invalid_units
def
parse_and_process
(
xml_string
):
def
parse_and_process
(
xml_string
):
unit_dict
=
parse_plain_utf8_xml
(
xml_string
)
unit_dict
=
parse_plain_utf8_xml
(
xml_string
)
valid_units
,
invalid_units
=
process_units
(
unit_dict
)
valid_units
,
invalid_units
=
process_units
(
unit_dict
)
...
...
This diff is collapsed.
Click to expand it.
test_API.py
+
5
−
2
View file @
4cd1a234
...
@@ -67,7 +67,10 @@ def test_parse_xml():
...
@@ -67,7 +67,10 @@ def test_parse_xml():
# Check invalid units
# Check invalid units
assert
"
4
"
in
invalid_units
# Line number for <si:unit>not_a_unit</si:unit>
assert
"
4
"
in
invalid_units
# Line number for <si:unit>not_a_unit</si:unit>
assert
invalid_units
[
"
4
"
]
==
"
not_a_unit
"
assert
invalid_units
[
"
4
"
][
'
unit
'
]
==
"
not_a_unit
"
assert
invalid_units
[
"
4
"
][
'
warnings
'
]
==
[
r
'
String should start with \, string given was «not_a_unit»
'
,
r
'
The identifier «not_a_unit» does not match any D-SI units!
'
]
# Check invalid units
# Check invalid units
assert
"
5
"
in
invalid_units
# Line number for <si:unit>not_a_unit</si:unit>
assert
"
5
"
in
invalid_units
# Line number for <si:unit>not_a_unit</si:unit>
assert
invalid_units
[
"
5
"
]
==
"
\seconds
"
assert
invalid_units
[
"
5
"
][
'
unit
'
]
==
"
\seconds
"
assert
invalid_units
[
"
5
"
][
'
warnings
'
]
==
[
r
'
The identifier «seconds» does not match any D-SI units! Did you mean one of these «\second, \arcsecond»?
'
]
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