summaryrefslogtreecommitdiff
path: root/src/flufigut.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/flufigut.py')
-rwxr-xr-xsrc/flufigut.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/flufigut.py b/src/flufigut.py
index 611764c..272dbee 100755
--- a/src/flufigut.py
+++ b/src/flufigut.py
@@ -29,9 +29,10 @@
import string
import random
+import os
import sys
import yaml
-# from jinja2 import Environment, FileSystemLoader
+import jinja2
# helper functions ############################################
#
@@ -476,6 +477,15 @@ class Planet:
self._generate_records()
return self._unassigned_components
+ def toXML(self, template_dir, output_file):
+ loader = jinja2.FileSystemLoader(os.path.join(template_dir, self._desc.globals['templates']))
+ env = jinja2.Environment(loader=loader, line_statement_prefix='%%')
+ template = env.get_template('planet.xml')
+ planet_xml = template.render(globals=self._desc.globals, atmosphere=self.atmosphere, flow=self.flow)
+
+ with open(output_file, 'wb') as f:
+ f.write(planet_xml.encode("utf8"))
+ f.write(b'\n')
# Main ########################################################
#
@@ -503,6 +513,7 @@ if __name__ == '__main__':
print("- " + c)
sys.exit(1)
+ p.toXML('../templates/flumotion/', 'output/planet.xml')
print("****************************************************")
print("** atmosphere **")
print("**")