From 3a19adb976393dc4066def880d0db11e2f7378d7 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 15 Dec 2013 14:16:53 +0900 Subject: Drop python-2.5 and remove 2.4,2.5 support codes --- sphinx/util/osutil.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sphinx/util/osutil.py') diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py index 87717771..e8655fe1 100644 --- a/sphinx/util/osutil.py +++ b/sphinx/util/osutil.py @@ -69,6 +69,10 @@ def ensuredir(path): raise +# TODO: This function can be removed because this function is same as os.walk +# of Python2.6, 2.7, 3.1, 3.2, 3.3. +# HOWEVER, this function is customized to check UnicodeError that obstacle to +# replace the function with the os.walk. def walk(top, topdown=True, followlinks=False): """Backport of os.walk from 2.6, where the *followlinks* argument was added. @@ -155,9 +159,8 @@ else: def safe_relpath(path, start=None): - from sphinx.util.pycompat import relpath try: - return relpath(path, start) + return os.path.relpath(path, start) except ValueError: return path @@ -171,14 +174,13 @@ def find_catalog(docname, compaction): def find_catalog_files(docname, srcdir, locale_dirs, lang, compaction): - from sphinx.util.pycompat import relpath if not(lang and locale_dirs): return [] domain = find_catalog(docname, compaction) files = [gettext.find(domain, path.join(srcdir, dir_), [lang]) for dir_ in locale_dirs] - files = [relpath(f, srcdir) for f in files if f] + files = [path.relpath(f, srcdir) for f in files if f] return files -- cgit v1.2.1 From 8b375619a7a91d26f07f1ba944757700ae82827f Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 15 Dec 2013 16:04:23 +0900 Subject: Drop python-3.1 and remove support codes --- sphinx/util/osutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sphinx/util/osutil.py') diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py index e8655fe1..d2f8679e 100644 --- a/sphinx/util/osutil.py +++ b/sphinx/util/osutil.py @@ -70,7 +70,7 @@ def ensuredir(path): # TODO: This function can be removed because this function is same as os.walk -# of Python2.6, 2.7, 3.1, 3.2, 3.3. +# of Python2.6, 2.7, 3.2, 3.3. # HOWEVER, this function is customized to check UnicodeError that obstacle to # replace the function with the os.walk. def walk(top, topdown=True, followlinks=False): -- cgit v1.2.1 From 80a0712b8190ca3d55531a9d1fe3205e364437d1 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sat, 18 Jan 2014 16:30:54 +0900 Subject: Fix: The application now check extra Python versions (3.0, 3.1) to stop invoking. And fix a trivial comment. --- sphinx/util/osutil.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sphinx/util/osutil.py') diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py index d2f8679e..a5c461a6 100644 --- a/sphinx/util/osutil.py +++ b/sphinx/util/osutil.py @@ -69,10 +69,9 @@ def ensuredir(path): raise -# TODO: This function can be removed because this function is same as os.walk -# of Python2.6, 2.7, 3.2, 3.3. -# HOWEVER, this function is customized to check UnicodeError that obstacle to -# replace the function with the os.walk. +# This function is same as os.walk of Python2.6, 2.7, 3.2, 3.3 except a +# customization that check UnicodeError. +# The customization obstacle to replace the function with the os.walk. def walk(top, topdown=True, followlinks=False): """Backport of os.walk from 2.6, where the *followlinks* argument was added. -- cgit v1.2.1 From 344417db950d6e816ab2efb21737c2bdf9d1ad53 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Sun, 19 Jan 2014 14:17:10 +0400 Subject: Modernize the code now that Python 2.5 is no longer supported - Use print function instead of print statement; - Use new exception handling; - Use in operator instead of has_key(); - Do not use tuple arguments in functions; - Other miscellaneous improvements. This is based on output of `futurize --stage1`, with some manual corrections. --- sphinx/util/osutil.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sphinx/util/osutil.py') diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py index a5c461a6..a0b669f1 100644 --- a/sphinx/util/osutil.py +++ b/sphinx/util/osutil.py @@ -8,6 +8,7 @@ :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ +from __future__ import print_function import os import re @@ -63,7 +64,7 @@ def ensuredir(path): """Ensure that a path exists.""" try: os.makedirs(path) - except OSError, err: + except OSError as err: # 0 for Jython/Win32 if err.errno not in [0, EEXIST]: raise @@ -83,9 +84,9 @@ def walk(top, topdown=True, followlinks=False): try: fullpath = path.join(top, name) except UnicodeError: - print >>sys.stderr, ( - '%s:: ERROR: non-ASCII filename not supported on this ' - 'filesystem encoding %r, skipped.' % (name, fs_encoding)) + print('%s:: ERROR: non-ASCII filename not supported on this ' + 'filesystem encoding %r, skipped.' % (name, fs_encoding), + file=sys.stderr) continue if path.isdir(fullpath): dirs.append(name) -- cgit v1.2.1