diff document_it.py @ 18:f7dc318832dc

misc improvements
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 02 Aug 2011 19:14:32 -0700
parents 0a1aecef2c52
children 493683e17eae
line wrap: on
line diff
--- a/document_it.py	Tue Aug 02 18:04:56 2011 -0700
+++ b/document_it.py	Tue Aug 02 19:14:32 2011 -0700
@@ -45,6 +45,12 @@
         if os.path.exists(path):
             return path
 
+def all_files(directory):
+    filenames = []
+    for dirpath, dirnames, files in os.walk(directory):
+        filenames.extend([os.path.join(dirpath, f) for f in files])
+    return sorted(filenames)
+                    
 def parse_manifest(filename, baseurl, directory=None):
     """
     reads a documentation manifest; returns a list of two-tuples:
@@ -71,7 +77,10 @@
             url = '%s/%s' % (baseurl, url.lstrip('/'))
         filename = os.path.join(directory, f)
         if os.path.isdir(filename):
-            pass # TODO
+            files = all_files(filename)
+            for i in files:
+                relpath = os.path.relpath(i, filename)
+                items.append((i, '%s/%s' % (url.rstrip('/'), relpath.lstrip('/'))))
         else:
             items.append((filename, url))
     return items
@@ -150,7 +159,7 @@
             # create a directory if needed
             dirname = os.path.dirname(dest)
             if os.path.exists(dirname):
-                assert os.path.isdir(dirname)
+                assert os.path.isdir(dirname), "%s exists and is not a directory" % dirname
             else:
                 os.makedirs(dirname)