[Checkins] SVN: Sandbox/ulif/z3c.recipe.template/z3c/recipe/template/__init__.py Add method for creating intermediate paths.

Uli Fouquet uli at gnufix.de
Mon Mar 9 18:08:47 EDT 2009


Log message for revision 97722:
  Add method for creating intermediate paths.

Changed:
  U   Sandbox/ulif/z3c.recipe.template/z3c/recipe/template/__init__.py

-=-
Modified: Sandbox/ulif/z3c.recipe.template/z3c/recipe/template/__init__.py
===================================================================
--- Sandbox/ulif/z3c.recipe.template/z3c/recipe/template/__init__.py	2009-03-09 21:55:38 UTC (rev 97721)
+++ Sandbox/ulif/z3c.recipe.template/z3c/recipe/template/__init__.py	2009-03-09 22:08:47 UTC (rev 97722)
@@ -35,6 +35,7 @@
         template=re.sub(r"\$\{([^:]+?)\}", r"${%s:\1}" % self.name, source) 
         result=self.options._sub(template, [])
 
+        self.createIntermediatePaths(os.path.dirname(self.output))
         output=open(self.output, "wt")
         output.write(result)
         output.close()
@@ -49,4 +50,11 @@
         # Variables in other parts might have changed so we need to do a
         # full reinstall.
         return self.install()
-        
+
+    def createIntermediatePaths(self, path):
+        parent = os.path.dirname(path)
+        if os.path.exists(path) or parent == path:
+            return
+        self.createIntermediatePaths(parent)
+        os.mkdir(path)
+        self.options.created(path)



More information about the Checkins mailing list