From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 3B60A138CA3 for ; Sun, 19 Apr 2015 19:59:06 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A5303E085A; Sun, 19 Apr 2015 19:59:03 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1A410E0857 for ; Sun, 19 Apr 2015 19:59:02 +0000 (UTC) Received: from localhost.localdomain (ip174-67-205-96.oc.oc.cox.net [174.67.205.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zmedico) by smtp.gentoo.org (Postfix) with ESMTPSA id 2DD73340CBC for ; Sun, 19 Apr 2015 19:59:02 +0000 (UTC) From: Zac Medico To: gentoo-portage-dev@lists.gentoo.org Subject: [gentoo-portage-dev] [PATCH] UseManager: handle newlines for USE_EXPAND prefixes (bug 546512) Date: Sun, 19 Apr 2015 12:58:39 -0700 Message-Id: <1429473519-18251-1-git-send-email-zmedico@gentoo.org> X-Mailer: git-send-email 2.3.1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 527dff4d-4ee0-4789-8440-cc3966aae270 X-Archives-Hash: 44505cbb0d4d10301f511cd1f7a40c90 From: Albert Safin Since commit b65e1fc5fe723bd07bf034f6e08878fa3eb033cb, USE_EXPAND prefixes affected subsequent lines of the same atom in package.use. Fixes: b65e1fc5fe72 ("Support USE_EXPAND prefixes in package.use and relevant files") X-Gentoo-Bug: 546512 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=546512 --- pym/portage/package/ebuild/_config/UseManager.py | 8 +++++++- pym/portage/util/__init__.py | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pym/portage/package/ebuild/_config/UseManager.py b/pym/portage/package/ebuild/_config/UseManager.py index a93ea5c..6041802 100644 --- a/pym/portage/package/ebuild/_config/UseManager.py +++ b/pym/portage/package/ebuild/_config/UseManager.py @@ -208,6 +208,9 @@ class UseManager(object): useflags = [] use_expand_prefix = '' for prefixed_useflag in v: + if extended_syntax and prefixed_useflag == "\n": + use_expand_prefix = "" + continue if extended_syntax and prefixed_useflag[-1] == ":": use_expand_prefix = prefixed_useflag[:-1].lower() + "_" continue @@ -236,11 +239,14 @@ class UseManager(object): ret = ExtendedAtomDict(dict) if user_config: pusedict = grabdict_package( - os.path.join(location, file_name), recursive=1, allow_wildcard=True, allow_repo=True, verify_eapi=False) + os.path.join(location, file_name), recursive=1, newlines=1, allow_wildcard=True, allow_repo=True, verify_eapi=False) for k, v in pusedict.items(): l = [] use_expand_prefix = '' for flag in v: + if flag == "\n": + use_expand_prefix = "" + continue if flag[-1] == ":": use_expand_prefix = flag[:-1].lower() + "_" continue diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py index 4b82e71..48cd1b7 100644 --- a/pym/portage/util/__init__.py +++ b/pym/portage/util/__init__.py @@ -340,7 +340,7 @@ def stack_lists(lists, incremental=1, remember_source_file=False, else: return list(new_list) -def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1): +def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1, newlines=0): """ This function grabs the lines in a file, normalizes whitespace and returns lines in a dictionary @@ -354,6 +354,8 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1): @type recursive: Boolean (integer) @param incremental: Append to the return list, don't overwrite @type incremental: Boolean (integer) + @param newlines: Append newlines + @type newlines: Boolean (integer) @rtype: Dictionary @return: 1. Returns the lines in a file in a dictionary, for example: @@ -379,6 +381,8 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1): continue if len(myline) < 1 and empty == 1: continue + if newlines: + myline.append("\n") if incremental: newdict.setdefault(myline[0], []).extend(myline[1:]) else: @@ -424,7 +428,7 @@ def read_corresponding_eapi_file(filename, default="0"): return default return eapi -def grabdict_package(myfilename, juststrings=0, recursive=0, +def grabdict_package(myfilename, juststrings=0, recursive=0, newlines=0, allow_wildcard=False, allow_repo=False, allow_build_id=False, verify_eapi=False, eapi=None, eapi_default="0"): """ Does the same thing as grabdict except it validates keys @@ -438,7 +442,7 @@ def grabdict_package(myfilename, juststrings=0, recursive=0, atoms = {} for filename in file_list: d = grabdict(filename, juststrings=False, - empty=True, recursive=False, incremental=True) + empty=True, recursive=False, incremental=True, newlines=newlines) if not d: continue if verify_eapi and eapi is None: -- 2.3.1