From b7d8e1a9a562dbaf75a86b33bba050226939b8f9 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"):