Bilingual meta classes

This commit is contained in:
Manuel Ebert 2015-04-05 05:50:30 +04:00
parent 6e52b5eb70
commit bad5582632

View file

@ -32,15 +32,10 @@ class PluginMeta(type):
else: else:
return ', '.join(plugin_names[:-1]) + ", or " + plugin_names[-1] return ', '.join(plugin_names[:-1]) + ", or " + plugin_names[-1]
# This looks a bit arcane, but is basically bilingual speak for defining a
class BaseExporter(object): # class with meta class 'PluginMeta' for both Python 2 and 3.
__metaclass__ = PluginMeta BaseExporter = PluginMeta(str('BaseExporter'), (), {'names': []})
names = [] BaseImporter = PluginMeta(str('BaseImporter'), (), {'names': []})
class BaseImporter(object):
__metaclass__ = PluginMeta
names = []
for module in glob.glob(os.path.dirname(__file__) + "/*.py"): for module in glob.glob(os.path.dirname(__file__) + "/*.py"):