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

Side by Side Diff: packager.py

Issue 9190147: Allow metadata file to inherit values from another configuration file (Closed)
Patch Set: Created Jan. 18, 2013, 11:40 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« chainedconfigparser.py ('K') | « chainedconfigparser.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus build tools, 3 # This file is part of the Adblock Plus build tools,
4 # Copyright (C) 2006-2012 Eyeo GmbH 4 # Copyright (C) 2006-2012 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17 17
18 # Note: These are the base functions common to all packagers, the actual 18 # Note: These are the base functions common to all packagers, the actual
19 # packagers are implemented in packagerGecko and packagerChrome. 19 # packagers are implemented in packagerGecko and packagerChrome.
20 20
21 import sys, os, re, codecs, subprocess, json, zipfile, jinja2 21 import sys, os, re, codecs, subprocess, json, zipfile, jinja2
22 from StringIO import StringIO 22 from StringIO import StringIO
23 from ConfigParser import SafeConfigParser 23 from chainedconfigparser import ChainedConfigParser
24 24
25 import buildtools 25 import buildtools
26 26
27 def getDefaultFileName(baseDir, metadata, version, ext): 27 def getDefaultFileName(baseDir, metadata, version, ext):
28 return os.path.join(baseDir, '%s-%s.%s' % (metadata.get('general', 'basename') , version, ext)) 28 return os.path.join(baseDir, '%s-%s.%s' % (metadata.get('general', 'basename') , version, ext))
29 29
30 def getMetadataPath(baseDir): 30 def getMetadataPath(baseDir):
31 return os.path.join(baseDir, 'metadata') 31 return os.path.join(baseDir, 'metadata')
32 32
33 def readMetadata(baseDir): 33 def readMetadata(baseDir):
34 metadata = SafeConfigParser() 34 return ChainedConfigParser(getMetadataPath(baseDir))
35 metadata.optionxform = str
36 file = codecs.open(getMetadataPath(baseDir), 'rb', encoding='utf-8')
37 metadata.readfp(file)
38 file.close()
39 return metadata
40 35
41 def getBuildNum(baseDir): 36 def getBuildNum(baseDir):
42 try: 37 try:
43 (result, dummy) = subprocess.Popen(['hg', 'id', '-R', baseDir, '-n'], stdout =subprocess.PIPE).communicate() 38 (result, dummy) = subprocess.Popen(['hg', 'id', '-R', baseDir, '-n'], stdout =subprocess.PIPE).communicate()
44 return re.sub(r'\D', '', result) 39 return re.sub(r'\D', '', result)
45 except Exception: 40 except Exception:
46 return '0' 41 return '0'
47 42
48 def getBuildVersion(baseDir, metadata, releaseBuild, buildNum=None): 43 def getBuildVersion(baseDir, metadata, releaseBuild, buildNum=None):
49 version = metadata.get('general', 'version') 44 version = metadata.get('general', 'version')
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 data = self[name] 111 data = self[name]
117 if self.process: 112 if self.process:
118 data = self.process(name, data) 113 data = self.process(name, data)
119 zip.writestr(name, data) 114 zip.writestr(name, data)
120 zip.close() 115 zip.close()
121 116
122 def zipToString(self, sortKey=None): 117 def zipToString(self, sortKey=None):
123 buffer = StringIO() 118 buffer = StringIO()
124 self.zip(buffer, sortKey=sortKey) 119 self.zip(buffer, sortKey=sortKey)
125 return buffer.getvalue() 120 return buffer.getvalue()
OLDNEW
« chainedconfigparser.py ('K') | « chainedconfigparser.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld