def test_license(): assert license.determined_license(None) is None assert license.determined_license("") is None assert license.determined_license("blah blah version 5") is None assert license.determined_license("... Version 2.0 http://www.apache.org/licenses/ ...") == "Apache 2.0" assert license.determined_license(BSD_SAMPLE) == "BSD" assert license.determined_license("MIT License ...") == "MIT" assert license.determined_license("Mozilla Public License Version 2.0 ...") == "MPL" assert license.determined_license("GNU AFFERO GENERAL PUBLIC LICENSE Version 3 ...") == "AGPLv3" assert license.determined_license("GNU GENERAL PUBLIC LICENSE Version 3 ...") == "GPLv3" assert license.determined_license("GNU LESSER GENERAL PUBLIC LICENSE Version 3 ...") == "LGPLv3"
def check_license(sample, short, classifier): s, c = license.determined_license(sample) assert s == short if classifier: assert c == "License :: OSI Approved :: %s" % classifier else: assert c is None
def auto_fill_license(self, key='license'): """ Try to auto-determine the license """ contents, _ = find_contents(['LICENSE*'], limit=20) short, classifier = determined_license(contents) if short: self.auto_fill('license', short) classifiers = self.value('classifiers') if classifiers and isinstance(classifiers, list): if classifier not in classifiers: classifiers.append(classifier)
def auto_fill_license(self, key="license"): """ Try to auto-determine the license """ contents, _ = find_contents(["LICENSE*"], limit=20) short = determined_license(contents) if short: self.auto_fill("license", short)