diff options
author | Bogdano Arendartchuk <bogdano@mandriva.org> | 2007-05-02 17:39:28 +0000 |
---|---|---|
committer | Bogdano Arendartchuk <bogdano@mandriva.org> | 2007-05-02 17:39:28 +0000 |
commit | 0b5ebe2e1b3becfd57c15dc3d585ffcd22b47076 (patch) | |
tree | 7e434f732783b2398fdb44d01a1a61a9df5ca3d9 /RepSys/plugins | |
parent | 91700a68924f4b2e97a18f2c3787bd885c36640c (diff) | |
download | mgarepo-0b5ebe2e1b3becfd57c15dc3d585ffcd22b47076.tar mgarepo-0b5ebe2e1b3becfd57c15dc3d585ffcd22b47076.tar.gz mgarepo-0b5ebe2e1b3becfd57c15dc3d585ffcd22b47076.tar.bz2 mgarepo-0b5ebe2e1b3becfd57c15dc3d585ffcd22b47076.tar.xz mgarepo-0b5ebe2e1b3becfd57c15dc3d585ffcd22b47076.zip |
Merged work on plugins support, including the possibility to wrap
configuration sections.
Diffstat (limited to 'RepSys/plugins')
-rw-r--r-- | RepSys/plugins/__init__.py | 27 | ||||
-rw-r--r-- | RepSys/plugins/sample.py.txt | 14 |
2 files changed, 41 insertions, 0 deletions
diff --git a/RepSys/plugins/__init__.py b/RepSys/plugins/__init__.py new file mode 100644 index 0000000..8bf4521 --- /dev/null +++ b/RepSys/plugins/__init__.py @@ -0,0 +1,27 @@ +import os + +loaded = {} + +def load(): + # based on smart's plugin system + pluginsdir = os.path.dirname(__file__) + for entry in os.listdir(pluginsdir): + if entry != "__init__.py" and entry.endswith(".py"): + name = entry[:-3] + loaded[name] = __import__("RepSys.plugins."+name, + fromlist=[name]) + elif os.path.isdir(entry): + initfile = os.path.join(entry, "__init__.py") + if os.path.isfile(initfile): + loaded[entry] = __import__("RepSys.plugins."+entry, + fromlist=[entry]) + +def list(): + return loaded.keys() + +def help(name): + from RepSys import Error + try: + return loaded[name].__doc__ + except KeyError: + raise Error, "plugin %s not found" % name diff --git a/RepSys/plugins/sample.py.txt b/RepSys/plugins/sample.py.txt new file mode 100644 index 0000000..9877f3c --- /dev/null +++ b/RepSys/plugins/sample.py.txt @@ -0,0 +1,14 @@ +# Sample repsys plugin. In order to test it, rename to sample.py +# vim:ft=python +from RepSys import config + +def users_wrapper(section, option=None, default=None, walk=False): + d = {"foolano": "Foolano De Tal <foolano@bla.com>", + "ceeclano": "Ceeclano Algumacoisa <ceeclano@bli.com>", + "beltrano": "Beltrano Bla <beltrano@mail.ru>"} + if walk: + return d.items() + + return d.get(option, default) + +config.wrap("users", handler=users_wrapper) |