Ejemplo n.º 1
0
def gen_ki_menu():
    """
    Generate a menu for restaurants at KI
    """
    output = ""
    output += "\n".join(page_start(ps.get_weekday(), str(ps.get_day()), ps.get_month()))
    output += activate_parsers(KI, REST_DATA)
    output += "\n".join(page_end())
    return output
Ejemplo n.º 2
0
def gen_uu_menu():
    """
    Generate a menu for restaurants at UU
    """
    output = ""
    output += "\n".join(page_start(ps.get_weekday(), str(ps.get_day()), ps.get_month()))
    output += activate_parsers(UU, REST_DATA)
    output += "\n".join(page_end())

    sys.stderr.write(output + "\n")
    return output
Ejemplo n.º 3
0
def gen_uu_menu():
    '''
    Generate a menu for restaurants at UU
    '''
    output = ''
    output += '\n'.join(
        page_start(ps.get_weekday(), str(ps.get_day()), ps.get_month()))
    output += activate_parsers(UU, REST_DATA)
    output += '\n'.join(page_end())

    sys.stderr.write(output + '\n')
    return output
Ejemplo n.º 4
0
def gen_ki_menu():
    '''
    Generate a menu for restaurants at KI
    '''
    restaurant_data = read_restaurants(open(REST_FILENAME).read())
    rest_names = [x[0] for x in MAPPER[:11]]

    output = ''
    output += '\n'.join(
        page_start(ps.get_weekday(), str(ps.get_day()), ps.get_month()))
    output += activate_parsers(rest_names, restaurant_data)
    output += '\n'.join(page_end())
    return output
Ejemplo n.º 5
0
    sys.stderr.write(output + "\n")
    return output


if __name__ == "__main__":
    if len(sys.argv) < 2 or "-h" in sys.argv:
        print_usage(KI + UU)
        sys.exit()

    REST_NAMES_IN = tuple()
    if "all" in sys.argv[1:]:
        REST_NAMES_IN += KI + UU
    elif "ki" in sys.argv[1:]:
        REST_NAMES_IN += KI
    elif "uu" in sys.argv[1:]:
        REST_NAMES_IN += UU
    else:
        REST_NAMES_IN = [param for param in sys.argv[1:] if param != "-r"]

    try:
        REST_NAMES = parse_restaurant_names(REST_NAMES_IN)
    except ValueError as err:
        sys.stderr.write("E: {}\n".format(err))
        print_usage((x for x in MAPPER))
        sys.exit(1)

    # print the menus
    print("\n".join(page_start(ps.get_weekday(), str(ps.get_day()), ps.get_month())))
    print(activate_parsers(REST_NAMES, REST_DATA))
    print("\n".join(page_end()))
Ejemplo n.º 6
0
    return output


if __name__ == '__main__':
    if len(sys.argv) < 2 or '-h' in sys.argv:
        print_usage(KI + UU)
        sys.exit()

    REST_NAMES_IN = tuple()
    if 'all' in sys.argv[1:]:
        REST_NAMES_IN += KI + UU
    elif 'ki' in sys.argv[1:]:
        REST_NAMES_IN += KI
    elif 'uu' in sys.argv[1:]:
        REST_NAMES_IN += UU
    else:
        REST_NAMES_IN = [param for param in sys.argv[1:] if param != '-r']

    try:
        REST_NAMES = parse_restaurant_names(REST_NAMES_IN)
    except ValueError as err:
        sys.stderr.write('E: {}\n'.format(err))
        print_usage((x for x in MAPPER))
        sys.exit(1)

    # print the menus
    print('\n'.join(
        page_start(ps.get_weekday(), str(ps.get_day()), ps.get_month())))
    print(activate_parsers(REST_NAMES, REST_DATA))
    print('\n'.join(page_end()))
Ejemplo n.º 7
0
def gen_uu_menu():
    '''
    Generate a menu for restaurants at UU
    '''
    restaurant_data = read_restaurants(open(REST_FILENAME).read())
    rest_names = [x[0] for x in MAPPER[11:]]

    date = ps.fix_for_html(ps.get_weekday().capitalize() + ' ' + str(ps.get_day()) + ' ' + str(ps.get_month()))
    output = ''
    output += '\n'.join(page_start("Dagens mat - {}".format(date)))
    output += activate_parsers(rest_names, restaurant_data)
    output += '\n'.join(page_end())

    sys.stderr.write(output)
    return output
Ejemplo n.º 8
0
    for line in intext.split('\n'):
        if not line or line[0] == '#':
            continue
        restaurants.append(line.rstrip().split('\t'))
    return restaurants


if __name__ == '__main__':
    if len(sys.argv) < 2 or '-h' in sys.argv:
        print_usage((x[0] for x in MAPPER))
        sys.exit()

    RESTAURANT_DATA = read_restaurants(open(REST_FILENAME).read())
    if 'all' in sys.argv[1:]:
        REST_NAMES_IN = (x[0] for x in MAPPER)
    else:
        REST_NAMES_IN = [param for param in sys.argv[1:] if param != '-r']

    try:
        REST_NAMES = parse_restaurant_names(REST_NAMES_IN)
    except ValueError as err:
        sys.stderr.write('E: {}'.format(err))
        print_usage((x[0] for x in MAPPER))
        sys.exit(1)

    # print the menus
    date = ps.fix_for_html(ps.get_weekday().capitalize() + ' ' + str(ps.get_day()) + ' ' + str(ps.get_month()))
    print('\n'.join(page_start("Dagens mat - {}".format(date))))
    print(activate_parsers(REST_NAMES, RESTAURANT_DATA))
    print('\n'.join(page_end()))