move output file opening to backend
Different backends have different requirements.
diff --git a/lang_python.py b/lang_python.py
index 639cf1a..2dd57b5 100644
--- a/lang_python.py
+++ b/lang_python.py
@@ -61,6 +61,8 @@
"ofp.OFPP_NONE".
"""
+import os
+import loxi_utils.loxi_utils as loxi_utils
import py_gen
import py_gen.util
import py_gen.codegen
@@ -99,3 +101,8 @@
for module in modules[version]:
filename = '%s/%s/%s.py' % (prefix, subdir, module)
targets[filename] = make_gen(module, version)
+
+def generate():
+ for (name, fn) in targets.items():
+ with loxi_utils.open_output(name) as outfile:
+ fn(outfile, os.path.basename(name))