Ejemplo n.º 1
0
def parse_and_sort_unicode_piecemeal():
    items = []
    filename = Settings().get_timelog_file()
    for line in open(filename, 'rb'):
        time, sep, entry = line.partition(b': ')
        if not sep:
            continue
        try:
            time = parse_datetime(time.decode('ASCII'))
        except (ValueError, UnicodeError):
            continue
        entry = entry.strip().decode('UTF-8')
        items.append((time, entry))
    items.sort(key=itemgetter(0))
    return items
Ejemplo n.º 2
0
 def _build_line(line, time, place):
     return "{} - in {} minutes - to {}".format(line.decode('latin-1'),
                                                time.decode('latin-1'),
                                                place.decode('latin-1'))