~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-13 19:58:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1869.
  • Revision ID: john@arbash-meinel.com-20060713195822-965e2c4422506a75
cleanup pass, allow pycurl connections to be shared between transports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2004, 2005 by Canonical Ltd
2
 
#
 
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
#
 
7
 
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
#
 
12
 
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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'):