From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1C5941382C5 for ; Sun, 24 Jan 2021 15:07:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DB4A9E09C9; Sun, 24 Jan 2021 15:07:29 +0000 (UTC) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B0833E09C9 for ; Sun, 24 Jan 2021 15:07:29 +0000 (UTC) Received: by mail-qk1-f181.google.com with SMTP id u20so1537324qku.7 for ; Sun, 24 Jan 2021 07:07:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5S1ZqIsqFLRKlC2gSMyQi62cwCzKjzdQ74EyxO81rho=; b=jXUV/SB07jtW1Sztz09rBGFjXdZMgOWVRa57Y9WY7JXmdHfReoyJ/9R1AjfzU7Rc9S 4P1plJeRmfhCa0uv2sX/OwEt56obFeOh7xtddQH4z3DKty0IEvdD0KPV8I4FxjODEhS6 6L49mZGDCxIXZEv7vZf5q0HMhnh+mCt099eNSFPNxcVK69zQWpDo3hIahNaRhIHYbLOE 2Y6qZPNun8+4aKkOOGbwwmFv1OHpSFzDrvF3LW2XoUFFnH3B9ktYgmyngTXB5JZOHfeX meKcTNtGmHcetAgbAawhhCsWLdSIJyyHsxySwWUUMn9fb2SCjEC4lfxzujQWpJppkNho gZqg== X-Gm-Message-State: AOAM532SFZhUxjSIb7hGbyz8Tn/2ONLAW0o+4JqhrKXQGMF1u/8nYC1Q dVh+NfAYNRjJ/jJvi+J7m5Vp9U0X2vQ= X-Google-Smtp-Source: ABdhPJyNyspc5r3Vnpo37GW7Dc/L4htgZdtsaCO2SwgudP+3LP2r00d3i70J/eiHBDJno5hn85oWxw== X-Received: by 2002:a37:59c5:: with SMTP id n188mr566839qkb.170.1611500848673; Sun, 24 Jan 2021 07:07:28 -0800 (PST) Received: from localhost ([208.104.103.123]) by smtp.gmail.com with ESMTPSA id o15sm477472qtp.51.2021.01.24.07.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 07:07:28 -0800 (PST) From: Matt Turner To: gentoo-catalyst@lists.gentoo.org Cc: Matt Turner Subject: [gentoo-catalyst] [PATCH 3/4] catalyst: Remove fallback make.conf parsing code Date: Sun, 24 Jan 2021 10:07:21 -0500 Message-Id: <20210124150722.760520-3-mattst88@gentoo.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210124150722.760520-1-mattst88@gentoo.org> References: <20210124150722.760520-1-mattst88@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: b21f0eb2-938f-405b-a34f-f26505677dc2 X-Archives-Hash: c95e3618941614919994c298b42e211a Signed-off-by: Matt Turner --- 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