diff options
author | Alex Willmer <alex@moreati.org.uk> | 2015-09-10 19:31:16 +0100 |
---|---|---|
committer | Alex Willmer <alex@moreati.org.uk> | 2015-09-10 19:31:16 +0100 |
commit | d9b20136c8314c56c7f7c26cc93d3eebcdfae29e (patch) | |
tree | d088501bc8cb4919d67b3aff9697bd4728abaab5 /babel/util.py | |
parent | e9373d98a5b2fda701d927087e5cb950bab1961c (diff) | |
download | babel-d9b20136c8314c56c7f7c26cc93d3eebcdfae29e.tar.gz |
Remove unneeded relpath() polyfill
It looks like this dates back all the way to 2007,
and the initial import of the code in commit 00f16f9.
Since Python 2.6 is the minimum supported version, and that has
os.path.relpath this is no longer needed.
Diffstat (limited to 'babel/util.py')
-rw-r--r-- | babel/util.py | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/babel/util.py b/babel/util.py index c366214..b5a3eab 100644 --- a/babel/util.py +++ b/babel/util.py @@ -12,6 +12,7 @@ import codecs from datetime import timedelta, tzinfo import os +from os.path import relpath import re import textwrap from babel._compat import izip, imap @@ -232,29 +233,6 @@ class odict(dict): return imap(self.get, self._keys) -try: - relpath = os.path.relpath -except AttributeError: - def relpath(path, start='.'): - """Compute the relative path to one path from another. - - >>> relpath('foo/bar.txt', '').replace(os.sep, '/') - 'foo/bar.txt' - >>> relpath('foo/bar.txt', 'foo').replace(os.sep, '/') - 'bar.txt' - >>> relpath('foo/bar.txt', 'baz').replace(os.sep, '/') - '../foo/bar.txt' - """ - start_list = os.path.abspath(start).split(os.sep) - path_list = os.path.abspath(path).split(os.sep) - - # Work out how much of the filepath is shared by start and path. - i = len(os.path.commonprefix([start_list, path_list])) - - rel_list = [os.path.pardir] * (len(start_list) - i) + path_list[i:] - return os.path.join(*rel_list) - - class FixedOffsetTimezone(tzinfo): """Fixed offset in minutes east from UTC.""" |