From bad5582632f992afa6a2b678f5d45f83e2b3a21c Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Sun, 5 Apr 2015 05:50:30 +0400 Subject: [PATCH] Bilingual meta classes --- jrnl/plugins/__init__.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/jrnl/plugins/__init__.py b/jrnl/plugins/__init__.py index 301ad76d..6f802342 100644 --- a/jrnl/plugins/__init__.py +++ b/jrnl/plugins/__init__.py @@ -32,15 +32,10 @@ class PluginMeta(type): else: return ', '.join(plugin_names[:-1]) + ", or " + plugin_names[-1] - -class BaseExporter(object): - __metaclass__ = PluginMeta - names = [] - - -class BaseImporter(object): - __metaclass__ = PluginMeta - names = [] +# This looks a bit arcane, but is basically bilingual speak for defining a +# class with meta class 'PluginMeta' for both Python 2 and 3. +BaseExporter = PluginMeta(str('BaseExporter'), (), {'names': []}) +BaseImporter = PluginMeta(str('BaseImporter'), (), {'names': []}) for module in glob.glob(os.path.dirname(__file__) + "/*.py"):