~divmod-dev/divmod.org/trunk

« back to all changes in this revision

Viewing changes to Epsilon/epsilon/hotfixes/plugin_package_paths.py

  • Committer: Jean-Paul Calderone
  • Date: 2014-06-29 20:33:04 UTC
  • mfrom: (2749.1.1 remove-epsilon-1325289)
  • Revision ID: exarkun@twistedmatrix.com-20140629203304-gdkmbwl1suei4m97
mergeĀ lp:~exarkun/divmod.org/remove-epsilon-1325289

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2007 Twisted Matrix Laboratories.
2
 
# Copyright (c) 2008 Divmod.
3
 
# See LICENSE for details.
4
 
 
5
 
 
6
 
 
7
 
import sys, os
8
 
 
9
 
def pluginPackagePaths(name):
10
 
    """
11
 
    Return a list of additional directories which should be searched for
12
 
    modules to be included as part of the named plugin package.
13
 
 
14
 
    @type name: C{str}
15
 
    @param name: The fully-qualified Python name of a plugin package, eg
16
 
        C{'twisted.plugins'}.
17
 
 
18
 
    @rtype: C{list} of C{str}
19
 
    @return: The absolute paths to other directories which may contain plugin
20
 
        modules for the named plugin package.
21
 
    """
22
 
    package = name.split('.')
23
 
    # Note that this may include directories which do not exist.  It may be
24
 
    # preferable to remove such directories at this point, rather than allow
25
 
    # them to be searched later on.
26
 
    #
27
 
    # Note as well that only '__init__.py' will be considered to make a
28
 
    # directory a package (and thus exclude it from this list).  This means
29
 
    # that if you create a master plugin package which has some other kind of
30
 
    # __init__ (eg, __init__.pyc) it will be incorrectly treated as a
31
 
    # supplementary plugin directory.
32
 
    return [
33
 
        os.path.abspath(os.path.join(x, *package))
34
 
        for x
35
 
        in sys.path
36
 
        if
37
 
        not os.path.exists(os.path.join(x, *package + ['__init__.py']))]
38
 
 
39
 
 
40
 
def install():
41
 
    import twisted.plugin
42
 
    twisted.plugin.pluginPackagePaths = pluginPackagePaths