def setId(self): rdf = xml_open('%s/install.rdf' % self.opts.exportTo) 'update the id' node = rdf.getElementsByTagNameNS(NS_EM, 'id')[0].childNodes[0] node.data = self.opts.extid 'save' f = open('export/install.rdf', 'w') rdf.writexml(f) 'cleanup' rdf.unlink() f.close() for vi in ('modules/version.jsm', 'chrome/content/common/verinfo.js'): vi = '%s/%s' % (self.opts.exportTo, vi) if not os.path.exists(vi): continue f = open(vi) lines = f.readlines() f.close() f = open(vi, 'wb') for l in lines: if re.search('const ID', l): l = "const ID = '%s';\n" % self.opts.extid elif re.search('const DTA_ID', l): l = "const DTA_ID = '%s';\n" % self.opts.extid f.write(l) f.close()
def nightlify(self): 'open' rdf = xml_open('%s/install.rdf' % self.opts.exportTo) 'update the version' node = rdf.getElementsByTagNameNS(NS_EM, 'version')[0].childNodes[0] node.data = "%s.%s.%s" % (node.data, strftime("%Y%m%d"), self.getrevision()) node = rdf.getElementsByTagNameNS(NS_EM, 'name')[0].childNodes[0] node.data = node.data + ' *nightly*' 'insert the updateURL node' node = rdf.getElementsByTagNameNS(NS_EM, 'aboutURL')[0] u = rdf.createElementNS(NS_EM, 'em:updateURL') u.appendChild(rdf.createTextNode(self.opts.updateURL)) node.parentNode.insertBefore(u, node) 'prettify' node.parentNode.insertBefore(rdf.createTextNode('\n\t\t'), node) 'save' with open('export/install.rdf', 'w') as f: f.write(rdf.toxml(encoding="utf-8")) 'cleanup' rdf.unlink()
def createXPI(self, xpi_file, rc): additional = '' if self.opts.version: rdf = xml_open('%s/install.rdf' % self.opts.exportTo) additional += '-' + rdf.getElementsByTagNameNS(NS_EM, 'version')[0].childNodes[0].data if rc > 0: additional += "rc%d" % rc rdf.unlink() if self.opts.revision: additional += '-r%d' % self.getrevision() output = xpi_file % additional xpi_file = ZipFile(output, 'w', ZIP_DEFLATED) for x in self.getfilelist(self.opts.exportTo): yield x xpi_file.write(x, x[len(self.opts.exportTo) + 1:].encode('cp437')) xpi_file.close() yield "written to: " + output
def createXPI(self, xpi_file, rc): additional = '' if self.opts.version: rdf = xml_open('%s/install.rdf' % self.opts.exportTo) additional += '-' + rdf.getElementsByTagNameNS( NS_EM, 'version')[0].childNodes[0].data if rc > 0: additional += "rc%d" % rc rdf.unlink() if self.opts.revision: additional += '-r%d' % self.getrevision() output = xpi_file % additional xpi_file = ZipFile(output, 'w', ZIP_DEFLATED) for x in self.getfilelist(self.opts.exportTo): yield x xpi_file.write(x, x[len(self.opts.exportTo) + 1:].encode('cp437')) xpi_file.close() yield "written to: " + output