def test_pluginDirectories(self): """ L{plugin.pluginPackagePaths} should return a list containing each directory in C{sys.path} with a suffix based on the supplied package name. """ foo = FilePath('foo') bar = FilePath('bar') sys.path = [foo.path, bar.path] self.assertEqual( plugin.pluginPackagePaths('dummy.plugins'), [foo.child('dummy').child('plugins').path, bar.child('dummy').child('plugins').path])
def test_pluginDirectories(self): """ L{plugin.pluginPackagePaths} should return a list containing each directory in C{sys.path} with a suffix based on the supplied package name. """ foo = FilePath('foo') bar = FilePath('bar') sys.path = [foo.path, bar.path] self.assertEqual(plugin.pluginPackagePaths('dummy.plugins'), [ foo.child('dummy').child('plugins').path, bar.child('dummy').child('plugins').path ])
def test_pluginPackagesExcluded(self): """ L{plugin.pluginPackagePaths} should exclude directories which are Python packages. The only allowed plugin package (the only one associated with a I{dummy} package which Python will allow to be imported) will already be known to the caller of L{plugin.pluginPackagePaths} and will most commonly already be in the C{__path__} they are about to mutate. """ root = FilePath(self.mktemp()) foo = root.child('foo').child('dummy').child('plugins') foo.makedirs() foo.child('__init__.py').setContent(b'') sys.path = [root.child('foo').path, root.child('bar').path] self.assertEqual( plugin.pluginPackagePaths('dummy.plugins'), [root.child('bar').child('dummy').child('plugins').path])
def test_pluginPackagesExcluded(self): """ L{plugin.pluginPackagePaths} should exclude directories which are Python packages. The only allowed plugin package (the only one associated with a I{dummy} package which Python will allow to be imported) will already be known to the caller of L{plugin.pluginPackagePaths} and will most commonly already be in the C{__path__} they are about to mutate. """ root = FilePath(self.mktemp()) foo = root.child('foo').child('dummy').child('plugins') foo.makedirs() foo.child('__init__.py').setContent('') sys.path = [root.child('foo').path, root.child('bar').path] self.assertEqual( plugin.pluginPackagePaths('dummy.plugins'), [root.child('bar').child('dummy').child('plugins').path])
from twisted.plugin import pluginPackagePaths import os # From txircd: # https://github.com/ElementalAlchemist/txircd/blob/8832098149b7c5f9b0708efe5c836c8160b0c7e6/txircd/modules/__init__.py __path__.extend(pluginPackagePaths(__name__)) for directory, subdirs, files in os.walk( os.path.dirname(os.path.realpath(__file__))): for subdir in subdirs: __path__.append(os.path.join( directory, subdir)) # Include all module subdirectories in the path __all__ = []
""" The plugins directory """ # add goonsite.plugins directories to the plugin-searchable paths from twisted.plugin import pluginPackagePaths __path__.extend(pluginPackagePaths(__name__)) __all__ = []
from twisted.plugin import pluginPackagePaths except ImportError: # Not available in Twisted 2.5.0 in Ubuntu hardy # This is straight from twisted.plugin import os.path import sys def pluginPackagePaths(name): package = name.split('.') return [ os.path.abspath(os.path.join(x, *package)) for x in sys.path if not os.path.exists(os.path.join(x, *package + ['__init__.py'])) ] __path__ = pluginPackagePaths(__name__) + __path__ class IbidSourceFactory(object): supports = () auth = () permissions = () def __new__(cls, *args): cls.type = cls.__module__.split('.')[2] for name, option in options.items(): new = copy(option) default = getattr(cls, name) new.default = default
# -*- test-case-name: twisted.test.test_plugin -*- # Copyright (c) 2005 Divmod, Inc. # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Plugins for services implemented in Twisted. Plugins go in directories on your PYTHONPATH named twisted/plugins: this is the only place where an __init__.py is necessary, thanks to the __path__ variable. @author: Jp Calderone @author: Glyph Lefkowitz """ from twisted.plugin import pluginPackagePaths from typing import List __path__.extend(pluginPackagePaths(__name__)) # type: ignore[name-defined] __all__ = [] # type: List[str] # nothing to see here, move along, move along
from twisted.plugin import pluginPackagePaths except ImportError: # Not available in Twisted 2.5.0 in Ubuntu hardy # This is straight from twisted.plugin import os.path import sys def pluginPackagePaths(name): package = name.split('.') return [os.path.abspath(os.path.join(x, *package)) for x in sys.path if not os.path.exists(os.path.join(x, *package + ['__init__.py']))] import ibid from ibid.compat import json, defaultdict from ibid.utils import url_regex __path__ = pluginPackagePaths(__name__) + __path__ for cat, desc, weight in ( ('account', u'bot accounts and permissions', None), ('admin', u'administrative functions', None), ('calculate', u'calculations', 0), ('convert', u'conversions', 0), ('debug', u'debugging me', None), ('decide', u'decisions', -2), ('development', u'software development', 10), ('fun', u'silly fun stuff', 0), ('game', u'games', -2), ('lookup', u'looking things up', -10), ('monitor', u'monitoring things', -2), ('remember', u'remembering things', -5), ('web', u'browsing the Internet', 0),
# Copyright 2010 Doug Winter # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Squeal: squeezebox jukebox. """ __author__ = 'Doug Winter <*****@*****.**>' __docformat__ = 'restructuredtext en' __version__ = '$Revision$'[11:-2] try: import wingdbstub except ImportError: pass # http://twistedmatrix.com/documents/current/core/howto/plugin.html from twisted.plugin import pluginPackagePaths __path__.extend(pluginPackagePaths('squeal.plugins')) __all__ = []
from twisted.plugin import pluginPackagePaths __path__.extend(pluginPackagePaths("rstpdflib.plugins")) __all__ = []