Get OA policy for a given DOI.

    .. note::

        Uses beta.dissem.in API.

    :param doi: A canonical DOI.
    :returns: The OpenAccess policy for the associated publications, or \
            ``None`` if unknown.

    >>> tmp = get_oa_policy('10.1209/0295-5075/111/40005'); (tmp["published"], tmp["preprint"], tmp["postprint"], tmp["romeo_id"])
    ('can', 'can', 'can', '1896')

    >>> get_oa_policy('10.1215/9780822387268') is None
    True

def get_oa_policy(doi):
    """
    Get OA policy for a given DOI.

    .. note::

        Uses beta.dissem.in API.

    :param doi: A canonical DOI.
    :returns: The OpenAccess policy for the associated publications, or \
            ``None`` if unknown.

    >>> tmp = get_oa_policy('10.1209/0295-5075/111/40005'); (tmp["published"], tmp["preprint"], tmp["postprint"], tmp["romeo_id"])
    ('can', 'can', 'can', '1896')

    >>> get_oa_policy('10.1215/9780822387268') is None
    True
    """
    try:
        request = requests.get("%s%s" % (DISSEMIN_API, doi))
        request.raise_for_status()
        result = request.json()
        assert result["status"] == "ok"
        return ([i
                 for i in result["paper"]["publications"]
                 if i["doi"] == doi][0])["policy"]
    except (AssertionError, ValueError,
            KeyError, RequestException, IndexError):
        return None