def test_recognize_cpan_manifest_as_plain_package(self):
     test_file = self.get_test_loc('cpan/MANIFEST')
     try:
         recognize_package(test_file)
         self.fail('Exception not raised')
     except NotImplementedError:
         pass
Beispiel #2
0
def get_package_infos(location):
    """
    Return a list of mappings of package information collected from the
    `location` or an empty list.
    """
    from packagedcode.recognize import recognize_package
    package = recognize_package(location)
    if not package:
        return []
    return [package.to_dict()]
Beispiel #3
0
def get_package_infos(location):
    """
    Return a list of mappings of package information collected from the
    `location` or an empty list.
    """
    from packagedcode.recognize import recognize_package
    package = recognize_package(location)
    if not package:
        return []
    return [package.to_dict()]
def get_package_info(location, **kwargs):
    """
    Return a mapping of package manifest information detected in the
    file at `location`.

    Note that all exceptions are caught if there are any errors while parsing a
    package manifest.
    """
    from packagedcode.recognize import recognize_package
    try:
        manifest = recognize_package(location)
        if manifest:
            return dict(packages=[manifest.to_dict()])
    except Exception as e:
        if TRACE:
            logger.error('get_package_info: {}: Exception: {}'.format(location, e))
        pass
    return dict(packages=[])
 def test_recognize_maven_pom_xml(self):
     test_file = self.get_test_loc('maven2/urwerk_pom.xml')
     package = recognize_package(test_file)
     assert isinstance(package, maven.MavenPomPackage)
 def test_recognize_package_iso(self):
     test_file = self.get_test_loc('archives/small.iso')
     package = recognize_package(test_file)
     assert isinstance(package, models.IsoImagePackage)
 def test_recognize_cpan_manifest_is_not_yet_supported(self):
     test_file = self.get_test_loc('cpan/MANIFEST')
     package = recognize_package(test_file)
     assert not package
 def test_recognize_package_rar(self):
     test_file = self.get_test_loc('archives/basic.rar')
     package = recognize_package(test_file)
     assert isinstance(package, models.RarPackage)
 def test_recognize_package_gem(self):
     test_file = self.get_test_loc(
         'archives/mysmallidea-address_standardization-0.4.1.gem')
     package = recognize_package(test_file)
     assert isinstance(package, models.RubyGem)
 def test_recognize_package_deb(self):
     test_file = self.get_test_loc('archives/adduser_3.112ubuntu1_all.deb')
     package = recognize_package(test_file)
     assert isinstance(package, packagedcode.models.DebianPackage)
 def test_recognize_package_rpm(self):
     test_file = self.get_test_loc('archives/alfandega-2.2-2.rh80.src.rpm')
     package = recognize_package(test_file)
     assert isinstance(package, rpm.RpmPackage)
