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