entrypoint.py 1.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
from django.template import loader
import requests
import json
import xml.etree.ElementTree as ET
import filelevel
from landingpage.handle import retrieval, cmip6parser


def get_html_string(request, prefix, suffix):
    json_record = retrieval.get_handle_record_json(prefix+'/'+suffix)
11
12
    context = _get_context_for_aggregation_level(json_record)
    template = _get_template_for_aggregation_level(json_record)
13
14
15

    return template.render(context, request)

16
17
def _get_template_for_aggregation_level(json_record):
    if cmip6parser.is_file(json_record):
18
        return filelevel.get_template()
19
    elif cmip6parser.is_dataset(json_record):
20
21
22
23
24
        return loader.get_template('landingpage/cmip6_dataset.html') # TODO
    else:
        return loader.get_template('landingpage/cmip6_fallback.html') # TODO


25
26
def _get_context_for_aggregation_level(json_record):
    if cmip6parser.is_file(json_record):
27
        return filelevel.get_context(json_record)
28
    elif cmip6parser.is_dataset(json_record):
29
30
31
32
33
34
35
36
37
38
39
        return _get_handle_info_for_dataset(json_record) # TODO
    else:
        return _get_dict_generic(json_record) # TODO


def _get_handle_info_for_dataset(values):
    return {}

def _get_dict_generic(values):
    return {}