diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2014-02-09 21:46:02 +0100 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2014-02-09 21:56:18 +0100 |
commit | e4ca64a26cefadb0e159463aac55d3d4410c84c5 (patch) | |
tree | 9733f16be57e3b91466bd73b6dbdedae953f8c4b /plugin_registry.py | |
parent | 68ddfa35b8cbd5a47efcfbf4870bdc7391bd093e (diff) | |
download | clufter-e4ca64a26cefadb0e159463aac55d3d4410c84c5.tar.gz clufter-e4ca64a26cefadb0e159463aac55d3d4410c84c5.tar.xz clufter-e4ca64a26cefadb0e159463aac55d3d4410c84c5.zip |
plugin_registry/format/filter: new way of "private plugin" marking
using MetaPlugin class in the inheritance hierarchy to mark this
fact.
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'plugin_registry.py')
-rw-r--r-- | plugin_registry.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/plugin_registry.py b/plugin_registry.py index b7e43ab..59a0624 100644 --- a/plugin_registry.py +++ b/plugin_registry.py @@ -1,5 +1,5 @@ # -*- coding: UTF-8 -*- -# Copyright 2013 Red Hat, Inc. +# Copyright 2014 Red Hat, Inc. # Part of clufter project # Licensed under GPLv2 (a copy included | http://gnu.org/licenses/gpl-2.0.txt) """Easy (at least for usage) plugin framework""" @@ -17,6 +17,10 @@ from .utils import classproperty, hybridproperty log = logging.getLogger(__name__) +class MetaPlugin(object): + """For use in the internal meta-hierarchy as "do not register me" mark""" + + class PluginRegistry(type): """Core of simple plugin framework @@ -40,8 +44,7 @@ class PluginRegistry(type): # non-API def __new__(registry, name, bases, attrs): - if '__metaclass__' not in attrs and (registry.use_local - or not registry.__module__.startswith(attrs['__module__'])): + if '__metaclass__' not in attrs and MetaPlugin not in bases: # alleged end-use plugin ret = registry.probe(name, bases, attrs) else: @@ -143,8 +146,6 @@ class PluginRegistry(type): # API - use_local = False - @classmethod def setup(registry, reset=False): """Implicit setup upon first registry involvement or external reset""" @@ -186,10 +187,9 @@ class PluginRegistry(type): # filled as a side-effect of meta-magic, see `__new__` ret.update((n, registry._plugins[n]) for n in path_plugins) - if registry.use_local: - # add "built-in" ones - ret.update((n, p) for n, p in registry._plugins.iteritems() - if p.__module__ == registry.__module__) + # add "built-in" ones + ret.update((n, p) for n, p in registry._plugins.iteritems() + if MetaPlugin not in p.__bases__) return ret |