Пример #1
0
def substitute_license(name, info):

    if name.startswith("com.digitalasset"):
        # Licenses are not produced for internal packages
        return None

    elif name.startswith("com.daml"):
        # Licenses are not produced for internal packages
        return None

    elif info['licenseUrl'] in licensedata.SBT.keys():
        # Hardcoded license data for projects that don't store the license
        # at a default location.
        return licensedata.SBT[info['licenseUrl']]

    elif name.startswith("ch.qos.logback"):
        return extract.retrieve_url(
            'sbt', name.replace('/', '_'),
            "https://raw.githubusercontent.com/qos-ch/logback/master/LICENSE.txt"
        )

    elif name.startswith("org.scala-sbt # test-interface"):
        return extract.retrieve_url(
            'sbt', name.replace('/', '_'),
            "https://raw.githubusercontent.com/sbt/test-interface/master/LICENSE"
        )

    elif name.startswith("org.checkerframework # checker"):
        return extract.retrieve_url(
            'sbt', name.replace('/', '_'),
            "https://raw.githubusercontent.com/reprogrammer/checker-framework/master/LICENSE.txt"
        )

    elif name.startswith("org.pcollections # pcollections"):
        return extract.retrieve_url(
            'sbt', name.replace('/', '_'),
            "https://raw.githubusercontent.com/hrldcpr/pcollections/master/LICENSE"
        )

    elif name.startswith("org.scalacheck # scalacheck"):
        return extract.retrieve_url(
            'sbt', name.replace('/', '_'),
            "https://raw.githubusercontent.com/rickynils/scalacheck/master/LICENSE"
        )

    else:
        # For the rest, retrieve the license from the URL
        if 'licenseUrl' in info:
            return extract.retrieve_url('sbt', name.replace(' # ', '_'),
                                        info['licenseUrl'])
        else:
            print "license URL missing for %s!" % name
            print "  license info is %s" % info['license']
            sys.exit(1)
Пример #2
0
def substitute_license(name, info):

  if name.startswith("@da/"):
    # Licenses are not produced for internal packages
    return None

  elif name in licensedata.NPM.keys():
    # Hardcoded license data for projects that don't store the license
    # at a default location.
    return licensedata.NPM[name]['text']

  elif name.startswith("@types/"):
    # DefinitelyTyped project is under an MIT license
    return extract.retrieve_url('node', name.replace('/', '_'), "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/LICENSE")

  elif name.startswith("dom-helpers"):
    # dom-helpers project is under an MIT license but need to get from root package
    return extract.retrieve_url('node', name.replace('/', '_'), "https://raw.githubusercontent.com/react-bootstrap/dom-helpers/master/LICENSE")

  elif name.startswith("get-caller-file"):
    return extract.retrieve_url('node', name.replace('/', '_'), "https://raw.githubusercontent.com/stefanpenner/get-caller-file/master/LICENSE.md")

  elif name.startswith("invert-kv"):
    return extract.retrieve_url('node', name.replace('/', '_'), "https://raw.githubusercontent.com/sindresorhus/invert-kv/master/license")

  elif name.startswith("isarray"):
    return extract.read_license(info['path'] + "/" + "README.md")

  elif name.startswith("popper.js"):
    return extract.retrieve_url('node', name.replace('/', '_'), "https://raw.githubusercontent.com/FezVrasta/popper.js/master/docs/LICENSE.txt")

  elif name.startswith("requirejs"):
    return extract.retrieve_url('node', name.replace('/', '_'), "https://raw.githubusercontent.com/requirejs/requirejs/master/LICENSE")


  else:
    # For the rest, retrieve the license using the licenseFile
    filenames = [ 'LICENSE', 'LICENSE.txt', 'LICENSE-MIT.txt',
        'LICENSE-MIT', 'LICENSE.md', 'COPYING', 'COPYING.txt', 'LICENCE',
        'license.txt', 'license', 'README.markdown','LICENSE.BSD' ]
    for filename in filenames:
      path = info['path'] + '/' + filename
      if os.path.isfile(path):
        return extract.read_license(path)

    print "license file missing for %s!" % name
    if 'licenseFile' in info: print "  license info might be available in %s" % info['licenseFile']
    sys.exit(1)