コード例 #1
0
ファイル: literature.py プロジェクト: tsgit/inspire-schemas
    def add_license(self,
                    url=None,
                    license=None,
                    material=None,
                    imposing=None):
        """Add license.

        :param url: url for the description of the license
        :type url: string

        :param license: license type
        :type license: string

        :param material: material type
        :type material: string

        :param imposing: imposing type
        :type imposing: string
        """
        hep_license = {}

        try:
            license_from_url = get_license_from_url(url)
            if license_from_url is not None:
                license = license_from_url
        except ValueError:
            pass

        for key in ('url', 'license', 'material', 'imposing'):
            if locals()[key] is not None:
                hep_license[key] = locals()[key]

        self._append_to('license', hep_license)
コード例 #2
0
def test_get_license_from_url_handles_arxiv():
    expected = 'arXiv nonexclusive-distrib 1.0'
    url = 'http://arxiv.org/licenses/nonexclusive-distrib/1.0/'
    assert utils.get_license_from_url(url) == expected
コード例 #3
0
def test_get_license_from_url_handles_CC_public_domain_no_match():
    url = 'http://creativecommons.org/publicdomain/nomatch'
    assert utils.get_license_from_url(url) == 'public domain'
コード例 #4
0
def test_get_license_from_url_handles_CC_public_domain():
    url = 'http://creativecommons.org/publicdomain/zero/1.0/'
    assert utils.get_license_from_url(url) == 'CC0 1.0'
コード例 #5
0
def test_get_license_from_url_handles_CC():
    url = 'http://creativecommons.org/licenses/by-nc/4.0/'
    assert utils.get_license_from_url(url) == 'CC BY-NC 4.0'
コード例 #6
0
def test_get_license_from_url_raises_when_unknown_url():
    with pytest.raises(ValueError):
        utils.get_license_from_url('http://www.example.com')
コード例 #7
0
def test_get_license_from_url_handles_none():
    assert utils.get_license_from_url(None) is None