/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to profile_imports.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
 
101
101
_real_import = __import__
102
102
 
103
 
def timed_import(name, globals=None, locals=None, fromlist=None, level=-1):
 
103
def timed_import(name, globals=None, locals=None, fromlist=None, level=None):
104
104
    """Wrap around standard importer to log import time"""
105
105
    # normally there are 4, but if this is called as __import__ eg by
106
106
    # /usr/lib/python2.6/email/__init__.py then there may be only one
118
118
        if scope_name is None:
119
119
            scope_name = globals.keys()
120
120
        else:
121
 
            # Trim out paths before breezy
122
 
            loc = scope_name.find('breezy')
 
121
            # Trim out paths before bzrlib
 
122
            loc = scope_name.find('bzrlib')
123
123
            if loc != -1:
124
124
                scope_name = scope_name[loc:]
125
125
            # For stdlib, trim out early paths
150
150
    tstart = _timer()
151
151
    try:
152
152
        # Do the import
153
 
        return _real_import(name, globals, locals, fromlist, level=level)
 
153
        mod = _real_import(name, globals, locals, fromlist)
154
154
    finally:
155
155
        tload = _timer()-tstart
156
156
        stack_finish(this, tload)
157
157
 
158
 
 
159
 
def _repr_regexp(pattern, max_len=30):
160
 
    """Present regexp pattern for logging, truncating if over max_len."""
161
 
    if len(pattern) > max_len:
162
 
        return repr(pattern[:max_len-3]) + "..."
163
 
    return repr(pattern)
 
158
    return mod
164
159
 
165
160
 
166
161
_real_compile = re._compile
180
175
        frame = sys._getframe(5)
181
176
        frame_name = frame.f_globals.get('__name__', '<unknown>')
182
177
    frame_lineno = frame.f_lineno
183
 
    this = stack_add(extra+_repr_regexp(args[0]), frame_name, frame_lineno)
 
178
    this = stack_add(extra+repr(args[0]), frame_name, frame_lineno)
184
179
 
185
180
    tstart = _timer()
186
181
    try: