~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-16 22:00:19 UTC
  • mto: This revision was merged to the branch mainline in revision 1942.
  • Revision ID: john@arbash-meinel.com-20060816220019-541cb90093258ac3
Using real utf8 and cache_utf8 has similar performance, 272ms, and 363ms

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
 
    # 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']
 
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]
122
120
    for d in dirs:
123
121
        if not d:
124
122
            continue
137
135
                else: # This directory is not a package
138
136
                    continue
139
137
            else:
140
 
                for suffix_info in suffixes:
 
138
                for suffix_info in imp.get_suffixes():
141
139
                    if f.endswith(suffix_info[0]):
142
140
                        f = f[:-len(suffix_info[0])]
143
141
                        if suffix_info[2] == imp.C_EXTENSION and f.endswith('module'):