public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
From: Matt Turner <mattst88@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Cc: Matt Turner <mattst88@gentoo.org>
Subject: [gentoo-catalyst] [PATCH 3/4] catalyst: Remove fallback make.conf parsing code
Date: Sun, 24 Jan 2021 10:07:21 -0500	[thread overview]
Message-ID: <20210124150722.760520-3-mattst88@gentoo.org> (raw)
In-Reply-To: <20210124150722.760520-1-mattst88@gentoo.org>

Signed-off-by: Matt Turner <mattst88@gentoo.org>
---
 catalyst/support.py | 42 +++---------------------------------------
 1 file changed, 3 insertions(+), 39 deletions(-)

diff --git a/catalyst/support.py b/catalyst/support.py
index f3a865a7..fa652987 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -2,7 +2,6 @@
 import glob
 import sys
 import os
-import re
 import shutil
 import time
 from pathlib import Path
@@ -12,6 +11,8 @@ import libmount
 
 from portage.repository.config import RepoConfig
 
+from snakeoil.bash import read_bash_dict
+
 from catalyst import log
 
 BASH_BINARY = "/bin/bash"
@@ -135,47 +136,10 @@ defined are not preserved. In other words, "foo", "bar", "oni" ordering is prese
                                     print_traceback=True)
 
 
-def parse_makeconf(mylines):
-    mymakeconf = {}
-    pos = 0
-    pat = re.compile("([0-9a-zA-Z_]*)=(.*)")
-    while pos < len(mylines):
-        if len(mylines[pos]) <= 1:
-            # skip blanks
-            pos += 1
-            continue
-        if mylines[pos][0] in ["#", " ", "\t"]:
-            # skip indented lines, comments
-            pos += 1
-            continue
-        else:
-            myline = mylines[pos]
-            mobj = pat.match(myline)
-            pos += 1
-            if mobj.group(2):
-                clean_string = re.sub(r"\"", r"", mobj.group(2))
-                mymakeconf[mobj.group(1)] = clean_string
-    return mymakeconf
-
-
 def read_makeconf(mymakeconffile):
     if os.path.exists(mymakeconffile):
         try:
-            try:
-                import snakeoil.bash  # import snakeoil.fileutils
-                return snakeoil.bash.read_bash_dict(mymakeconffile, sourcing_command="source")
-            except ImportError:
-                try:
-                    import portage.util
-                    return portage.util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True)
-                except Exception:
-                    try:
-                        import portage_util
-                        return portage_util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True)
-                    except ImportError:
-                        with open(mymakeconffile, "r") as myf:
-                            mylines = myf.readlines()
-                        return parse_makeconf(mylines)
+            return read_bash_dict(mymakeconffile, sourcing_command="source")
         except Exception:
             raise CatalystError("Could not parse make.conf file " +
                                 mymakeconffile, print_traceback=True)
-- 
2.26.2



  parent reply	other threads:[~2021-01-24 15:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-24 15:07 [gentoo-catalyst] [PATCH 1/4] catalyst: Remove unused import Matt Turner
2021-01-24 15:07 ` [gentoo-catalyst] [PATCH 2/4] catalyst: Use lazy % formatting in logging functions Matt Turner
2021-01-24 15:07 ` Matt Turner [this message]
2021-01-24 15:07 ` [gentoo-catalyst] [PATCH 4/4] catalyst: Clean up exception handling Matt Turner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210124150722.760520-3-mattst88@gentoo.org \
    --to=mattst88@gentoo.org \
    --cc=gentoo-catalyst@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox