From 99316030cbc945cecce7d07f7b2efe4c1702d6d1 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 13 Dec 2015 11:54:56 -0500 Subject: lps_gen: introduced main() main() reads a markdown version of LP schedule, converts it into a python dictionary and stdouts the json version of the python dictionary. --- lps_gen.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lps_gen.py') diff --git a/lps_gen.py b/lps_gen.py index c90260a..657b030 100644 --- a/lps_gen.py +++ b/lps_gen.py @@ -18,6 +18,9 @@ # along with lpschedule-generator (see COPYING). If not, see # . +import json + +from argparse import ArgumentParser from collections import OrderedDict from os import path @@ -128,3 +131,21 @@ class LPSMarkdown(Markdown): lps_dict = OrderedDict() html = super(LPSMarkdown, self).parse(text) return lps_dict + + +def main(): + parser = ArgumentParser() + parser.add_argument("lps_md", + help="Path to the markdown version of LP Schedule.") + args = parser.parse_args() + + lps_md_content = read_file(path.abspath(args.lps_md)) + + markdown = LPSMarkdown() + lps_dict = markdown(lps_md_content) + + print json.dumps(lps_dict, indent=4) + + +if __name__ == "__main__": + main() -- cgit v1.2.3