From 971f633eaadec381bda398f024bab42fa1311bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20P=C3=A9rez-Cerezo?= Date: Tue, 18 Sep 2018 00:37:18 +0200 Subject: added templating, Version 0.4.1 You can now use templating by creating a file containing "$$TEXT$$" somewhere. $$TEXT$$ will be replaced with the menu. --- bin/mensa | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/mensa b/bin/mensa index 3648607..a6537e7 100755 --- a/bin/mensa +++ b/bin/mensa @@ -3,6 +3,7 @@ import argparse from mensa import logic from mensa import base +import os parser = argparse.ArgumentParser(description='Fetch menus from various sources') parser.add_argument('rest', nargs="*", @@ -14,6 +15,7 @@ parser.add_argument('-f', '--formatter', dest='form', action='store', nargs=1, h parser.add_argument('-p', '--pos', dest='pos', action='store', nargs=1, help="Your current position") parser.add_argument('-d', '--dist', dest='dist', action='store_true', help="Show distances to restaurants") parser.add_argument('-r', '--radius', dest='rad', action='store', nargs=1, help="Radius to find restaurants in") +parser.add_argument('-t', '--template', dest='template', action='store', nargs=1, help="Template file to use") parser.add_argument('-g', '--vegetarian', dest='vegetarian', action='store_true', help='show only vegetarian meals') parser.add_argument('-G', '--vegan', dest='vegan', action='store_true', @@ -59,6 +61,11 @@ if args.vegetarian : if args.vegan : veggie = 2 +if args.template : + args.template = os.path.expanduser(args.template[0]) + if not os.path.exists(args.template) : + print("File not found: " + os.path.expanduser(args.template)) + exit(1) if args.list : @@ -70,4 +77,4 @@ if args.rest : restlist = args.rest foodl = logic.get_food(restlist, no_parallel=args.no_parallel, pos=args.pos, rad=args.rad, only_student_prices=args.student) -logic.render(foodl, form, only_veggie=veggie, only_student_prices=args.student, pos=args.pos, dist=args.dist) +logic.render(foodl, form, only_veggie=veggie, only_student_prices=args.student, pos=args.pos, dist=args.dist, template=args.template) -- cgit v1.2.3