aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
authorNiall Douglas (a [underscors] sourceforge {at} nedprod [dot] com) <spam@spamtrap.com>2012-02-22 17:46:06 +0000
committerW. Trevor King <wking@tremily.us>2012-08-23 12:39:07 -0400
commit71ec5a1d04094da7bce5f542978ed49bd302e178 (patch)
treed25da65b1462a91de44730b19c439e751c3c83e2 /libbe
parente55730c6b0737e3edb4ff407c12b34b5390ef4a1 (diff)
downloadbugseverywhere-71ec5a1d04094da7bce5f542978ed49bd302e178.tar.gz
Cherrypick improved zipfile support from Niall Douglas.
WTK: This is the meat of Niall's commit 4632cb6d22faa7220540f92af67693084f80f033 Author: Niall Douglas ... Date: Wed Feb 22 17:46:06 2012 +0000 Fixed small bug where running from inside zip support was over preferring .pyc files
Diffstat (limited to 'libbe')
-rw-r--r--libbe/util/plugin.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/libbe/util/plugin.py b/libbe/util/plugin.py
index 1fee690..63715a0 100644
--- a/libbe/util/plugin.py
+++ b/libbe/util/plugin.py
@@ -72,17 +72,23 @@ def modnames(prefix):
components = prefix.split('.')
modfilespath=os.path.join(_PLUGIN_PATH, *components)
# Cope if we are executing from inside a zip archive full of precompiled .pyc's
- modfiles=ziplistdir(modfilespath) if '.zip' in modfilespath else os.listdir(modfilespath)
+ inside_zip='.zip' in modfilespath
+ modfiles=ziplistdir(modfilespath) if inside_zip else os.listdir(modfilespath)
modfiles.sort()
- # Eliminate .py/.pyc duplicates
- print modfiles
- x=1
- while x<len(modfiles):
- if modfiles[x].endswith('.pyc') and modfiles[x-1]==modfiles[x][:len(modfiles[x-1])]:
- del modfiles[x-1]
- else:
+ # Eliminate .py/.pyc duplicates, preferring .pyc if we're in a zip archive
+ if inside_zip:
+ x=1
+ while x<len(modfiles):
+ if modfiles[x].endswith('.pyc') and modfiles[x-1]==modfiles[x][:len(modfiles[x-1])]:
+ del modfiles[x-1]
+ else:
+ x+=1
+ else:
+ x=0
+ while x<len(modfiles)-1:
+ if modfiles[x].endswith('.py') and modfiles[x]==modfiles[x+1][:len(modfiles[x])]:
+ del modfiles[x+1]
x+=1
- print modfiles
for modfile in modfiles:
if modfile.startswith('.'):
continue # the occasional emacs temporary file