Author: jvloothuis
Date: Sun May 13 18:33:05 2007
New Revision: 43316

Added:
   kukit/kss.pluginregistry/trunk/kss/
   kukit/kss.pluginregistry/trunk/kss/__init__.py
   kukit/kss.pluginregistry/trunk/kss/pluginregistry/
   kukit/kss.pluginregistry/trunk/kss/pluginregistry/README.txt
   kukit/kss.pluginregistry/trunk/kss/pluginregistry/__init__.py
   kukit/kss.pluginregistry/trunk/kss/pluginregistry/commandset.py
   kukit/kss.pluginregistry/trunk/kss/pluginregistry/tests.py
   kukit/kss.pluginregistry/trunk/setup.py
Log:
New package for registering plugins. It currently allows command sets to be 
registered.


Added: kukit/kss.pluginregistry/trunk/kss/__init__.py
==============================================================================
--- (empty file)
+++ kukit/kss.pluginregistry/trunk/kss/__init__.py      Sun May 13 18:33:05 2007
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)

Added: kukit/kss.pluginregistry/trunk/kss/pluginregistry/README.txt
==============================================================================
--- (empty file)
+++ kukit/kss.pluginregistry/trunk/kss/pluginregistry/README.txt        Sun May 
13 18:33:05 2007
@@ -0,0 +1,58 @@
+===================
+KSS Plugin Registry
+===================
+
+The plugin registry is used so that extra plugins are easy to use. All
+registries can be easily queried and modified using the provided api.
+
+Command Set Registry
+====================
+
+One of the main features of KSS are the command sets. These wrap the transport
+protocol for easier usage. To make sure all access to the commandsets are
+convenient we provide a registry.
+
+Using the registry is pretty simple.
+
+  >>> from kss.pluginregistry import command_set_registry
+
+First we will create a simple factory for our command set. Note that any
+callable object will do. For more information on command sets look at the
+documentation in kss.commands.
+
+  >>> def test_command_set_factory(commands):
+  ...     pass
+
+We can register a command set by passing in the factory and a name.
+
+  >>> command_set_registry.register('test', test_command_set_factory)
+
+The name is used as a unique identifier to lookup the command set factory.
+When you try to register a factory under the same name you will get an error.
+
+  >>> command_set_registry.register('test', test_command_set_factory)
+  Traceback (most recent call last):
+  ...
+  KeyError: ...
+
+This avoids any accidental overrides. If you want to override a command you
+can unregister it first.
+
+  >>> command_set_registry.unregister('test')
+
+Now we can safely register it again.
+
+  >>> command_set_registry.register('test', test_command_set_factory)
+
+To use a command set we will need to get it from the registry. Let us load the
+previously defined `test` set.
+
+  >>> command_set_registry.get('test') is test_command_set_factory
+  True
+
+Trying to load a command set which is not defined will result in a key error.
+
+  >>> command_set_registry.get('does-not-exist')
+  Traceback (most recent call last):
+  ...
+  KeyError: ...

Added: kukit/kss.pluginregistry/trunk/kss/pluginregistry/__init__.py
==============================================================================
--- (empty file)
+++ kukit/kss.pluginregistry/trunk/kss/pluginregistry/__init__.py       Sun May 
13 18:33:05 2007
@@ -0,0 +1,10 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)
+
+from commandset import CommandSetRegistry
+
+command_set_registry = CommandSetRegistry()

Added: kukit/kss.pluginregistry/trunk/kss/pluginregistry/commandset.py
==============================================================================
--- (empty file)
+++ kukit/kss.pluginregistry/trunk/kss/pluginregistry/commandset.py     Sun May 
13 18:33:05 2007
@@ -0,0 +1,14 @@
+class CommandSetRegistry(object):
+    def __init__(self):
+        self._sets = {}
+
+    def register(self, name, factory):
+        if name in self._sets:
+            raise KeyError('Duplicate registration for name: %s' % name)
+        self._sets[name] = factory
+
+    def unregister(self, name):
+        del self._sets[name]
+
+    def get(self, name):
+        return self._sets[name]

Added: kukit/kss.pluginregistry/trunk/kss/pluginregistry/tests.py
==============================================================================
--- (empty file)
+++ kukit/kss.pluginregistry/trunk/kss/pluginregistry/tests.py  Sun May 13 
18:33:05 2007
@@ -0,0 +1,12 @@
+import unittest
+import doctest
+
+def test_suite():
+    suite = unittest.TestSuite((
+        doctest.DocFileSuite(
+            'README.txt',
+            package='kss.pluginregistry',
+            optionflags=doctest.ELLIPSIS,
+        ),
+    ))
+    return suite

Added: kukit/kss.pluginregistry/trunk/setup.py
==============================================================================
--- (empty file)
+++ kukit/kss.pluginregistry/trunk/setup.py     Sun May 13 18:33:05 2007
@@ -0,0 +1,32 @@
+from setuptools import setup, find_packages
+import sys, os
+
+version = '0.1'
+
+setup(name='kss.pluginregistry',
+      version=version,
+      description="KSS (Kinetic Style Sheets) plugin registry",
+      long_description="""\
+""",
+      # Get more strings from 
http://www.python.org/pypi?%3Aaction=list_classifiers
+      classifiers=[
+        "Programming Language :: Python",
+        "Topic :: Software Development :: Libraries :: Python Modules",
+        ],
+      keywords='',
+      author='KSS Project',
+      author_email='[EMAIL PROTECTED]',
+      url='http://kssproject.org',
+      license='GPL',
+      packages=find_packages(exclude=['ez_setup']),
+      namespace_packages=['kss'],
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=[
+          'setuptools',
+      ],
+      entry_points="""
+      # -*- Entry points: -*-
+      """,
+      test_suite='kss.pluginregistry.tests.test_suite',
+      )
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to