From db101fdddb6f631a342fedc0ef2560edbef580b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=98yvind=20Karlsen?= Date: Tue, 28 Jun 2016 20:25:13 +0200 Subject: improve getpkgtopdir() to return "friendlier" (normalized) paths --- MgaRepo/rpmutil.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'MgaRepo') diff --git a/MgaRepo/rpmutil.py b/MgaRepo/rpmutil.py index 0bd2ef8..c541fc9 100644 --- a/MgaRepo/rpmutil.py +++ b/MgaRepo/rpmutil.py @@ -625,19 +625,12 @@ def clone(pkgdirurl, path=None, revision=None, branch=None, distro=None, backpor if not spec: binrepo.download_binaries(path) -def getpkgtopdir(basedir=None): - - #FIXME this implementation doesn't work well with relative path names, - # which is something we need in order to have a friendlier output - if basedir is None: - basedir = os.path.curdir +def getpkgtopdir(basedir=os.path.curdir): while not ispkgtopdir(basedir): if os.path.abspath(basedir) == "/": raise Error("can't find top package directories SOURCES and SPECS") basedir = os.path.join(basedir, os.path.pardir) - if basedir.startswith("./"): - basedir = basedir[2:] - return basedir + return os.path.normpath(basedir) def ispkgtopdir(path=None): if path is None: -- cgit v1.2.1