summaryrefslogtreecommitdiff
path: root/src/flufig.py
diff options
context:
space:
mode:
authorequinox <equinox@88d0365b-309c-4eec-8061-d8e0c04ad69e>2012-09-14 18:09:55 +0000
committerequinox <equinox@88d0365b-309c-4eec-8061-d8e0c04ad69e>2012-09-14 18:09:55 +0000
commit533fbfa6abbfa791ced8bba2acf9450bfc12fccf (patch)
tree76dfd56ad0a84b0aeb6da0f3fd63a1bd7afa0c1b /src/flufig.py
parentinitial checkin (diff)
added json parsing
changed to GPLv2 or later added gebi as author git-svn-id: https://svn.spreadspace.org/flufigut/trunk@3 88d0365b-309c-4eec-8061-d8e0c04ad69e
Diffstat (limited to 'src/flufig.py')
-rwxr-xr-xsrc/flufig.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/flufig.py b/src/flufig.py
index c2c58c7..ea1a4fa 100755
--- a/src/flufig.py
+++ b/src/flufig.py
@@ -5,16 +5,17 @@
# flufig is a simple flumotion configuration generator using
# pyhton jinja2 template engine and simplejson. flufig generates
# planet.xml and worker.xml files from configuration templates and
-# a easy representation of the flow structure written in json.
+# an easy representation of the flow structure written in json.
#
#
# Copyright (C) 2012 Christian Pointner <equinox@spreadspace.org>
+# Michael Gebetsroither <michael@mgeb.org>
#
# This file is part of flufig.
#
# flufig is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
+# the Free Software Foundation, either version 2 of the License, or
# any later version.
#
# flufig is distributed in the hope that it will be useful,
@@ -27,15 +28,18 @@
#
import sys
+import simplejson as json
from exceptions import *
from jinja2 import Environment, FileSystemLoader
if len(sys.argv) <= 2:
raise SystemExit("No template and or data file given")
-data = [];
+df = open(sys.argv[2], 'r')
+data = json.load(df);
+df.close();
env = Environment(loader=FileSystemLoader('../templates/%s/' % (sys.argv[1])))
template = env.get_template('planet.xml')
-planet = template.render(data)
+planet = template.render(globals=data['globals'], atmosphere=data['atmosphere'], flow=data['flow'])
sys.stdout.write(planet.encode("utf8"))