Esempio n. 1
0
 def _get_license_dict(self, files):
     result = []
     for f in files:
         try:
             # once DB full, remove license path
             try:
                 license_path = helper.get_sources_path(session,
                                                        f['package'],
                                                        f['version'],
                                                        current_app.config)
             except (FileOrFolderNotFound, InvalidPackageOrVersionError):
                 raise Http404ErrorSuggestions(f['package'], f['version'],
                                               '')
             l = helper.get_license(session, f['package'],
                                    f['version'], f['path'], license_path)
             result.append(dict(oracle='debian',
                                path=f['path'],
                                package=f['package'],
                                version=f['version'],
                                license=l,
                                origin=helper.license_url(f['package'],
                                                          f['version'])))
         except Exception:
             result.append(dict(oracle='debian',
                                path=f['path'],
                                package=f['package'],
                                version=f['version'],
                                license=None,
                                origin=helper.license_url(f['package'],
                                                          f['version'])))
     return result
Esempio n. 2
0
 def _get_license_dict(self, files):
     result = []
     for f in files:
         try:
             # once DB full, remove license path
             try:
                 license_path = helper.get_sources_path(
                     session, f['package'], f['version'],
                     current_app.config)
             except (FileOrFolderNotFound, InvalidPackageOrVersionError):
                 raise Http404ErrorSuggestions(f['package'], f['version'],
                                               '')
             l = helper.get_license(session, f['package'], f['version'],
                                    f['path'], license_path)
             result.append(
                 dict(oracle='debian',
                      path=f['path'],
                      package=f['package'],
                      version=f['version'],
                      license=l,
                      origin=helper.license_url(f['package'],
                                                f['version'])))
         except Exception:
             result.append(
                 dict(oracle='debian',
                      path=f['path'],
                      package=f['package'],
                      version=f['version'],
                      license=None,
                      origin=helper.license_url(f['package'],
                                                f['version'])))
     return result
Esempio n. 3
0
 def emit_license(out, package, version, relpath, copyright):
     """Retrieve license of the file. We use `relpath` as we want the path
     inside the package directory which is used in the d/copyright files
     paragraphs
     """
     synopsis = helper.get_license(package, version, relpath, copyright)
     if synopsis is not None:
         s = b"%s\t%s\n" % (synopsis.encode("utf8"), relpath)
         out.write(s)
Esempio n. 4
0
 def emit_license(out, package, version, relpath, copyright):
     """ Retrieve license of the file. We use `relpath` as we want the path
         inside the package directory which is used in the d/copyright files
         paragraphs
     """
     synopsis = helper.get_license(package, version, relpath, copyright)
     if synopsis is not None:
         s = '%s\t%s\n' % (synopsis, relpath.decode('utf-8'))
         out.write(s)
Esempio n. 5
0
 def emit_license(out, session, package, version, relpath, pkgdir):
     """ Retrieve license of the file. We use `relpath` as we want the path
         inside the package directory which is used in the d/copyright files
         paragraphs
     """
     # join path for debian/copyright file as we are already in the sources
     # directory.
     synopsis = helper.get_license(session, package, version, relpath,
                                   os.path.join(pkgdir, 'debian/copyright'))
     if synopsis is not None:
         s = '%s\t%s\n' % (synopsis, relpath.decode('utf-8'))
         out.write(s)
Esempio n. 6
0
 def _license_of_files(self, f):
     # once DB full, remove license path
     try:
         license_path = helper.get_sources_path(session, f.package,
                                                f.version,
                                                current_app.config)
     except (FileOrFolderNotFound, InvalidPackageOrVersionError):
         raise Http404ErrorSuggestions(f.package, f.version, '')
     return dict(oracle='debian',
                 path=f.path,
                 package=f.package,
                 version=f.version,
                 license=helper.get_license(session, f.package, f.version,
                                            f.path, license_path),
                 origin=helper.license_url(f.package, f.version))
Esempio n. 7
0
 def _license_of_files(self, f):
     # once DB full, remove license path
     try:
         license_path = helper.get_sources_path(session, f.package,
                                                f.version,
                                                current_app.config)
     except (FileOrFolderNotFound, InvalidPackageOrVersionError):
         raise Http404ErrorSuggestions(f.package, f.version, '')
     return dict(oracle='debian',
                 path=f.path,
                 package=f.package,
                 version=f.version,
                 license=helper.get_license(session, f.package,
                                            f.version, f.path,
                                            license_path),
                 origin=helper.license_url(f.package, f.version))
Esempio n. 8
0
    def _license_of_files(self, f):
        # once DB full, remove license path
        try:
            license_path = helper.get_sources_path(session, f.package,
                                                   f.version,
                                                   current_app.config)
        except (FileOrFolderNotFound, InvalidPackageOrVersionError):
            raise Http404ErrorSuggestions(f.package, f.version, '')

        try:
            c = helper.parse_license(license_path)
            l = helper.get_license(f.package, f.version, f.path, c)
        except copyright.NotMachineReadableError:
            l = None
        return dict(oracle='debian',
                    path=f.path,
                    package=f.package,
                    version=f.version,
                    license=l,
                    origin=helper.license_url(f.package, f.version))
Esempio n. 9
0
    def _license_of_files(self, f):
        # once DB full, remove license path
        try:
            license_path = helper.get_sources_path(session, f.package,
                                                   f.version,
                                                   current_app.config)
        except (FileOrFolderNotFound, InvalidPackageOrVersionError):
            raise Http404ErrorSuggestions(f.package, f.version, '')

        try:
            c = helper.parse_license(license_path)
            l = helper.get_license(f.package, f.version, f.path, c)
        except copyright.NotMachineReadableError:
            l = None
        return dict(oracle='debian',
                    path=f.path,
                    package=f.package,
                    version=f.version,
                    license=l,
                    origin=helper.license_url(f.package, f.version))
Esempio n. 10
0
 def _get_license_dict(self, files):
     result = []
     for f in files:
         try:
             # once DB full, remove license path
             try:
                 license_path = helper.get_sources_path(
                     session, f["package"], f["version"],
                     current_app.config)
             except (FileOrFolderNotFound, InvalidPackageOrVersionError):
                 raise Http404ErrorSuggestions(f["package"], f["version"],
                                               "")
             # parse file
             try:
                 c = helper.parse_license(license_path)
                 license = helper.get_license(f["package"], f["version"],
                                              f["path"], c)
             except copyright.NotMachineReadableError:
                 license = None
             result.append(
                 dict(
                     oracle="debian",
                     path=f["path"],
                     package=f["package"],
                     version=f["version"],
                     license=license,
                     origin=helper.license_url(f["package"], f["version"]),
                 ))
         except Exception:
             result.append(
                 dict(
                     oracle="debian",
                     path=f["path"],
                     package=f["package"],
                     version=f["version"],
                     license=None,
                     origin=helper.license_url(f["package"], f["version"]),
                 ))
     return result