Beispiel #1
0
def _set_metadata(response, **parameters):
    """Generates a standard set of metadata informated by the response.

    Args:
        response: Response
             Response object from requests module
        parameters: unpacked dictionary
            unpacked dictionary of the parameters supplied in the request
    """
    md = set_md(response)
    site_aliases = ['sites', 'site_no']
    for alias in site_aliases:
        if alias in parameters:
            md.site_info = lambda: what_sites(sites=parameters[alias])
            break

    if 'parameterCd' in parameters:
        md.variable_info = lambda: get_pmcodes(parameterCd=parameters[
            'parameterCd'])

    comments = ""
    for line in response.text.splitlines():
        if line.startswith("#"):
            comments += line.lstrip("#") + "\n"
    if comments != "":
        md.comment = comments

    return md
Beispiel #2
0
def set_metadata(response, **parameters):
    md = set_md(response)
    site_aliases = ['sites', 'site_no']
    for alias in site_aliases:
        if alias in parameters:
            md.site_info = lambda: what_sites(sites=parameters[alias])
            break

    if 'parameterCd' in parameters:
        md.variable_info = lambda: get_pmcodes(parameterCd=parameters[
            'parameterCd'])

    comments = ""
    for line in response.text.splitlines():
        if line.startswith("#"):
            comments += line.lstrip("#") + "\n"
    if comments != "":
        md.comment = comments

    return md