1 |
Modern Python allows us to do this in a much cleaner way. |
2 |
|
3 |
Signed-off-by: Matt Turner <mattst88@g.o> |
4 |
--- |
5 |
catalyst/support.py | 24 +++++++----------------- |
6 |
1 file changed, 7 insertions(+), 17 deletions(-) |
7 |
|
8 |
diff --git a/catalyst/support.py b/catalyst/support.py |
9 |
index f49315a5..4458ed20 100644 |
10 |
--- a/catalyst/support.py |
11 |
+++ b/catalyst/support.py |
12 |
@@ -5,6 +5,7 @@ import os |
13 |
import re |
14 |
import shutil |
15 |
import time |
16 |
+from pathlib import Path |
17 |
from subprocess import Popen |
18 |
|
19 |
from catalyst import log |
20 |
@@ -179,31 +180,20 @@ def read_makeconf(mymakeconffile): |
21 |
return makeconf |
22 |
|
23 |
|
24 |
-def pathcompare(path1, path2): |
25 |
- # Change double slashes to slash |
26 |
- path1 = re.sub(r"//", r"/", path1) |
27 |
- path2 = re.sub(r"//", r"/", path2) |
28 |
- # Removing ending slash |
29 |
- path1 = re.sub("/$", "", path1) |
30 |
- path2 = re.sub("/$", "", path2) |
31 |
- |
32 |
- if path1 == path2: |
33 |
- return 1 |
34 |
- return 0 |
35 |
- |
36 |
- |
37 |
def ismount(path): |
38 |
"""Like os.path.ismount, but also support bind mounts""" |
39 |
if os.path.ismount(path): |
40 |
- return 1 |
41 |
+ return True |
42 |
+ |
43 |
a = os.popen("mount") |
44 |
mylines = a.readlines() |
45 |
a.close() |
46 |
for line in mylines: |
47 |
mysplit = line.split() |
48 |
- if pathcompare(path, mysplit[2]): |
49 |
- return 1 |
50 |
- return 0 |
51 |
+ if Path(path) == Path(mysplit[2]): |
52 |
+ return True |
53 |
+ |
54 |
+ return False |
55 |
|
56 |
|
57 |
def addl_arg_parse(myspec, addlargs, requiredspec, validspec): |
58 |
-- |
59 |
2.26.2 |