From 209e9d6042c2ddbca6ba1bcbef6213d568753fa2 Mon Sep 17 00:00:00 2001 From: Albert Safin Date: Wed, 15 Apr 2015 02:28:55 +0600 Subject: [PATCH] Make USE_EXPAND do not affect subsequent lines of same atom in package.use --- 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.5