From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1218328-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 6C10D13835A for <garchives@archives.gentoo.org>; Thu, 29 Oct 2020 15:47:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 49E7CE0858; Thu, 29 Oct 2020 15:47:41 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2DE75E0858 for <gentoo-commits@lists.gentoo.org>; Thu, 29 Oct 2020 15:47:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D649A340E68 for <gentoo-commits@lists.gentoo.org>; Thu, 29 Oct 2020 15:47:39 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4C85F3C0 for <gentoo-commits@lists.gentoo.org>; Thu, 29 Oct 2020 15:47:38 +0000 (UTC) From: "Matt Turner" <mattst88@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" <mattst88@gentoo.org> Message-ID: <1603983055.7af99d080974b090056788ee3e89ee60931a9fe5.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/support.py X-VCS-Directories: catalyst/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: 7af99d080974b090056788ee3e89ee60931a9fe5 X-VCS-Branch: pending/mattst88 Date: Thu, 29 Oct 2020 15:47:38 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: e3ddf079-3899-4510-af1c-c02e0fd1ee55 X-Archives-Hash: eb5e2872c303249e62fb2298651765d2 commit: 7af99d080974b090056788ee3e89ee60931a9fe5 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> AuthorDate: Wed Oct 28 20:50:00 2020 +0000 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> CommitDate: Thu Oct 29 14:50:55 2020 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=7af99d08 catalyst: Replace pathcompare() Modern Python allows us to do this in a much cleaner way. Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org> catalyst/support.py | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/catalyst/support.py b/catalyst/support.py index f49315a5..4458ed20 100644 --- a/catalyst/support.py +++ b/catalyst/support.py @@ -5,6 +5,7 @@ import os import re import shutil import time +from pathlib import Path from subprocess import Popen from catalyst import log @@ -179,31 +180,20 @@ def read_makeconf(mymakeconffile): return makeconf -def pathcompare(path1, path2): - # Change double slashes to slash - path1 = re.sub(r"//", r"/", path1) - path2 = re.sub(r"//", r"/", path2) - # Removing ending slash - path1 = re.sub("/$", "", path1) - path2 = re.sub("/$", "", path2) - - if path1 == path2: - return 1 - return 0 - - def ismount(path): """Like os.path.ismount, but also support bind mounts""" if os.path.ismount(path): - return 1 + return True + a = os.popen("mount") mylines = a.readlines() a.close() for line in mylines: mysplit = line.split() - if pathcompare(path, mysplit[2]): - return 1 - return 0 + if Path(path) == Path(mysplit[2]): + return True + + return False def addl_arg_parse(myspec, addlargs, requiredspec, validspec):