From aef2d8cffba402955f666b9e5447017c5188b411 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Fri, 9 Oct 2015 20:03:51 +0300 Subject: [PATCH 1/3] gettext: use canonical relative paths for .pot --- sphinx/builders/gettext.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py index ec6a18805..a1a0d1842 100644 --- a/sphinx/builders/gettext.py +++ b/sphinx/builders/gettext.py @@ -216,7 +216,8 @@ class MessageCatalogBuilder(I18nBuilder): if self.config.gettext_location: # generate "#: file1:line1\n#: file2:line2 ..." pofile.write("#: %s\n" % "\n#: ".join( - "%s:%s" % (safe_relpath(source, self.outdir), line) + "%s:%s" % (safe_relpath(source, self.outdir). + replace('\\', '/'), line) for source, line, _ in positions)) if self.config.gettext_uuid: # generate "# uuid1\n# uuid2\n ..." From 9c53796f87e5957744bcc8b990ef8387446b9964 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sat, 10 Oct 2015 16:40:59 +0300 Subject: [PATCH 2/3] add inverse of util.os_path for canonical path generation --- sphinx/util/osutil.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py index 5bfbcabc4..9177f42c4 100644 --- a/sphinx/util/osutil.py +++ b/sphinx/util/osutil.py @@ -38,6 +38,10 @@ SEP = "/" def os_path(canonicalpath): return canonicalpath.replace(SEP, path.sep) + +def canon_path(nativepath): + """Return path in OS-independent form""" + return nativepath.replace(path.sep, SEP) def relative_uri(base, to): From 281bf2ae3accaa0052902ccf6d760b165b457812 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sat, 10 Oct 2015 16:44:46 +0300 Subject: [PATCH 3/3] gettext: use new osutil.canon_path() --- sphinx/builders/gettext.py | 9 ++++----- sphinx/util/osutil.py | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py index a1a0d1842..dd9a35c15 100644 --- a/sphinx/builders/gettext.py +++ b/sphinx/builders/gettext.py @@ -23,7 +23,7 @@ from six import iteritems from sphinx.builders import Builder from sphinx.util import split_index_msg from sphinx.util.nodes import extract_messages, traverse_translatable_index -from sphinx.util.osutil import safe_relpath, ensuredir, SEP +from sphinx.util.osutil import safe_relpath, ensuredir, canon_path from sphinx.util.i18n import find_catalog from sphinx.util.console import darkgreen, purple, bold from sphinx.locale import pairindextypes @@ -165,8 +165,7 @@ class MessageCatalogBuilder(I18nBuilder): for dirpath, dirs, files in walk(tmpl_abs_path): for fn in files: if fn.endswith('.html'): - filename = path.join(dirpath, fn) - filename = filename.replace(path.sep, SEP) + filename = canon_path(path.join(dirpath, fn)) template_files.add(filename) return template_files @@ -216,8 +215,8 @@ class MessageCatalogBuilder(I18nBuilder): if self.config.gettext_location: # generate "#: file1:line1\n#: file2:line2 ..." pofile.write("#: %s\n" % "\n#: ".join( - "%s:%s" % (safe_relpath(source, self.outdir). - replace('\\', '/'), line) + "%s:%s" % (canon_path( + safe_relpath(source, self.outdir)), line) for source, line, _ in positions)) if self.config.gettext_uuid: # generate "# uuid1\n# uuid2\n ..." diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py index 9177f42c4..c99042112 100644 --- a/sphinx/util/osutil.py +++ b/sphinx/util/osutil.py @@ -38,7 +38,8 @@ SEP = "/" def os_path(canonicalpath): return canonicalpath.replace(SEP, path.sep) - + + def canon_path(nativepath): """Return path in OS-independent form""" return nativepath.replace(path.sep, SEP)