summaryrefslogtreecommitdiff
path: root/formats/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'formats/__init__.py')
-rw-r--r--formats/__init__.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/formats/__init__.py b/formats/__init__.py
new file mode 100644
index 0000000..7ebd9fd
--- /dev/null
+++ b/formats/__init__.py
@@ -0,0 +1,24 @@
+import importlib
+import os
+
+path = os.path.dirname(__file__) or "."
+
+__formats = {}
+
+for entry in sorted(os.listdir(path)):
+ if not entry.endswith(".py") or entry.startswith("_"):
+ continue
+
+ modname = entry.replace(".py", "")
+ mod = __import__(modname, globals(), locals(), ["init"], 1)
+ fmt = mod.init()
+ __formats[fmt.name] = fmt
+
+def supported():
+ return sorted(__formats.keys())
+
+def issupported(name):
+ return name in __formats
+
+def handler(name, logger = None):
+ return __formats.get(name)(logger)