Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(221)

Unified Diff: trac/loader.py

Issue 186050: Trac r9016 - plugin detection in a traceback (Closed) Base URL: http://svn.edgewall.org/repos/trac/trunk/
Patch Set: Created 2 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trac/htdocs/css/trac.css ('k') | trac/templates/about.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « trac/htdocs/css/trac.css ('k') | trac/templates/about.html » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 855:fffdfa546f68