From d9b20136c8314c56c7f7c26cc93d3eebcdfae29e Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 10 Sep 2015 19:31:16 +0100 Subject: [PATCH] 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. --- babel/util.py | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) 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.""" -- 2.47.2