| Index: trac/loader.py |
| =================================================================== |
| --- trac/loader.py (revision 9015) |
| +++ trac/loader.py (revision 9016) |
| @@ -156,8 +156,8 @@ |
| info = get_pkginfo(dist) |
| if not info: |
| info = {} |
| - for k in ('author author_email home_page url license trac' |
| - .split()): |
| + for k in ('author', 'author_email', 'home_page', 'url', |
| + 'license', 'trac'): |
| v = getattr(module, k, '') |
| if v: |
| if k == 'home_page' or k == 'url': |
| @@ -172,7 +172,7 @@ |
| # aren't specified in "setup.py" |
| for k in info: |
| if info[k] == 'UNKNOWN': |
| - info[k] = None |
| + info[k] = '' |
| elif k == 'author': |
| # Must be encoded as unicode as otherwise Genshi |
| # may raise a "UnicodeDecodeError". |
| @@ -220,3 +220,33 @@ |
| return pkg_resources.Distribution(project_name=module.__name__, |
| version='', |
| location=module.__file__) |
| + |
| +def match_plugins_to_frames(plugins, frames): |
| + """Add a `frame_idx` element to plugin information as returned by |
| + `get_plugin_info()`, containing the index of the highest frame in the |
| + list that was located in the plugin. |
| + """ |
|
techtonik
2010/01/09 16:10:39
I would rephrase last part: "...the index of first
|
| + egg_frames = [(i, f) for i, f in enumerate(frames) |
| + if f['filename'].startswith('build/')] |
|
techtonik
2010/01/09 16:10:39
Is there any example of traceback for reference? O
|
| + |
| + def find_egg_frame_index(plugin): |
| + for dist in pkg_resources.find_distributions(plugin['path'], |
| + only=True): |
| + sources = dist.get_metadata('SOURCES.txt') |
| + for src in sources.splitlines(): |
| + if src.endswith('.py'): |
| + nsrc = os.path.normpath(src) |
| + for i, f in egg_frames: |
| + if f['filename'].endswith(nsrc): |
| + plugin['frame_idx'] = i |
| + return |
|
techtonik
2010/01/09 16:10:39
The traceback sample won't hurt here. Can tracebac
|
| + |
| + for plugin in plugins.itervalues(): |
| + base, ext = os.path.splitext(plugin['path']) |
|
techtonik
2010/01/09 16:10:39
plugin['path'] is Distribution.location (any other
|
| + if ext == '.egg' and egg_frames: |
| + find_egg_frame_index(plugin) |
| + else: |
| + for i, f in enumerate(frames): |
| + if f['filename'].startswith(base): |
|
techtonik
2010/01/09 16:10:39
Is base an absolute path or relative? Is it normal
|
| + plugin['frame_idx'] = i |
| + break |