def processJarSection(self, jarinfo, jardir): '''Internal method called by makeJar to actually process a section of a jar.mn file. ''' # chromebasepath is used for chrome registration manifests # {0} is getting replaced with chrome/ for chrome.manifest, and with # an empty string for jarfile.manifest chromebasepath = '{0}' + os.path.basename(jarinfo.name) if self.outputFormat == 'jar': chromebasepath = 'jar:' + chromebasepath + '.jar!' chromebasepath += '/' jarfile = os.path.join(jardir, jarinfo.base, jarinfo.name) jf = None if self.outputFormat == 'jar': # jar jarfilepath = jarfile + '.jar' try: os.makedirs(os.path.dirname(jarfilepath)) except OSError as error: if error.errno != errno.EEXIST: raise jf = ZipFile(jarfilepath, 'a', lock=True) outHelper = self.OutputHelper_jar(jf) else: outHelper = getattr(self, 'OutputHelper_' + self.outputFormat)(jarfile) if jarinfo.relativesrcdir: self.localedirs = self.generateLocaleDirs(jarinfo.relativesrcdir) for e in jarinfo.entries: self._processEntryLine(e, outHelper, jf) self.finalizeJar(jardir, jarinfo.base, jarinfo.name, chromebasepath, jarinfo.chrome_manifests) if jf is not None: jf.close()
def processJarSection(self, jarfile, lines, jardir): '''Internal method called by makeJar to actually process a section of a jar.mn file. jarfile is the basename of the jarfile or the directory name for flat output, lines is a pushback_iterator of the lines of jar.mn, the remaining options are carried over from makeJar. ''' # chromebasepath is used for chrome registration manifests # {0} is getting replaced with chrome/ for chrome.manifest, and with # an empty string for jarfile.manifest chromebasepath = '{0}' + os.path.basename(jarfile) if self.outputFormat == 'jar': chromebasepath = 'jar:' + chromebasepath + '.jar!' chromebasepath += '/' jarfile = os.path.join(jardir, jarfile) jf = None if self.outputFormat == 'jar': #jar jarfilepath = jarfile + '.jar' try: os.makedirs(os.path.dirname(jarfilepath)) except OSError as error: if error.errno != errno.EEXIST: raise jf = ZipFile(jarfilepath, 'a', lock=True) outHelper = self.OutputHelper_jar(jf) else: outHelper = getattr(self, 'OutputHelper_' + self.outputFormat)(jarfile) register = {} # This loop exits on either # - the end of the jar.mn file # - an line in the jar.mn file that's not part of a jar section # - on an exception raised, close the jf in that case in a finally try: while True: try: l = next(lines) except StopIteration: # we're done with this jar.mn, and this jar section self.finalizeJar(jarfile, chromebasepath, register) if jf is not None: jf.close() # reraise the StopIteration for makeJar raise if self.ignore.match(l): continue m = self.relsrcline.match(l) if m: relativesrcdir = m.group('relativesrcdir') self.localedirs = self.generateLocaleDirs(relativesrcdir) continue m = self.regline.match(l) if m: rline = m.group(1) register[rline] = 1 continue m = self.entryline.match(l) if not m: # neither an entry line nor chrome reg, this jar section is done self.finalizeJar(jarfile, chromebasepath, register) if jf is not None: jf.close() lines.pushback(l) return self._processEntryLine(m, outHelper, jf) finally: if jf is not None: jf.close() return
def processJarSection(self, jarfile, lines, jardir, sourcedirs, topsourcedir, localedirs): '''Internal method called by makeJar to actually process a section of a jar.mn file. jarfile is the basename of the jarfile or the directory name for flat output, lines is a pushback_iterator of the lines of jar.mn, the remaining options are carried over from makeJar. ''' # chromebasepath is used for chrome registration manifests # %s is getting replaced with chrome/ for chrome.manifest, and with # an empty string for jarfile.manifest chromebasepath = '%s' + jarfile if self.outputFormat == 'jar': chromebasepath = 'jar:' + chromebasepath + '.jar!' chromebasepath += '/' jarfile = os.path.join(jardir, jarfile) jf = None if self.outputFormat == 'jar': #jar jarfilepath = jarfile + '.jar' try: os.makedirs(os.path.dirname(jarfilepath)) except OSError: pass jf = ZipFile(jarfilepath, 'a', lock=True) outHelper = self.OutputHelper_jar(jf) else: outHelper = getattr(self, 'OutputHelper_' + self.outputFormat)(jarfile) register = {} # This loop exits on either # - the end of the jar.mn file # - an line in the jar.mn file that's not part of a jar section # - on an exception raised, close the jf in that case in a finally try: while True: try: l = lines.next() except StopIteration: # we're done with this jar.mn, and this jar section self.finalizeJar(jarfile, chromebasepath, register) if jf is not None: jf.close() # reraise the StopIteration for makeJar raise if self.ignore.match(l): continue m = self.regline.match(l) if m: rline = m.group(1) register[rline] = 1 continue m = self.entryline.match(l) if not m: # neither an entry line nor chrome reg, this jar section is done self.finalizeJar(jarfile, chromebasepath, register) if jf is not None: jf.close() lines.pushback(l) return self._processEntryLine(m, sourcedirs, topsourcedir, localedirs, outHelper, jf) finally: if jf is not None: jf.close() return