Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
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
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
d8c93bfa
Verified
Commit
d8c93bfa
authored
1 year ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Pretty printing of errors.
parent
3d9adf32
No related branches found
No related tags found
2 merge requests
!107
Release v0.11.0
,
!103
xlsx -> json conversion
Pipeline
#50736
passed
1 year ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/table_json_conversion/convert.py
+12
-1
12 additions, 1 deletion
src/caosadvancedtools/table_json_conversion/convert.py
unittests/table_json_conversion/test_read_data.py
+14
-0
14 additions, 0 deletions
unittests/table_json_conversion/test_read_data.py
with
26 additions
and
1 deletion
src/caosadvancedtools/table_json_conversion/convert.py
+
12
−
1
View file @
d8c93bfa
...
@@ -97,7 +97,9 @@ validate: bool, optional
...
@@ -97,7 +97,9 @@ validate: bool, optional
If True, validate the result against the schema.
If True, validate the result against the schema.
collect_errors: bool, optional
collect_errors: bool, optional
If True, do not fail at the first error, but try to collect as many errors as possible.
If True, do not fail at the first error, but try to collect as many errors as possible. After an
Exception is raised, the errors can be collected with ``get_errors()`` and printed with
``get_error_str()``.
Returns
Returns
-------
-------
...
@@ -120,6 +122,15 @@ out: dict
...
@@ -120,6 +122,15 @@ out: dict
"""
Return a dict with collected errors.
"""
"""
Return a dict with collected errors.
"""
return
self
.
_errors
return
self
.
_errors
def
get_error_str
(
self
)
->
str
:
"""
Return a beautiful string with the collected errors.
"""
result
=
""
for
loc
,
value
in
self
.
_errors
.
items
():
result
+=
f
"
Sheet:
{
loc
[
0
]
}
\t
Row:
{
loc
[
1
]
+
1
}
\n
"
for
item
in
value
:
result
+=
f
"
\t\t
{
item
[
:
-
1
]
}
:
\t
{
item
[
-
1
]
}
\n
"
return
result
def
_check_columns
(
self
,
fail_fast
:
bool
=
False
):
def
_check_columns
(
self
,
fail_fast
:
bool
=
False
):
"""
Check if the columns correspond to the schema.
"""
"""
Check if the columns correspond to the schema.
"""
def
missing
(
path
):
def
missing
(
path
):
...
...
This diff is collapsed.
Click to expand it.
unittests/table_json_conversion/test_read_data.py
+
14
−
0
View file @
d8c93bfa
...
@@ -142,6 +142,20 @@ def test_faulty_foreign():
...
@@ -142,6 +142,20 @@ def test_faulty_foreign():
[
'
url
'
,
None
]],
[
'
url
'
,
None
]],
}
}
error_str
=
converter
.
get_error_str
()
assert
error_str
==
"""
Sheet: Training.Organisation.Person
\t
Row: 9
\t\t
[
'
name
'
]:
\t
World Training Organization 2
Sheet: Training.Organisation.Person
\t
Row: 10
\t\t
[
'
date
'
]:
\t
2024-03-21T14:12:00.000Z
\t\t
[
'
url
'
]:
\t
www.getlinkahead.com
Sheet: Training.participant
\t
Row: 7
\t\t
[
'
date
'
]:
\t
2024-03-21T14:12:00.000Z
\t\t
[
'
url
'
]:
\t
None
Sheet: Training.participant
\t
Row: 8
\t\t
[
'
date
'
]:
\t
2024-03-21T14:12:00.000Z
\t\t
[
'
url
'
]:
\t
None
"""
def
test_set_in_nested
():
def
test_set_in_nested
():
"""
Test the ``_set_in_nested`` function.
"""
"""
Test the ``_set_in_nested`` function.
"""
...
...
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