public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-catalyst] [PATCH 01/12] catalyst: Replace pathcompare()
@ 2020-10-29 16:16 Matt Turner
  2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 02/12] catalyst: Rewrite ismount() to use libmount Matt Turner
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Matt Turner @ 2020-10-29 16:16 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Matt Turner

Modern Python allows us to do this in a much cleaner way.

Signed-off-by: Matt Turner <mattst88@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):
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-10-29 16:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-29 16:16 [gentoo-catalyst] [PATCH 01/12] catalyst: Replace pathcompare() Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 02/12] catalyst: Rewrite ismount() to use libmount Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 03/12] catalyst: Use libmount for handling mounts Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 04/12] catalyst: Move action_sequence out of self.settings[] Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 05/12] catalyst: Use .extend() and .append() for action_sequence Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 06/12] catalyst: Split action_sequence into prepare/build/finish Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 07/12] catalyst: Factor out run_sequence() Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 08/12] catalyst: Add and use namespace context manager Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 09/12] catalyst: Run the build sequence in new mount namespace Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 10/12] catalyst: Remove kill_support_pids() Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 11/12] catalyst: Remove mount_safety_check() Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 12/12] catalyst: Drop unbind() Matt Turner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox