def unify_file(self, path, file1, file2): ''' Unify buildconfig.html contents, or defer to UnifiedFinder.unify_file. ''' if mozpack.path.basename(path) == 'buildconfig.html': content1 = file1.open().readlines() content2 = file2.open().readlines() # Copy everything from the first file up to the end of its <body>, # insert a <hr> between the two files and copy the second file's # content beginning after its leading <h1>. return GeneratedFile(''.join( content1[:content1.index('</body>\n')] + ['<hr> </hr>\n'] + content2[content2.index('<h1>about:buildconfig</h1>\n') + 1:] )) if path.endswith('.xpi'): finder1 = JarFinder(os.path.join(self._finder1.base, path), JarReader(fileobj=file1.open())) finder2 = JarFinder(os.path.join(self._finder2.base, path), JarReader(fileobj=file2.open())) unifier = UnifiedFinder(finder1, finder2, sorted=self._sorted) err = errors.count all(unifier.find('')) if err == errors.count: return file1 return None return UnifiedFinder.unify_file(self, path, file1, file2)
def _minify_file(self, path, file): ''' Return an appropriate MinifiedSomething wrapper for the given BaseFile instance (file), according to the file type (determined by the given path), if the FileFinder was created with minification enabled. Otherwise, just return the given BaseFile instance. ''' if not self._minify or isinstance(file, ExecutableFile): return file if path.endswith('.properties'): return MinifiedProperties(file) if self._minify_js and path.endswith(('.js', '.jsm')): return MinifiedJavaScript(file, self._minify_js_verify_command) return file
def add(self, path, file): ''' Add the given BaseFile instance with the given path. ''' assert not self._closed if is_manifest(path): self._add_manifest_file(path, file) elif path.endswith('.xpt'): self._queue.append(self.formatter.add_interfaces, path, file) else: self._file_queue.append(self.formatter.add, path, file)
def _minify_file(self, path, file): ''' Return an appropriate MinifiedSomething wrapper for the given BaseFile instance (file), according to the file type (determined by the given path), if the FileFinder was created with minification enabled. Otherwise, just return the given BaseFile instance. Currently, only "*.properties" files are handled. ''' if self._minify and not isinstance(file, ExecutableFile): if path.endswith('.properties'): return MinifiedProperties(file) return file
def add(self, path, file): ''' Add the given BaseFile instance with the given path. ''' assert not self._closed if is_manifest(path): self._add_manifest_file(path, file) elif path.endswith('.xpt'): self._queue.append(self.formatter.add_interfaces, path, file) else: self._file_queue.append(self.formatter.add, path, file) if mozpack.path.basename(path) == 'install.rdf': self._addons.add(mozpack.path.dirname(path))
def is_manifest(path): ''' Return whether the given path is that of a manifest file. ''' return path.endswith('.manifest') and not path.endswith('.CRT.manifest') \ and not path.endswith('.exe.manifest')
def is_manifest(path): """ Return whether the given path is that of a manifest file. """ return path.endswith(".manifest") and not path.endswith(".CRT.manifest") and not path.endswith(".exe.manifest")