From 533fbfa6abbfa791ced8bba2acf9450bfc12fccf Mon Sep 17 00:00:00 2001 From: equinox Date: Fri, 14 Sep 2012 18:09:55 +0000 Subject: 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 --- src/flufig.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') 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 +# Michael Gebetsroither # # 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")) -- cgit v1.2.3