Skip to content
Snippets Groups Projects
Verified Commit 89b4ccad authored by Timm Fitschen's avatar Timm Fitschen
Browse files

WIP: enhance find_func of table_export

parent 93be597d
No related branches found
No related tags found
2 merge requests!89ENH: JsonSchemaExporter accepts do_not_create parameter.,!78ENH: more useful table export find func
Pipeline #40473 failed
This commit is part of merge request !78. Comments created here will be created in the context of that merge request.
......@@ -83,7 +83,7 @@ class BaseTableExporter(object):
```
{"entry_to_be_exported: {
"optional": True/False
"find_func": name of member function
"find_func": callable or name of member function
"query": query string
"selector": selector for the query
"error": error explanation
......@@ -97,8 +97,8 @@ class BaseTableExporter(object):
- optional: True or False, if not present, the entry is
assumed to be mandatory.
- find_func: name of the member function that returns the
value for this entry. Must not exist together with
`query`
value for this entry or callable object. Must not exist
together with `query`
- query: Query string for finding the value for this
entry. If this is given, a record must be given to the
constructor of this class. The query is then executed as
......@@ -163,7 +163,10 @@ class BaseTableExporter(object):
else:
self._append_missing(e, d)
elif FIND_FUNCTION in d:
find_fun = getattr(self, d[FIND_FUNCTION])
if callable(d[FIND_FUNCTION]):
find_fun = d[FIND_FUNCTION]
else
find_fun = getattr(self, d[FIND_FUNCTION])
try:
self.info[e] = find_fun()
except Exception as exc:
......@@ -287,7 +290,9 @@ class BaseTableExporter(object):
# check find function if present
if FIND_FUNCTION in d:
if not hasattr(self, d[FIND_FUNCTION]):
if callable(d[FIND_FUNCTION]):
pass
elif not hasattr(self, d[FIND_FUNCTION]):
raise TableExportError(
"Find function " + d[FIND_FUNCTION] +
" was specified for entry " + e +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment