How to use the pybliometrics.scopus.utils.config.has_option function in pybliometrics

To help you get started, we’ve selected a few pybliometrics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pybliometrics-dev / pybliometrics / pybliometrics / scopus / utils / get_content.py View on Github external
ValueError
        If the accept parameter is not one of the accepted values.

    Returns
    -------
    resp : byte-like object
        The content of the file, which needs to be serialized.
    """
    # Get credentials and set request headers
    key = config.get('Authentication', 'APIKey')
    header = {
        'X-ELS-APIKey': key,
        'Accept': 'application/json',
        'User-Agent': user_agent
        }
    if config.has_option('Authentication', 'InstToken'):
        token = config.get('Authentication', 'InstToken')
        header.update({'X-ELS-APIKey': key, 'X-ELS-Insttoken': token})
    # Perform request
    params.update(**kwds)
    # If config.ini has a section as follows:
    #
    # [Proxy]
    # https = protocol://server:port
    #
    # it uses a proxy as defined
    # see requests documentation for details
    if config.has_section("Proxy"):
        proxyDict = dict(config.items("Proxy"))
        resp = requests.get(url, headers=header, proxies=proxyDict, params=params)
    else:
        resp = requests.get(url, headers=header, params=params)