Beispiel #12
0
 def test_recognize_cpan_manifest_as_plain_package(self):
     test_file = self.get_test_loc('cpan/MANIFEST')
     package = recognize_package(test_file)
     assert isinstance(package, packagedcode.models.CpanModule)
 def test_recognize_maven_dot_pom(self):
     test_file = self.get_test_loc('m2/aspectj/aspectjrt/1.5.3/aspectjrt-1.5.3.pom')
     package = recognize_package(test_file)
     assert isinstance(package, maven.MavenPomPackage)
 def test_recognize_package_iso(self):
     test_file = self.get_test_loc('archives/small.iso')
     package = recognize_package(test_file)
     assert isinstance(package, packagedcode.models.IsoImagePackage)
 def test_recognize_package_tarball(self):
     test_file = self.get_test_loc('archives/tarred_bzipped.tar.bz2')
     package = recognize_package(test_file)
     assert isinstance(package, packagedcode.models.TarPackage)
 def test_recognize_package_jar(self):
     test_file = self.get_test_loc('archives/simple.jar')
     package = recognize_package(test_file)
     assert isinstance(package, packagedcode.models.JavaJar)
 def test_recognize_package_gem(self):
     test_file = self.get_test_loc('archives/mysmallidea-address_standardization-0.4.1.gem')
     package = recognize_package(test_file)
     assert isinstance(package, packagedcode.models.RubyGem)
 def test_recognize_package_zip(self):
     test_file = self.get_test_loc('archives/myarch-2.3.0.7z')
     package = recognize_package(test_file)
     assert isinstance(package, packagedcode.models.PlainZipPackage)
 def test_recognize_package_rar(self):
     test_file = self.get_test_loc('archives/basic.rar')
     package = recognize_package(test_file)
     assert isinstance(package, packagedcode.models.RarPackage)
 def test_recognize_maven_pom_xml(self):
     test_file = self.get_test_loc('maven2/urwerk_pom.xml')
     package = recognize_package(test_file)
     assert isinstance(package, maven.MavenPomPackage)
 def test_recognize_package_does_not_recognize_plain_tarball(self):
     test_file = self.get_test_loc('archives/tarred_bzipped.tar.bz2')
     package = recognize_package(test_file)
     assert None == package
 def test_recognize_npm(self):
     test_file = self.get_test_loc('recon/package.json')
     package = recognize_package(test_file)
     assert isinstance(package, npm.NpmPackage)
 def test_recognize_package_deb(self):
     test_file = self.get_test_loc('archives/adduser_3.112ubuntu1_all.deb')
     package = recognize_package(test_file)
     assert isinstance(package, models.DebianPackage)
 def test_recognize_cargo(self):
     test_file = self.get_test_loc('recon/Cargo.toml')
     package = recognize_package(test_file)
     assert isinstance(package, cargo.RustCargoCrate)
 def test_recognize_package_cab(self):
     test_file = self.get_test_loc('archives/basic.cab')
     package = recognize_package(test_file)
     assert isinstance(package, models.CabPackage)
 def test_recognize_composer(self):
     test_file = self.get_test_loc('recon/composer.json')
     package = recognize_package(test_file)
     assert isinstance(package, phpcomposer.PHPComposerPackage)
 def test_recognize_package_zip(self):
     test_file = self.get_test_loc('archives/myarch-2.3.0.7z')
     package = recognize_package(test_file)
     assert isinstance(package, models.PlainZipPackage)
 def test_recognize_freebsd(self):
     test_file = self.get_test_loc('freebsd/multi_license/+COMPACT_MANIFEST')
     package = recognize_package(test_file)
     assert isinstance(package, freebsd.FreeBSDPackage)
 def test_recognize_package_jar(self):
     test_file = self.get_test_loc('archives/simple.jar')
     package = recognize_package(test_file)
     assert isinstance(package, models.JavaJar)
 def test_recognize_package_rpm(self):
     test_file = self.get_test_loc('archives/alfandega-2.2-2.rh80.src.rpm')
     package = recognize_package(test_file)
     assert isinstance(package, rpm.RpmPackage)
 def test_recognize_package_tarball(self):
     test_file = self.get_test_loc('archives/tarred_bzipped.tar.bz2')
     package = recognize_package(test_file)
     assert isinstance(package, models.TarPackage)
 def test_recognize_composer(self):
     test_file = self.get_test_loc('recon/composer.json')
     package = recognize_package(test_file)
     assert isinstance(package, phpcomposer.PHPComposerPackage)
 def test_recognize_maven_dot_pom(self):
     test_file = self.get_test_loc(
         'm2/aspectj/aspectjrt/1.5.3/aspectjrt-1.5.3.pom')
     package = recognize_package(test_file)
     assert isinstance(package, maven.MavenPomPackage)
 def test_recognize_package_zip(self):
     test_file = self.get_test_loc('archives/myarch-2.3.0.7z')
     package = recognize_package(test_file)
     assert None == package
 def test_recognize_nuget(self):
     test_file = self.get_test_loc('recon/bootstrap.nuspec')
     package = recognize_package(test_file)
     assert isinstance(package, nuget.NugetPackage)
 def test_recognize_package_cab(self):
     test_file = self.get_test_loc('archives/basic.cab')
     package = recognize_package(test_file)
     assert isinstance(package, packagedcode.models.CabPackage)
 def test_recognize_package_rar(self):
     test_file = self.get_test_loc('archives/basic.rar')
     package = recognize_package(test_file)
     assert None == package
 def test_recognize_npm(self):
     test_file = self.get_test_loc('recon/package.json')
     package = recognize_package(test_file)
     assert isinstance(package, npm.NpmPackage)