1 |
commit: b8b6de7bc84677d9ae13cf8bfff2c0e6a281ff75 |
2 |
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jan 24 02:34:06 2021 +0000 |
4 |
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 28 02:06:46 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b8b6de7b |
7 |
|
8 |
catalyst: Remove fallback make.conf parsing code |
9 |
|
10 |
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org> |
11 |
|
12 |
catalyst/support.py | 42 +++--------------------------------------- |
13 |
1 file changed, 3 insertions(+), 39 deletions(-) |
14 |
|
15 |
diff --git a/catalyst/support.py b/catalyst/support.py |
16 |
index f3a865a7..fa652987 100644 |
17 |
--- a/catalyst/support.py |
18 |
+++ b/catalyst/support.py |
19 |
@@ -2,7 +2,6 @@ |
20 |
import glob |
21 |
import sys |
22 |
import os |
23 |
-import re |
24 |
import shutil |
25 |
import time |
26 |
from pathlib import Path |
27 |
@@ -12,6 +11,8 @@ import libmount |
28 |
|
29 |
from portage.repository.config import RepoConfig |
30 |
|
31 |
+from snakeoil.bash import read_bash_dict |
32 |
+ |
33 |
from catalyst import log |
34 |
|
35 |
BASH_BINARY = "/bin/bash" |
36 |
@@ -135,47 +136,10 @@ defined are not preserved. In other words, "foo", "bar", "oni" ordering is prese |
37 |
print_traceback=True) |
38 |
|
39 |
|
40 |
-def parse_makeconf(mylines): |
41 |
- mymakeconf = {} |
42 |
- pos = 0 |
43 |
- pat = re.compile("([0-9a-zA-Z_]*)=(.*)") |
44 |
- while pos < len(mylines): |
45 |
- if len(mylines[pos]) <= 1: |
46 |
- # skip blanks |
47 |
- pos += 1 |
48 |
- continue |
49 |
- if mylines[pos][0] in ["#", " ", "\t"]: |
50 |
- # skip indented lines, comments |
51 |
- pos += 1 |
52 |
- continue |
53 |
- else: |
54 |
- myline = mylines[pos] |
55 |
- mobj = pat.match(myline) |
56 |
- pos += 1 |
57 |
- if mobj.group(2): |
58 |
- clean_string = re.sub(r"\"", r"", mobj.group(2)) |
59 |
- mymakeconf[mobj.group(1)] = clean_string |
60 |
- return mymakeconf |
61 |
- |
62 |
- |
63 |
def read_makeconf(mymakeconffile): |
64 |
if os.path.exists(mymakeconffile): |
65 |
try: |
66 |
- try: |
67 |
- import snakeoil.bash # import snakeoil.fileutils |
68 |
- return snakeoil.bash.read_bash_dict(mymakeconffile, sourcing_command="source") |
69 |
- except ImportError: |
70 |
- try: |
71 |
- import portage.util |
72 |
- return portage.util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True) |
73 |
- except Exception: |
74 |
- try: |
75 |
- import portage_util |
76 |
- return portage_util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True) |
77 |
- except ImportError: |
78 |
- with open(mymakeconffile, "r") as myf: |
79 |
- mylines = myf.readlines() |
80 |
- return parse_makeconf(mylines) |
81 |
+ return read_bash_dict(mymakeconffile, sourcing_command="source") |
82 |
except Exception: |
83 |
raise CatalystError("Could not parse make.conf file " + |
84 |
mymakeconffile, print_traceback=True) |