def test_get_list(): """Test that the manager can read the file listing.""" z = XPIManager(get_path('xpi/install_rdf_only.xpi')) assert not z.contents_cache assert z.package_contents() assert z.contents_cache # Spelling check! z.contents_cache = 'foo' eq_(z.package_contents(), 'foo')
def test_get_list(): """Test that the manager can read the file listing.""" z = XPIManager(get_path('xpi/install_rdf_only.xpi')) assert not z.contents_cache assert z.package_contents() assert z.contents_cache # Spelling check! z.contents_cache = 'foo' eq_(z.package_contents(), 'foo')
def test_get_list(): "Test that the manager can read the file listing" z = XPIManager("tests/resources/xpi/install_rdf_only.xpi") assert not z.contents_cache assert z.package_contents() assert z.contents_cache # Spelling check! z.contents_cache = "foo" eq_(z.package_contents(), "foo")
def _test_type(file_, expectation, failure=False): 'Tests a file against the expectations' err = ErrorBundle(None, True) package = XPIManager(open(file_), mode='r', name=file_) contents = package.package_contents() # We need to have an install.rdf. assert 'install.rdf' in contents # Load up the install.rdf into an RDFParser install_file = package.read('install.rdf') install_rdf = RDFParser(err, install_file) results = typedetection.detect_type(err, install_rdf, package) assert results == expectation if not failure: assert not err.failed() else: assert err.failed() return err
def _test_type(file_, expectation, failure=False): 'Tests a file against the expectations' err = ErrorBundle(None, True) package = XPIManager(open(file_), mode='r', name=file_) contents = package.package_contents() # We need to have an install.rdf. assert 'install.rdf' in contents # Load up the install.rdf into an RDFParser install_file = package.read('install.rdf') install_rdf = RDFParser(err, install_file) results = typedetection.detect_type(err, install_rdf, package) assert results == expectation if not failure: assert not err.failed() else: assert err.failed() return err
def test_valid_name(): 'Test that the manager can retrieve the correct file name.' z = XPIManager(get_path('xpi/install_rdf_only.xpi')) contents = z.package_contents() assert 'install.rdf' in contents
def test_valid_name(): "Test that the manager can retrieve the correct file name." z = XPIManager(get_path('xpi/install_rdf_only.xpi')) contents = z.package_contents() assert 'install.rdf' in contents
def test_valid_name(): "Test that the manager can retrieve the correct file name." z = XPIManager(get_path("xpi/install_rdf_only.xpi")) contents = z.package_contents() assert "install.rdf" in contents assert z.test() == False
def __init__(self, filename, project=None, release=None, name=None): """ Fills in a list of locales from the chrome.manifest file. """ Bundle.__init__(self, project, release) self.xpi = XPIManager(filename, name=name) # here we will store managers for jarfiles self.jarfiles = {} chrome = ChromeManifest(self.xpi.read("chrome.manifest"), "manifest") locales = list(chrome.get_triples("locale")) if not locales: return None # read the list for locale in locales: code, location = locale["object"].split() # finding out the language of the locale try: lang = self._get_lang(code) except Language.DoesNotExist: self.log("Locale %s SKIPPED" % code, "font-weight:bold") continue # Locales can be bundled in JARs jarred = location.startswith("jar:") if jarred: # We just care about the JAR path location = location[4:] split_location = location.split("!", 2) # Ignore malformed JAR URIs. if len(split_location) < 2: continue jarname, location = split_location # missing file mentioned if jarname not in self.xpi: continue # may be we have already read this one if jarname in self.jarfiles: package = self.jarfiles[jarname] else: jar = StringIO(self.xpi.read(jarname)) package = XPIManager(jar, mode="r", name=jarname) else: package = self.xpi # and now we read files from there location = location.strip('/') result = {} for f in package.package_contents(): f = f.strip("/") if f.startswith(location) and f != location: result[f.split("/")[-1]] = package.read(f) # file with same name in different jars can get overwritten if lang not in self.locales: self.locales[lang] = result else: self.locales[lang].update(result)
def __init__(self, filename, project=None, release=None, name=None): """ Fills in a list of locales from the chrome.manifest file. """ Bundle.__init__(self, project, release) self.xpi = XPIManager(filename, name=name) # here we will store managers for jarfiles self.jarfiles = {} chrome = ChromeManifest(self.xpi.read("chrome.manifest"), "manifest") locales = list(chrome.get_triples("locale")) if not locales: return None # read the list for locale in locales: code, location = locale["object"].split() # finding out the language of the locale try: lang = self._get_lang(code) except Language.DoesNotExist: self.log("Locale %s SKIPPED" % code, "font-weight:bold") continue # Locales can be bundled in JARs jarred = location.startswith("jar:") if jarred: # We just care about the JAR path location = location[4:] split_location = location.split("!", 2) # Ignore malformed JAR URIs. if len(split_location) < 2: continue jarname, location = split_location # missing file mentioned if jarname not in self.xpi: continue # may be we have already read this one if jarname in self.jarfiles: package = self.jarfiles[jarname] else: jar = StringIO(self.xpi.read(jarname)) package = XPIManager(jar, mode="r", name=jarname) else: package = self.xpi # and now we read files from there location = location.strip('/') result = {} for f in package.package_contents(): f = f.strip("/") if f.startswith(location) and f != location: result[f.split("/")[-1]] = package.read(f) # file with same name in different jars can get overwritten if lang not in self.locales: self.locales[lang] = result else: self.locales[lang].update(result)
def test_valid_name(): "Test that the manager can retrieve the correct file name" z = XPIManager("tests/resources/xpi/install_rdf_only.xpi") contents = z.package_contents() assert "install.rdf" in contents assert z.test() == False
def test_get_list(): "Test that the manager can read the file listing" z = XPIManager("tests/resources/xpi/install_rdf_only.xpi") assert z.package_contents()