From d63ba471ca27f6592c7af005181c5754bd2e243c Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sun, 16 May 2021 21:09:44 -0600 Subject: [PATCH] We already know when exporter to use Don't re-calculate it! --- jrnl/plugins/collector.py | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/jrnl/plugins/collector.py b/jrnl/plugins/collector.py index f42c25e2..21527ec3 100644 --- a/jrnl/plugins/collector.py +++ b/jrnl/plugins/collector.py @@ -90,28 +90,16 @@ def get_exporter(format): """ Given an export format, returns the (callable) class of the corresponding exporter. """ - # print('get_exporter') - # print(__exporter_types) - for exporter_name, exporter_class in __exporter_types.items(): - # print(exporter_class, exporter_class.Exporter.names) - if ( - hasattr(exporter_class, "Exporter") - and hasattr(exporter_class.Exporter, "names") - and format in exporter_class.Exporter.names - ): - return exporter_class.Exporter - return None - + try: + return __exporter_types[format].Exporter + except (AttributeError, KeyError): + return None def get_importer(format): """ Given an import format, returns the (callable) class of the corresponding importer. """ - for importer_name, importer_class in __importer_types.items(): - if ( - hasattr(importer_class, "Importer") - and hasattr(importer_class.Importer, "names") - and format in importer_class.Importer.names - ): - return importer_class.Importer - return None + try: + return __importer_types[format].Importer + except (AttributeError, KeyError): + return None