示例#1
0
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"
示例#2
0
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
示例#3
0
文件: model.py 项目: coryb/setupmeta
 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)
示例#4
0
 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)