Ejemplo n.º 1
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
Ejemplo 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
Ejemplo n.º 3
0
 def awards_grants_honors(self, p):
     """Make sorted awards grants and honrs list."""
     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']), 
              'year': x['year'],
              '_key': date_to_float(x['year'], x.get('month', 0)),
              }
         aghs.append(d)
     aghs.sort(key=(lambda x: x.get('_key', 0.0)), reverse=True)
     return aghs
Ejemplo n.º 4
0
 def awards_grants_honors(self, p):
     """Make sorted awards grants and honrs list."""
     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']),
             'year': x['year'],
             '_key': date_to_float(x['year'], x.get('month', 0)),
         }
         aghs.append(d)
     aghs.sort(key=(lambda x: x.get('_key', 0.0)), reverse=True)
     return aghs
Ejemplo n.º 5
0
"""Builder for websites."""
import os
from itertools import groupby
import string

from regolith.tools import all_docs_from_collection, date_to_float, date_to_rfc822, \
    rfc822now

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

Ejemplo n.º 6
0
import shutil
from itertools import groupby

from jinja2 import Environment, FileSystemLoader
try:
    from bibtexparser.bwriter import BibTexWriter
    from bibtexparser.bibdatabase import BibDatabase
    HAVE_BIBTEX_PARSER = True
except ImportError:
    HAVE_BIBTEX_PARSER = False

from regolith.tools import all_docs_from_collection, date_to_float, date_to_rfc822, \
    rfc822now


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', 1970), x.get('end_month', 'jan'))
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))