Total Complexity | 8 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | #!/usr/bin/env python |
||
2 | # encoding: utf-8 |
||
3 | |||
4 | from .fancy_exporter import FancyExporter |
||
5 | from .jrnl_importer import JRNLImporter |
||
6 | from .json_exporter import JSONExporter |
||
7 | from .markdown_exporter import MarkdownExporter |
||
8 | from .tag_exporter import TagExporter |
||
9 | from .template_exporter import __all__ as template_exporters |
||
10 | from .text_exporter import TextExporter |
||
11 | from .xml_exporter import XMLExporter |
||
12 | from .yaml_exporter import YAMLExporter |
||
13 | |||
14 | __exporters = [ |
||
15 | JSONExporter, |
||
16 | MarkdownExporter, |
||
17 | TagExporter, |
||
18 | TextExporter, |
||
19 | XMLExporter, |
||
20 | YAMLExporter, |
||
21 | FancyExporter, |
||
22 | ] + template_exporters |
||
23 | __importers = [JRNLImporter] |
||
24 | |||
25 | __exporter_types = {name: plugin for plugin in __exporters for name in plugin.names} |
||
26 | __importer_types = {name: plugin for plugin in __importers for name in plugin.names} |
||
27 | |||
28 | EXPORT_FORMATS = sorted(__exporter_types.keys()) |
||
29 | IMPORT_FORMATS = sorted(__importer_types.keys()) |
||
30 | |||
31 | |||
32 | def get_exporter(format): |
||
33 | for exporter in __exporters: |
||
34 | if hasattr(exporter, "names") and format in exporter.names: |
||
35 | return exporter |
||
36 | return None |
||
37 | |||
38 | |||
39 | def get_importer(format): |
||
40 | for importer in __importers: |
||
41 | if hasattr(importer, "names") and format in importer.names: |
||
42 | return importer |
||
43 | return None |
||
44 |