summaryrefslogtreecommitdiffstats
path: root/lps_gen.py
diff options
context:
space:
mode:
authorrsiddharth <rsd@gnu.org>2015-12-13 11:54:56 -0500
committerrsiddharth <rsd@gnu.org>2015-12-13 11:54:56 -0500
commit99316030cbc945cecce7d07f7b2efe4c1702d6d1 (patch)
tree62b90539631d4a6ee3d200618b5dff49f075cfe1 /lps_gen.py
parent8c9ac2143c367dd54bafc8bbce4bbf50a2066288 (diff)
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.
Diffstat (limited to 'lps_gen.py')
-rw-r--r--lps_gen.py21
1 files changed, 21 insertions, 0 deletions
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
# <http://www.gnu.org/licenses/>.
+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()