Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: packagerChrome.py

Issue 5406295150559232: wrong icons parameter value in manifest.json for chrome buildtool fix. (Closed)
Patch Set: implement PIL in packagerChrome.py Created March 19, 2014, 2:50 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packagerChrome.py
===================================================================
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -50,7 +50,7 @@
# that it can be overridden if necessary.
return data
-def createManifest(params):
+def createManifest(params, files):
template = getTemplate('manifest.json.tmpl')
templateData = dict(params)
@@ -72,19 +72,13 @@
templateData['browserAction'] = {'icon': icon, 'popup': popup}
if metadata.has_option('general', 'icons'):
+ from PIL import Image
icons = {}
- iconsDir = baseDir
- for dir in metadata.get('general', 'icons').split('/')[0:-1]:
- iconsDir = os.path.join(iconsDir, dir)
-
- prefix, suffix = metadata.get('general', 'icons').split('/')[-1].split('?', 1)
- for file in os.listdir(iconsDir):
- path = os.path.join(iconsDir, file)
- if os.path.isfile(path) and file.startswith(prefix) and file.endswith(suffix):
- size = file[len(prefix):-len(suffix)]
- if not re.search(r'\D', size):
- icons[size] = os.path.relpath(path, baseDir).replace('\\', '/')
-
+ for icon in re.split('\s+', metadata.get('general', 'icons')):
+ width, height = Image.open(StringIO(files[icon])).size
+ if(width != height):
+ print 'Warning: %s size is %ix%i, icon should be square' % (icon, width, height)
Wladimir Palant 2014/03/19 21:23:06 Errors and warnings should go to stderr: print
+ icons[width] = icon
templateData['icons'] = icons
if metadata.has_option('general', 'permissions'):
@@ -345,7 +339,7 @@
files = Files(getPackageFiles(params), getIgnoredFiles(params),
process=lambda path, data: processFile(path, data, params))
- files['manifest.json'] = createManifest(params)
+
if metadata.has_section('mapping'):
files.readMappedFiles(metadata.items('mapping'))
files.read(baseDir)
@@ -365,7 +359,8 @@
if metadata.has_section('import_locales'):
importGeckoLocales(params, files)
-
+
+ files['manifest.json'] = createManifest(params, files)
fixMissingTranslations(files)
if devenv:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld