~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-31 16:12:57 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060731161257-91a231523255332c
new official bzr.ico

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
    Plugins are loaded into bzrlib.plugins.NAME, and can be found there
112
112
    for future reference.
113
113
    """
114
 
    # Get the list of valid python suffixes for __init__.py?
115
 
    # this includes .py, .pyc, and .pyo (depending on if we are running -O)
116
 
    # but it doesn't include compiled modules (.so, .dll, etc)
117
 
    valid_suffixes = [suffix for suffix, mod_type, flags in imp.get_suffixes()
118
 
                              if flags in (imp.PY_SOURCE, imp.PY_COMPILED)]
119
 
    package_entries = ['__init__'+suffix for suffix in valid_suffixes]
 
114
    # The problem with imp.get_suffixes() is that it doesn't include
 
115
    # .pyo which is technically valid
 
116
    # It also means that "testmodule.so" will show up as both test and testmodule
 
117
    # though it is only valid as 'test'
 
118
    # but you should be careful, because "testmodule.py" loads as testmodule.
 
119
    suffixes = imp.get_suffixes()
 
120
    suffixes.append(('.pyo', 'rb', imp.PY_COMPILED))
 
121
    package_entries = ['__init__.py', '__init__.pyc', '__init__.pyo']
120
122
    for d in dirs:
121
123
        if not d:
122
124
            continue
135
137
                else: # This directory is not a package
136
138
                    continue
137
139
            else:
138
 
                for suffix_info in imp.get_suffixes():
 
140
                for suffix_info in suffixes:
139
141
                    if f.endswith(suffix_info[0]):
140
142
                        f = f[:-len(suffix_info[0])]
141
143
                        if suffix_info[2] == imp.C_EXTENSION and f.endswith('module'):