Skip to content
Snippets Groups Projects

ENH: more useful table export find func

Merged Timm Fitschen requested to merge f-table-export-find-func into dev
All threads resolved!
1 file
+ 10
5
Compare changes
  • Side-by-side
  • Inline
@@ -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 +
Loading