[Python-checkins] r62526 - in doctools/trunk: CHANGES sphinx/util/__init__.py

georg.brandl python-checkins at python.org
Sun Apr 27 17:48:24 CEST 2008


Author: georg.brandl
Date: Sun Apr 27 17:48:24 2008
New Revision: 62526

Log:
Follow links when searching documents and document changes from Armin.


Modified:
   doctools/trunk/CHANGES
   doctools/trunk/sphinx/util/__init__.py

Modified: doctools/trunk/CHANGES
==============================================================================
--- doctools/trunk/CHANGES	(original)
+++ doctools/trunk/CHANGES	Sun Apr 27 17:48:24 2008
@@ -24,6 +24,9 @@
 
   and putting ``'index': name of your template`` in ``html_additional_pages``.
 
+* In the layout template, redundant ``block``\s were removed; you should use
+  Jinja's standard ``{{ super() }}`` mechanism instead.
+
 New features added
 ------------------
 
@@ -83,6 +86,8 @@
 * sphinx.builder, sphinx.environment: Gracefully handle some user error
   cases.
 
+* sphinx.util: Follow symbolic links when searching for documents.
+
 
 Release 0.1.61950 (Mar 26, 2008)
 ================================

Modified: doctools/trunk/sphinx/util/__init__.py
==============================================================================
--- doctools/trunk/sphinx/util/__init__.py	(original)
+++ doctools/trunk/sphinx/util/__init__.py	Sun Apr 27 17:48:24 2008
@@ -50,6 +50,30 @@
             raise
 
 
+def walk(top, topdown=True, followlinks=False):
+    """
+    Backport of os.walk from 2.6, where the followlinks argument was added.
+    """
+    names = os.listdir(top)
+
+    dirs, nondirs = [], []
+    for name in names:
+        if path.isdir(path.join(top, name)):
+            dirs.append(name)
+        else:
+            nondirs.append(name)
+
+    if topdown:
+        yield top, dirs, nondirs
+    for name in dirs:
+        fullpath = path.join(top, name)
+        if followlinks or not path.islink(fullpath):
+            for x in walk(fullpath, topdown, followlinks):
+                yield x
+    if not topdown:
+        yield top, dirs, nondirs
+
+
 def get_matching_docs(dirname, suffix, exclude=(), prune=()):
     """
     Get all file names (without suffix) matching a suffix in a
@@ -61,7 +85,7 @@
     # dirname is a normalized absolute path.
     dirname = path.normpath(path.abspath(dirname))
     dirlen = len(dirname) + 1    # exclude slash
-    for root, dirs, files in os.walk(dirname):
+    for root, dirs, files in walk(dirname, followlinks=True):
         dirs.sort()
         files.sort()
         for prunedir in prune:


More information about the Python-checkins mailing list