From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 ECF22138359 for ; Fri, 30 Oct 2020 22:41:09 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 32723E05C1; Fri, 30 Oct 2020 22:41:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (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 183D6E05C1 for ; Fri, 30 Oct 2020 22:41:09 +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 B8F8833BF21 for ; Fri, 30 Oct 2020 22:41:07 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3625E3F0 for ; Fri, 30 Oct 2020 22:41:06 +0000 (UTC) From: "Matt Turner" 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" Message-ID: <1604097652.cf50ce228e766252fe0ea901f86671fed6a99cfa.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:master 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: cf50ce228e766252fe0ea901f86671fed6a99cfa X-VCS-Branch: master Date: Fri, 30 Oct 2020 22:41:06 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: f90eac9d-0893-40f2-bc1d-ab56c771d21b X-Archives-Hash: fae15e76c30eb3a44e4d254818659fb6 commit: cf50ce228e766252fe0ea901f86671fed6a99cfa Author: Matt Turner gentoo org> AuthorDate: Wed Oct 28 20:50:00 2020 +0000 Commit: Matt Turner gentoo org> CommitDate: Fri Oct 30 22:40:52 2020 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=cf50ce22 catalyst: Replace pathcompare() Modern Python allows us to do this in a much cleaner way. Signed-off-by: Matt Turner 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):