Refactor exporter into Export class

This commit is contained in:
JonnyWong16 2020-09-20 20:34:31 -07:00
parent ca06154805
commit 7eedb14834
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 1285 additions and 1081 deletions

File diff suppressed because it is too large Load diff

View file

@ -1267,15 +1267,11 @@ def flatten_tree(obj, key=''):
# https://stackoverflow.com/a/14692747 # https://stackoverflow.com/a/14692747
def get_by_path(root, items): def get_by_path(root, items):
"""Access a nested object in root by item sequence.""" """Access a nested object in root by item sequence."""
if isinstance(items, str):
items = items.split('.')
return reduce(operator.getitem, items, root) return reduce(operator.getitem, items, root)
def set_by_path(root, items, value): def set_by_path(root, items, value):
"""Set a value in a nested object in root by item sequence.""" """Set a value in a nested object in root by item sequence."""
if isinstance(items, str):
items = items.split('.')
get_by_path(root, items[:-1])[items[-1]] = value get_by_path(root, items[:-1])[items[-1]] = value

View file

@ -6511,11 +6511,11 @@ class WebInterface(object):
} }
``` ```
""" """
result = exporter.export(section_id=section_id, result = exporter.Export(section_id=section_id,
rating_key=rating_key, rating_key=rating_key,
file_format=file_format, file_format=file_format,
metadata_level=metadata_level, metadata_level=metadata_level,
media_info_level=media_info_level) media_info_level=media_info_level).export()
if result: if result:
return {'result': 'success', 'message': 'Metadata export has started.'} return {'result': 'success', 'message': 'Metadata export has started.'}