Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
Date: Thu, 29 Oct 2020 03:33:29
Message-Id: 1603942388.6340855697e98ba4f393b4568810387c538d0245.mattst88@gentoo
1 commit: 6340855697e98ba4f393b4568810387c538d0245
2 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
3 AuthorDate: Wed Oct 28 20:50:00 2020 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 29 03:33:08 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=63408556
7
8 catalyst: Replace pathcompare function
9
10 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
11
12 catalyst/support.py | 24 +++++++-----------------
13 1 file changed, 7 insertions(+), 17 deletions(-)
14
15 diff --git a/catalyst/support.py b/catalyst/support.py
16 index f49315a5..4458ed20 100644
17 --- a/catalyst/support.py
18 +++ b/catalyst/support.py
19 @@ -5,6 +5,7 @@ import os
20 import re
21 import shutil
22 import time
23 +from pathlib import Path
24 from subprocess import Popen
25
26 from catalyst import log
27 @@ -179,31 +180,20 @@ def read_makeconf(mymakeconffile):
28 return makeconf
29
30
31 -def pathcompare(path1, path2):
32 - # Change double slashes to slash
33 - path1 = re.sub(r"//", r"/", path1)
34 - path2 = re.sub(r"//", r"/", path2)
35 - # Removing ending slash
36 - path1 = re.sub("/$", "", path1)
37 - path2 = re.sub("/$", "", path2)
38 -
39 - if path1 == path2:
40 - return 1
41 - return 0
42 -
43 -
44 def ismount(path):
45 """Like os.path.ismount, but also support bind mounts"""
46 if os.path.ismount(path):
47 - return 1
48 + return True
49 +
50 a = os.popen("mount")
51 mylines = a.readlines()
52 a.close()
53 for line in mylines:
54 mysplit = line.split()
55 - if pathcompare(path, mysplit[2]):
56 - return 1
57 - return 0
58 + if Path(path) == Path(mysplit[2]):
59 + return True
60 +
61 + return False
62
63
64 def addl_arg_parse(myspec, addlargs, requiredspec, validspec):