aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gentoo.org>2020-10-28 16:50:00 -0400
committerMatt Turner <mattst88@gentoo.org>2020-10-30 18:40:52 -0400
commitcf50ce228e766252fe0ea901f86671fed6a99cfa (patch)
tree5f2f02725f016f930ae880932e273e2aa0b63eae
parentMakefile: Cleanup doc/subarches.generated.xml (diff)
downloadcatalyst-cf50ce22.tar.gz
catalyst-cf50ce22.tar.bz2
catalyst-cf50ce22.zip
catalyst: Replace pathcompare()
Modern Python allows us to do this in a much cleaner way. Signed-off-by: Matt Turner <mattst88@gentoo.org>
-rw-r--r--catalyst/support.py24
1 files 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):