From: Rob Browning Date: Sat, 9 Nov 2019 19:36:16 +0000 (-0600) Subject: wvtest.py: drop relpath compatability code X-Git-Tag: 0.31~250 X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=5e36ae7acf551bf33e78eda849617ceced02bac5 wvtest.py: drop relpath compatability code Signed-off-by: Rob Browning --- diff --git a/LICENSE b/LICENSE index 6ed12e5..ed0a377 100644 --- a/LICENSE +++ b/LICENSE @@ -7,10 +7,6 @@ In addition, bupsplit.c, bupsplit.h, and options.py may be redistributed according to the separate (BSD-style) license written inside those files. -The definition of the relpath function was taken from CPython (tag -v2.6, file Lib/posixpath.py, hg-commit 95fff5a6a276) and is covered -under the terms of the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2. - GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 diff --git a/wvtest.py b/wvtest.py index 9078127..6a302d7 100755 --- a/wvtest.py +++ b/wvtest.py @@ -14,6 +14,7 @@ exec "$bup_python" "$0" ${1+"$@"} # from __future__ import absolute_import, print_function +from os.path import relpath import atexit import inspect import os @@ -193,33 +194,11 @@ def _run_in_chdir(path, func, *args, **kwargs): sys.path = oldpath -if sys.version_info >= (2,6,0): - _relpath = os.path.relpath; -else: - # Implementation for Python 2.5, taken from CPython (tag v2.6, - # file Lib/posixpath.py, hg-commit 95fff5a6a276). Update - # ./LICENSE When this code is eventually removed. - def _relpath(path, start=os.path.curdir): - if not path: - raise ValueError("no path specified") - - start_list = os.path.abspath(start).split(os.path.sep) - path_list = os.path.abspath(path).split(os.path.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:] - if not rel_list: - return curdir - return os.path.join(*rel_list) - - def _runtest(fname, f): mod = inspect.getmodule(f) - relpath = _relpath(mod.__file__, os.getcwd()).replace('.pyc', '.py') + rpath = relpath(mod.__file__, os.getcwd()).replace('.pyc', '.py') print() - print('Testing "%s" in %s:' % (fname, relpath)) + print('Testing "%s" in %s:' % (fname, rpath)) sys.stdout.flush() try: _run_in_chdir(os.path.split(mod.__file__)[0], f)