From 4bac666bb4f85f0efe0b4002a527c9f4b510c306 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Thu, 1 Oct 2015 13:37:41 +0100 Subject: Code cleanup: removed function for supporting relpath in pre-2.6 python. --- src/engine/SCons/Tool/GettextCommon.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/engine/SCons/Tool/GettextCommon.py b/src/engine/SCons/Tool/GettextCommon.py index cd2f306..bdd52c0 100644 --- a/src/engine/SCons/Tool/GettextCommon.py +++ b/src/engine/SCons/Tool/GettextCommon.py @@ -306,23 +306,6 @@ class RPaths(object): - Tuple of strings, which represent paths relative to current working directory (for given environment). """ - # os.path.relpath is available only on python >= 2.6. We use our own - # implementation. It's taken from BareNecessities package: - # http://jimmyg.org/work/code/barenecessities/index.html - from posixpath import curdir - def relpath(path, start=curdir): - import posixpath - """Return a relative version of a path""" - if not path: - raise ValueError("no path specified") - start_list = posixpath.abspath(start).split(posixpath.sep) - path_list = posixpath.abspath(path).split(posixpath.sep) - # Work out how much of the filepath is shared by start and path. - i = len(posixpath.commonprefix([start_list, path_list])) - rel_list = [posixpath.pardir] * (len(start_list)-i) + path_list[i:] - if not rel_list: - return posixpath.curdir - return posixpath.join(*rel_list) import os import SCons.Node.FS rpaths = () @@ -330,7 +313,7 @@ class RPaths(object): for node in nodes: rpath = None if isinstance(node, SCons.Node.FS.Base): - rpath = relpath(node.get_abspath(), cwd) + rpath = os.path.relpath(node.get_abspath(), cwd) # FIXME: Other types possible here? if rpath is not None: rpaths += (rpath,) -- cgit v0.12