Takayuki Shimizukawa avatar Takayuki Shimizukawa committed 4f314ba

Fix NFC/NFD normalizing problem of rst filename on Mac OS X. Closes #1142

Comments (0)

Files changed (2)

 * #1232: Sphinx generated broken ePub files on Windows.
 * #1259: Guard the debug output call when emitting events; to prevent the
   repr() implementation of arbitrary objects causing build failures.
+* #1142: Fix NFC/NFD normalizing problem of rst filename on Mac OS X.
 
 
 Release 1.2 beta1 (released Mar 31, 2013)

sphinx/util/__init__.py

 import tempfile
 import posixpath
 import traceback
+import unicodedata
 from os import path
 from codecs import open, BOM_UTF8
 from collections import deque
         posixpath.join('/' + basedocname, '..', docname))[1:]
 
 
+def path_stabilize(filepath):
+    "normalize path separater and unicode string"
+    newpath = filepath.replace(os.path.sep, SEP)
+    newpath = unicodedata.normalize('NFC', newpath)
+    return newpath
+
+
 def get_matching_files(dirname, exclude_matchers=()):
     """Get all file names in a directory, recursively.
 
     for root, dirs, files in walk(dirname, followlinks=True):
         relativeroot = root[dirlen:]
 
-        qdirs = enumerate(path.join(relativeroot, dn).replace(os.path.sep, SEP)
+        qdirs = enumerate(path_stabilize(path.join(relativeroot, dn))
                           for dn in dirs)
-        qfiles = enumerate(path.join(relativeroot, fn).replace(os.path.sep, SEP)
+        qfiles = enumerate(path_stabilize(path.join(relativeroot, fn))
                            for fn in files)
         for matcher in exclude_matchers:
             qdirs = [entry for entry in qdirs if not matcher(entry[1])]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.