From: Alex Willmer Date: Thu, 10 Sep 2015 18:31:16 +0000 (+0100) Subject: Remove unneeded relpath() polyfill X-Git-Tag: dev-2a51c9b95d06~27^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9b20136c8314c56c7f7c26cc93d3eebcdfae29e;p=thirdparty%2Fbabel.git 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. --- diff --git a/babel/util.py b/babel/util.py index c3662141..b5a3eabd 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."""