From d3571ab23839adb57216378539425fb3c42c0bc2 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 30 Jun 2008 23:10:53 +0200 Subject: Define __all__ in nbblib.* --- src/nbblib/bs.py | 4 ++++ src/nbblib/commands.py | 10 ++++++++++ src/nbblib/main.py | 3 +++ src/nbblib/plugins.py | 14 ++++++++++++++ src/nbblib/test-plugins.py | 4 ++-- src/nbblib/vcs.py | 4 ++++ 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/nbblib/bs.py b/src/nbblib/bs.py index b5fd865..5b7b19b 100644 --- a/src/nbblib/bs.py +++ b/src/nbblib/bs.py @@ -10,6 +10,9 @@ from nbblib import progutils from nbblib import plugins +__all__ = [] + + class NotABSSourceTree(plugins.PluginNoMatch): def __init__(self, vcs_tree): super(NotABSSourceTree, self).__init__() @@ -29,6 +32,7 @@ class AmbigousBSDetection(plugins.AmbigousPluginDetection): '\n '.join(alist)) +__all__.append('BSSourceTree') class BSSourceTree(plugins.GenericDetectPlugin): __metaclass__ = plugins.GenericPluginMeta no_match_exception = NotABSSourceTree diff --git a/src/nbblib/commands.py b/src/nbblib/commands.py index 3b69334..296426b 100644 --- a/src/nbblib/commands.py +++ b/src/nbblib/commands.py @@ -15,6 +15,9 @@ import nbblib.vcs as vcs import nbblib.bs as bs +__all__ = [] + + def adjust_doc(doc): """Remove common whitespace at beginning of doc string lines""" if not doc: return doc @@ -31,6 +34,7 @@ def adjust_doc(doc): return almost_doc[:i] +__all__.append('CommandLineError') class CommandLineError(Exception): def __init__(self, message, *args, **kwargs): super(CommandLineError, self).__init__() @@ -48,6 +52,8 @@ class CommandLineError(Exception): # Command plugin system ######################################################################## + +__all__.append('Command') class Command(object): """ Mount point for plugins which refer to commands that can be performed. @@ -332,6 +338,8 @@ class ConfigCommand(SourceClassCommand): # Commands ######################################################################## + +__all__.append('UnknownCommand') class UnknownCommand(Exception): def __init__(self, cmd): super(UnknownCommand, self).__init__() @@ -339,6 +347,8 @@ class UnknownCommand(Exception): def __str__(self): return "Fatal: Unknown command '%(cmd)s'" % self.__dict__ + +__all__.append('NBB_Command') class NBB_Command(object): def __init__(self, cmd, cmdargs, context): if Command.plugins.has_key(cmd): diff --git a/src/nbblib/main.py b/src/nbblib/main.py index 80f53a6..cf5ec52 100644 --- a/src/nbblib/main.py +++ b/src/nbblib/main.py @@ -247,3 +247,6 @@ def cmdmain(argv): logging.shutdown() raise + +__all__ = ['cmdmain', 'main'] + diff --git a/src/nbblib/plugins.py b/src/nbblib/plugins.py index 9d519f7..c42420d 100644 --- a/src/nbblib/plugins.py +++ b/src/nbblib/plugins.py @@ -67,6 +67,10 @@ import functools import inspect +__all__ = [] + + +__all__.append('NoPluginsRegistered') class NoPluginsRegistered(Exception): """Raised when looking for plugins but none are registered""" def __init__(self, cls): @@ -76,11 +80,13 @@ class NoPluginsRegistered(Exception): return "No plugins of type %s registered" % (self.cls.__name__) +__all__.append('DuplicatePluginName') class DuplicatePluginName(Exception): """Raised when another plugin tries to register the same name""" pass +__all__.append('PluginNoMatch') class PluginNoMatch(Exception): """Raised when no registered plugin matches the given args""" def __init__(self, *args, **kwargs): @@ -92,6 +98,7 @@ class PluginNoMatch(Exception): self.args, self.kwargs) +__all__.append('AmbigousPluginDetection') class AmbigousPluginDetection(Exception): """Raised when more than one registered plugin matches the given args""" def __init__(self, matches, cls, context, *args, **kwargs): @@ -110,6 +117,7 @@ class AmbigousPluginDetection(Exception): self.kwargs) +__all__.append('AbstractMethodsInConcreteClass') class AbstractMethodsInConcreteClass(Exception): """Raised when an abstract method is detected in a non-abstract class @@ -127,6 +135,7 @@ class AbstractMethodsInConcreteClass(Exception): methods) +__all__.append('AbstractMethodError') class AbstractMethodError(Exception): """Raised when an abstract method is called""" def __init__(self, name, module): @@ -138,6 +147,7 @@ class AbstractMethodError(Exception): % (repr(self.name), repr(self.module)) +__all__.append('abstractmethod') def abstractmethod(fun): """The decorator for abstract methods in plugins @@ -160,6 +170,7 @@ def abstractmethod(fun): return f +# Internal type __all__.append('PluginDict') class PluginDict(dict): """Helper for GenericPluginMeta class @@ -175,6 +186,7 @@ class PluginDict(dict): super(PluginDict, self).__setitem__(key, value) +__all__.append('GenericPluginMeta') class GenericPluginMeta(type): """Simple plugin metaclass with named plugins @@ -220,6 +232,7 @@ class GenericPluginMeta(type): pass +__all__.append('GenericDetectPlugin') class GenericDetectPlugin(object): """Advanced plugin class where the plugins detect whether they apply @@ -297,6 +310,7 @@ class GenericDetectPlugin(object): return matches[matches.keys()[0]] +# Not for __all__ def selftest(): class PluginNoMatchA(PluginNoMatch): diff --git a/src/nbblib/test-plugins.py b/src/nbblib/test-plugins.py index 8082aec..1187062 100644 --- a/src/nbblib/test-plugins.py +++ b/src/nbblib/test-plugins.py @@ -14,6 +14,6 @@ if True: logging.error("xxx error") -import newplugins -newplugins.selftest() +import plugins +plugins.selftest() diff --git a/src/nbblib/vcs.py b/src/nbblib/vcs.py index f2a4ea5..6162f3c 100644 --- a/src/nbblib/vcs.py +++ b/src/nbblib/vcs.py @@ -8,6 +8,9 @@ from nbblib import progutils from nbblib import plugins +__all__ = [] + + class AbstractConfig(object): """Return static config until we implement real config reading""" @@ -54,6 +57,7 @@ class AmbigousVCSDetection(plugins.AmbigousPluginDetection): return "Ambigous VCS types detected for %s:\n%s" % (repr(self.srcdir), table) +__all__.append('VCSourceTree') class VCSourceTree(plugins.GenericDetectPlugin): """ Mount point for plugins which refer to actions that can be performed. -- cgit