Esempio n. 1
0
def awards_grants_honors(p):
    """Make sorted awards grants and honors list.

    Parameters
    ----------
    p : dict
        The person entry
    """
    aghs = []
    for x in p.get('funding', ()):
        d = {'description': '{0} ({1}{2:,})'.format(
            latex_safe(x['name']),
            x.get('currency', '$').replace('$', '\$'), x['value']),
            'year': x['year'],
            '_key': date_to_float(x['year'], x.get('month', 0)),
        }
        aghs.append(d)
    for x in p.get('service', []) + p.get('honors', []):
        d = {'description': latex_safe(x['name']), }
        if 'year' in x:
            d.update({'year': x['year'],
                      '_key': date_to_float(x['year'],
                                            x.get('month', 0))})
        elif 'begin_year' in x and 'end_year' in x:
            d.update({'year': '{}-{}'.format(x['begin_year'], x['end_year']),
                      '_key': date_to_float(x['begin_year'],
                                            x.get('month', 0))})
        elif 'begin_year' in x:
            d.update({'year': '{}'.format(x['begin_year']),
                      '_key': date_to_float(x['begin_year'],
                                            x.get('month', 0))})
        aghs.append(d)
    aghs.sort(key=(lambda x: x.get('_key', 0.0)), reverse=True)
    return aghs
Esempio n. 2
0
def date_key(x):
    if "end_year" in x:
        v = date_to_float(x["end_year"], x.get("end_month", "jan"),
                          x.get("end_day", 0))
    elif "year" in x:
        v = date_to_float(x["year"], x.get("month", "jan"), x.get("day", 0))
    elif "begin_year" in x:
        v = date_to_float(x["begin_year"], x.get("begin_month", "jan"),
                          x.get("begin_day", 0))
    else:
        raise KeyError("could not find year in " + str(x))
    return v
Esempio n. 3
0
def date_key(x):
    if 'end_year' in x:
        v = date_to_float(x['end_year'], x.get('end_month', 'jan'),
                          x.get('end_day', 0))
    elif 'year' in x:
        v = date_to_float(x['year'], x.get('month', 'jan'), x.get('day', 0))
    elif 'begin_year' in x:
        v = date_to_float(x['begin_year'], x.get('begin_month', 'jan'),
                          x.get('begin_day', 0))
    else:
        raise KeyError('could not find year in ' + str(x))
    return v
Esempio n. 4
0
def awards_grants_honors(p):
    """Make sorted awards grants and honors list.

    Parameters
    ----------
    p : dict
        The person entry
    """
    aghs = []
    for x in p.get("funding", ()):
        d = {
            "description": "{0} ({1}{2:,})".format(
                latex_safe(x["name"]),
                x.get("currency", "$").replace("$", "\$"),
                x["value"],
            ),
            "year": x["year"],
            "_key": date_to_float(x["year"], x.get("month", 0)),
        }
        aghs.append(d)
    for x in p.get("service", []) + p.get("honors", []):
        d = {"description": latex_safe(x["name"])}
        if "year" in x:
            d.update(
                {"year": x["year"],
                 "_key": date_to_float(x["year"], x.get("month", 0))}
            )
        elif "begin_year" in x and "end_year" in x:
            d.update(
                {
                    "year": "{}-{}".format(x["begin_year"], x["end_year"]),
                    "_key": date_to_float(x["begin_year"], x.get("month", 0)),
                }
            )
        elif "begin_year" in x:
            d.update(
                {
                    "year": "{}".format(x["begin_year"]),
                    "_key": date_to_float(x["begin_year"], x.get("month", 0)),
                }
            )
        aghs.append(d)
    aghs.sort(key=(lambda x: x.get("_key", 0.0)), reverse=True)
    return aghs
Esempio n. 5
0
"""Builder for websites."""
import string

from regolith.dates import date_to_float

doc_date_key = lambda x: date_to_float(x.get("year", 1970),
                                       x.get("month", "jan"))
ene_date_key = lambda x: date_to_float(x.get("end_year", 4242),
                                       x.get("end_month", "dec"))
category_val = lambda x: x.get("category", "<uncategorized>")
level_val = lambda x: x.get("level", "<no-level>")
id_key = lambda x: x.get("_id", "")


def date_key(x):
    if "end_year" in x:
        v = date_to_float(x["end_year"], x.get("end_month", "jan"),
                          x.get("end_day", 0))
    elif "year" in x:
        v = date_to_float(x["year"], x.get("month", "jan"), x.get("day", 0))
    elif "begin_year" in x:
        v = date_to_float(x["begin_year"], x.get("begin_month", "jan"),
                          x.get("begin_day", 0))
    else:
        raise KeyError("could not find year in " + str(x))
    return v


POSITION_LEVELS = {
    "": -1,
    "editor": -1,
Esempio n. 6
0
def test_date_to_float(input, expected):
    assert date_to_float(input[0], input[1], d=input[2]) == expected
Esempio n. 7
0
"""Builder for websites."""
import string

from regolith.dates import date_to_float

doc_date_key = lambda x: date_to_float(x.get('year', 1970),
                                       x.get('month', 'jan'))
ene_date_key = lambda x: date_to_float(x.get('end_year', 4242),
                                       x.get('end_month', 'dec'))
category_val = lambda x: x.get('category', '<uncategorized>')
level_val = lambda x: x.get('level', '<no-level>')
id_key = lambda x: x.get('_id', '')


def date_key(x):
    if 'end_year' in x:
        v = date_to_float(x['end_year'], x.get('end_month', 'jan'),
                          x.get('end_day', 0))
    elif 'year' in x:
        v = date_to_float(x['year'], x.get('month', 'jan'), x.get('day', 0))
    elif 'begin_year' in x:
        v = date_to_float(x['begin_year'], x.get('begin_month', 'jan'),
                          x.get('begin_day', 0))
    else:
        raise KeyError('could not find year in ' + str(x))
    return v


POSITION_LEVELS = {
    '': -1,
    'undergraduate research assistant': 1,