mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-03 15:16:12 +02:00
We already know when exporter to use
Don't re-calculate it!
This commit is contained in:
parent
c990c8c9ad
commit
d63ba471ca
1 changed files with 8 additions and 20 deletions
|
@ -90,28 +90,16 @@ def get_exporter(format):
|
||||||
"""
|
"""
|
||||||
Given an export format, returns the (callable) class of the corresponding exporter.
|
Given an export format, returns the (callable) class of the corresponding exporter.
|
||||||
"""
|
"""
|
||||||
# print('get_exporter')
|
try:
|
||||||
# print(__exporter_types)
|
return __exporter_types[format].Exporter
|
||||||
for exporter_name, exporter_class in __exporter_types.items():
|
except (AttributeError, KeyError):
|
||||||
# print(exporter_class, exporter_class.Exporter.names)
|
return None
|
||||||
if (
|
|
||||||
hasattr(exporter_class, "Exporter")
|
|
||||||
and hasattr(exporter_class.Exporter, "names")
|
|
||||||
and format in exporter_class.Exporter.names
|
|
||||||
):
|
|
||||||
return exporter_class.Exporter
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def get_importer(format):
|
def get_importer(format):
|
||||||
"""
|
"""
|
||||||
Given an import format, returns the (callable) class of the corresponding importer.
|
Given an import format, returns the (callable) class of the corresponding importer.
|
||||||
"""
|
"""
|
||||||
for importer_name, importer_class in __importer_types.items():
|
try:
|
||||||
if (
|
return __importer_types[format].Importer
|
||||||
hasattr(importer_class, "Importer")
|
except (AttributeError, KeyError):
|
||||||
and hasattr(importer_class.Importer, "names")
|
return None
|
||||||
and format in importer_class.Importer.names
|
|
||||||
):
|
|
||||||
return importer_class.Importer
|
|
||||||
return None
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue