summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2013-09-17 20:32:18 +0900
committershimizukawa <shimizukawa@gmail.com>2013-09-17 20:32:18 +0900
commitf4264a2abf5f988cd550222c359386e53d9fefbf (patch)
treef02e04edf8a62bb8f3ba4c6e2e42a4ba7ca8b0b9 /sphinx/util
parent0e28974e924e5037ccf9cfe9b9af238abb15e89a (diff)
downloadsphinx-f4264a2abf5f988cd550222c359386e53d9fefbf.tar.gz
Fix NFC/NFD normalizing problem of rst filename on Mac OS X. Closes #1142
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/__init__.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py
index 229c3ad6..17371ea8 100644
--- a/sphinx/util/__init__.py
+++ b/sphinx/util/__init__.py
@@ -17,6 +17,7 @@ import fnmatch
import tempfile
import posixpath
import traceback
+import unicodedata
from os import path
from codecs import open, BOM_UTF8
from collections import deque
@@ -50,6 +51,13 @@ def docname_join(basedocname, docname):
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.
@@ -62,9 +70,9 @@ def get_matching_files(dirname, exclude_matchers=()):
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])]