本文整理汇总了Python中MoinMoin.util.pysupport.getPackageModules函数的典型用法代码示例。如果您正苦于以下问题:Python getPackageModules函数的具体用法?Python getPackageModules怎么用?Python getPackageModules使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getPackageModules函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeSuite
def makeSuite():
""" Automatically create tests and test suites for all tests.
For this to work, test modules must reside in MoinMoin._tests
(i.e. right here) and have names starting with "test_", and
contain test cases with names ending in "TestCase". Each test case
may contain multiply testAABBCC methods. Those methods will be run by
the test suites. See _test_template.py for an example, and use it to
create new tests.
"""
result = unittest.TestSuite()
test_modules = pysupport.getPackageModules(__file__)
# Sort test modules names by case insensitive compare to get nicer output
caseInsensitiveCompare = lambda a, b: cmp(a.lower(), b.lower())
test_modules.sort(caseInsensitiveCompare)
for mod_name in test_modules:
if not mod_name.startswith('test_'): continue
# Import module
module = __import__(__name__ + '.' + mod_name,
globals(), locals(), ['__file__'])
# Collect TestCase and create suite for each one
test_cases = [unittest.makeSuite(obj, 'test')
for name, obj in module.__dict__.items()
if name.endswith('TestCase')]
# Add tests suites
if test_cases:
suite = unittest.TestSuite(test_cases)
result.addTest(suite)
return result
示例2: makeSuite
def makeSuite(request, names=None):
""" Create test suites from modules in names
@param request: current request
@param names: module names to get tests from. If the list is empty,
all test modules in the _tests package are used.
@rtype: C{unittest.TestSuite}
@return: test suite with all test cases in names
"""
if not names:
from MoinMoin.util.pysupport import getPackageModules
names = getPackageModules(__file__)
names = ['%s.%s' % (__name__, name) for name in names
if name.startswith('test_')]
caseInsensitiveCompare = lambda a, b: cmp(a.lower(), b.lower())
names.sort(caseInsensitiveCompare)
loader = MoinTestLoader(request)
return loader.loadTestsFromNames(names)
示例3: __init__
Additionally to the usual stuff, we provide an ActionBase class here with
some of the usual base functionality for an action, like checking
actions_excluded, making and checking tickets, rendering some form,
displaying errors and doing stuff after an action.
@copyright: 2006 MoinMoin:ThomasWaldmann
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin.util import pysupport
from MoinMoin import wikiutil
from MoinMoin.Page import Page
# create a list of extension actions from the subpackage directory
import MoinMoin.request
extension_actions = pysupport.getPackageModules(MoinMoin.request.prefix + "/action/__init__.py")
modules = extension_actions
class ActionBase:
""" action base class with some generic stuff to inherit
Note: the action name is the class name of the derived class
"""
def __init__(self, pagename, request):
self.request = request
self.form = request.form
self.cfg = request.cfg
self._ = _ = request.getText
self.pagename = pagename
self.actionname = self.__class__.__name__
self.use_ticket = False # set this to True if you want to use a ticket
示例4:
# -*- coding: iso-8859-1 -*-
"""
MoinMoin - Maintenance Script Package
@copyright: 2006 by Thomas Waldmann
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin.util import pysupport
# create a list of extension scripts from the subpackage directory
maint_scripts = pysupport.getPackageModules(__file__)
modules = maint_scripts
示例5:
# -*- coding: iso-8859-1 -*-
"""
MoinMoin - Extension Script Package
@copyright: 2006 by Thomas Waldmann
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin.util import pysupport
# create a list of extension scripts from the subpackage directory
extension_scripts = pysupport.getPackageModules(__file__)
modules = extension_scripts
示例6: Event
This code abstracts event handling in MoinMoin,
currently for notifications. It implements the observer pattern.
@copyright: 2007 by Karol Nowak <[email protected]>
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin import log
logging = log.getLogger(__name__)
from MoinMoin import wikiutil
from MoinMoin.util import pysupport
from MoinMoin.wikiutil import PluginAttributeError
# Create a list of extension actions from the package directory
modules = pysupport.getPackageModules(__file__)
# Dummy pseudo-getText function used in event descriptions,
# so that they get into .po files
_ = lambda x: x
class Event(object):
"""A class handling information common to all events."""
# NOTE: each Event subclass must have a unique name attribute
name = u"Event"
def __init__(self, request):
self.request = request
示例7:
# -*- coding: iso-8859-1 -*-
"""
MoinMoin - Processor Package
DEPRECATED!
Please use Parsers instead of Processors.
@copyright: 2002 by Jürgen Hermann <[email protected]>
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin.util import pysupport
processors = pysupport.getPackageModules(__file__)
modules = processors
示例8: getPlugins
def getPlugins(request):
dir = os.path.join(request.cfg.plugin_dir, 'action')
plugins = []
if os.path.isdir(dir):
plugins = pysupport.getPackageModules(os.path.join(dir, 'dummy'))
return dir, plugins
示例9: Waldmann
# -*- coding: iso-8859-1 -*-
"""
MoinMoin - LogFile package
@copyright: 2005 by Thomas Waldmann (MoinMoin:ThomasWaldmann)
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin.util import pysupport
import MoinMoin.request
logfiles = pysupport.getPackageModules(MoinMoin.request.prefix + "/logfile/__init__.py")
示例10: execute
# -*- coding: iso-8859-1 -*-
"""
MoinMoin - Macro Package
The canonical interface to macros is their execute() function,
which gets passed an instance of the Macro class. Such an instance
has the four members parser, formatter, form and request.
Using "form" directly is deprecated and should be replaced
by "request.form".
Besides the execute() function, macros can export additional
functions to offer services to other macros or actions. A few
actually do that, e.g. AttachFile.
@copyright: 2000 by Jürgen Hermann <[email protected]>
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin.util import pysupport
import MoinMoin.request
extension_macros = pysupport.getPackageModules(MoinMoin.request.prefix + "/macro/__init__.py")
modules = extension_macros
示例11: execute
# -*- coding: iso-8859-1 -*-
"""
MoinMoin - Macro Package
The canonical interface to macros is their execute() function,
which gets passed an instance of the Macro class. Such an instance
has the four members parser, formatter, form and request.
Using "form" directly is deprecated and should be replaced
by "request.form".
Besides the execute() function, macros can export additional
functions to offer services to other macros or actions. A few
actually do that, e.g. AttachFile.
@copyright: 2000 by Jürgen Hermann <[email protected]>
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin.util import pysupport
extension_macros = pysupport.getPackageModules(__file__)
modules = extension_macros