summaryrefslogtreecommitdiff
path: root/formats/__init__.py
blob: 60a35fc2c4afaff0c5c7ae3cd16074eda4113d5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)