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

Delta Between Two Patch Sets: packager.py

Issue 29319007: Issue 2711 - Refactored ChainedConfigParser, allowing manipulation of list items (Closed)
Left Patch Set: Unimplement add_section as well Created June 26, 2015, 1:40 p.m.
Right Patch Set: Addressed comments Created July 7, 2015, 3:18 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « chainedconfigparser.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This Source Code Form is subject to the terms of the Mozilla Public 3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 6
7 # Note: These are the base functions common to all packagers, the actual 7 # Note: These are the base functions common to all packagers, the actual
8 # packagers are implemented in packagerGecko and packagerChrome. 8 # packagers are implemented in packagerGecko and packagerChrome.
9 9
10 import sys, os, re, codecs, subprocess, json, zipfile 10 import sys, os, re, codecs, subprocess, json, zipfile
11 from StringIO import StringIO 11 from StringIO import StringIO
12 from chainedconfigparser import ChainedConfigParser 12 from chainedconfigparser import ChainedConfigParser
13 13
14 import buildtools 14 import buildtools
15 15
16 def getDefaultFileName(metadata, version, ext): 16 def getDefaultFileName(metadata, version, ext):
17 return '%s-%s.%s' % (metadata.get('general', 'basename'), version, ext) 17 return '%s-%s.%s' % (metadata.get('general', 'basename'), version, ext)
18 18
19 def getMetadataPath(baseDir, type): 19 def getMetadataPath(baseDir, type):
20 return os.path.join(baseDir, 'metadata.%s' % type) 20 return os.path.join(baseDir, 'metadata.%s' % type)
21 21
22 def readMetadata(baseDir, type): 22 def readMetadata(baseDir, type):
23 parser = ChainedConfigParser() 23 parser = ChainedConfigParser()
24 parser.optionxform = lambda option: option
24 parser.read(getMetadataPath(baseDir, type)) 25 parser.read(getMetadataPath(baseDir, type))
25 return parser 26 return parser
26 27
27 def getBuildNum(baseDir): 28 def getBuildNum(baseDir):
28 try: 29 try:
29 from buildtools.ensure_dependencies import Mercurial, Git 30 from buildtools.ensure_dependencies import Mercurial, Git
30 if Mercurial().istype(baseDir): 31 if Mercurial().istype(baseDir):
31 result = subprocess.check_output(['hg', 'id', '-R', baseDir, '-n']) 32 result = subprocess.check_output(['hg', 'id', '-R', baseDir, '-n'])
32 return re.sub(r'\D', '', result) 33 return re.sub(r'\D', '', result)
33 elif Git().istype(baseDir): 34 elif Git().istype(baseDir):
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 names = self.keys() 126 names = self.keys()
126 names.sort(key=sortKey) 127 names.sort(key=sortKey)
127 for name in names: 128 for name in names:
128 zip.writestr(name, self[name]) 129 zip.writestr(name, self[name])
129 zip.close() 130 zip.close()
130 131
131 def zipToString(self, sortKey=None): 132 def zipToString(self, sortKey=None):
132 buffer = StringIO() 133 buffer = StringIO()
133 self.zip(buffer, sortKey=sortKey) 134 self.zip(buffer, sortKey=sortKey)
134 return buffer.getvalue() 135 return buffer.getvalue()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld