[gobject-introspection] docmain: Create the output dir for us if it doesn't exist



commit 6ba948c1647ad19e91576520e6f506235a585bb2
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Feb 15 05:49:55 2013 -0500

    docmain: Create the output dir for us if it doesn't exist

 giscanner/docmain.py   |    2 --
 giscanner/docwriter.py |    6 ++++++
 2 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/giscanner/docmain.py b/giscanner/docmain.py
index cd782fe..fc78ed6 100644
--- a/giscanner/docmain.py
+++ b/giscanner/docmain.py
@@ -41,8 +41,6 @@ def doc_main(args):
     options, args = parser.parse_args(args)
     if not options.output:
         raise SystemExit("missing output parameter")
-    if not os.path.isdir(options.output):
-        raise SystemExit("wrong output parameter: %s" % (options.output, ))
 
     if len(args) < 2:
         raise SystemExit("Need an input GIR filename")
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index 85f3b16..d5b1f90 100644
--- a/giscanner/docwriter.py
+++ b/giscanner/docwriter.py
@@ -593,6 +593,12 @@ class DocWriter(object):
                               output_encoding='utf-8')
 
     def write(self, output):
+        try:
+            os.makedirs(output)
+        except OSError:
+            # directory already made
+            pass
+
         nodes = [self._transformer.namespace]
         for node in self._transformer.namespace.itervalues():
             if isinstance(node, ast.Function) and node.moved_to is not None:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]