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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
b7138cf0
Verified
Commit
b7138cf0
authored
1 year ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
ENH: More versatile find_func for TableExporter
parent
4f79e91a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!89
ENH: JsonSchemaExporter accepts do_not_create parameter.
,
!78
ENH: more useful table export find func
Pipeline
#40615
failed
1 year ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosadvancedtools/table_export.py
+12
-9
12 additions, 9 deletions
src/caosadvancedtools/table_export.py
with
12 additions
and
9 deletions
src/caosadvancedtools/table_export.py
+
12
−
9
View file @
b7138cf0
...
...
@@ -133,6 +133,7 @@ class BaseTableExporter(object):
self
.
_check_sanity_of_export_dict
()
self
.
raise_error_if_missing
=
raise_error_if_missing
self
.
info
=
{}
self
.
all_keys
=
[
key
for
key
in
self
.
export_dict
]
def
collect_information
(
self
):
"""
Use the items of `export_dict` to collect the information for the
...
...
@@ -140,7 +141,8 @@ class BaseTableExporter(object):
"""
for
e
,
d
in
self
.
export_dict
.
items
():
for
e
in
self
.
all_keys
:
d
=
self
.
export_dict
[
e
]
if
QUERY
in
d
:
# TODO: How do we make this more general? There might
# be queries that don't need the record or work with
...
...
@@ -164,11 +166,11 @@ class BaseTableExporter(object):
else
:
self
.
_append_missing
(
e
,
d
)
elif
FIND_FUNCTION
in
d
:
try
:
self
.
info
[
e
]
=
self
.
_call_find_function
(
d
[
FIND_FUNCTION
],
e
);
except
Exception
as
exc
:
val
=
self
.
_call_find_function
(
d
[
FIND_FUNCTION
],
e
);
if
val
is
not
None
:
self
.
info
[
e
]
=
val
else
:
self
.
_append_missing
(
e
,
d
)
logger
.
debug
(
exc
)
# last resort: check if record has e as property:
else
:
try
:
...
...
@@ -202,10 +204,10 @@ class BaseTableExporter(object):
def
_call_find_function
(
self
,
find_function
,
e
):
account_for_self
=
0
if
callable
(
d
[
FIND_FUNCTION
]
):
find_fun
=
d
[
FIND_FUNCTION
]
if
callable
(
find_function
):
find_fun
=
find_function
else
:
find_fun
=
getattr
(
self
,
d
[
FIND_FUNCTION
]
)
find_fun
=
getattr
(
self
,
find_function
)
account_for_self
=
1
sig
=
signature
(
find_fun
)
...
...
@@ -254,7 +256,8 @@ class BaseTableExporter(object):
if
print_header
:
header
=
""
for
e
,
d
in
self
.
export_dict
.
items
():
for
e
in
self
.
all_keys
:
d
=
self
.
export_dict
[
e
]
if
e
in
self
.
info
:
body
+=
str
(
self
.
info
[
e
])
+
delimiter
...
...
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