Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] UseManager: handle newlines for USE_EXPAND prefixes (bug 546512)
Date: Tue, 21 Apr 2015 23:21:29
Message-Id: 20150421162124.28734421.dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] UseManager: handle newlines for USE_EXPAND prefixes (bug 546512) by Zac Medico
1 On Sun, 19 Apr 2015 12:58:39 -0700
2 Zac Medico <zmedico@g.o> wrote:
3
4 > From: Albert Safin <xzfcpw@×××××.com>
5 >
6 > Since commit b65e1fc5fe723bd07bf034f6e08878fa3eb033cb, USE_EXPAND
7 > prefixes affected subsequent lines of the same atom in package.use.
8 >
9 > Fixes: b65e1fc5fe72 ("Support USE_EXPAND prefixes in package.use and
10 > relevant files") X-Gentoo-Bug: 546512
11 > X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=546512
12 > ---
13 > pym/portage/package/ebuild/_config/UseManager.py | 8 +++++++-
14 > pym/portage/util/__init__.py | 10 +++++++---
15 > 2 files changed, 14 insertions(+), 4 deletions(-)
16 >
17 > diff --git a/pym/portage/package/ebuild/_config/UseManager.py
18 > b/pym/portage/package/ebuild/_config/UseManager.py index
19 > a93ea5c..6041802 100644 ---
20 > a/pym/portage/package/ebuild/_config/UseManager.py +++
21 > b/pym/portage/package/ebuild/_config/UseManager.py @@ -208,6 +208,9
22 > @@ class UseManager(object): useflags = []
23 > use_expand_prefix = ''
24 > for prefixed_useflag in v:
25 > + if extended_syntax and
26 > prefixed_useflag == "\n":
27 > + use_expand_prefix = ""
28 > + continue
29 > if extended_syntax and
30 > prefixed_useflag[-1] == ":": use_expand_prefix =
31 > prefixed_useflag[:-1].lower() + "_" continue
32 > @@ -236,11 +239,14 @@ class UseManager(object):
33 > ret = ExtendedAtomDict(dict)
34 > if user_config:
35 > pusedict = grabdict_package(
36 > - os.path.join(location, file_name),
37 > recursive=1, allow_wildcard=True, allow_repo=True, verify_eapi=False)
38 > + os.path.join(location, file_name),
39 > recursive=1, newlines=1, allow_wildcard=True, allow_repo=True,
40 > verify_eapi=False) for k, v in pusedict.items(): l = []
41 > use_expand_prefix = ''
42 > for flag in v:
43 > + if flag == "\n":
44 > + use_expand_prefix =
45 > ""
46 > + continue
47 > if flag[-1] == ":":
48 > use_expand_prefix =
49 > flag[:-1].lower() + "_" continue
50 > diff --git a/pym/portage/util/__init__.py
51 > b/pym/portage/util/__init__.py index 4b82e71..48cd1b7 100644
52 > --- a/pym/portage/util/__init__.py
53 > +++ b/pym/portage/util/__init__.py
54 > @@ -340,7 +340,7 @@ def stack_lists(lists, incremental=1,
55 > remember_source_file=False, else:
56 > return list(new_list)
57 >
58 > -def grabdict(myfilename, juststrings=0, empty=0, recursive=0,
59 > incremental=1): +def grabdict(myfilename, juststrings=0, empty=0,
60 > recursive=0, incremental=1, newlines=0): """
61 > This function grabs the lines in a file, normalizes
62 > whitespace and returns lines in a dictionary
63 > @@ -354,6 +354,8 @@ def grabdict(myfilename, juststrings=0, empty=0,
64 > recursive=0, incremental=1): @type recursive: Boolean (integer)
65 > @param incremental: Append to the return list, don't
66 > overwrite @type incremental: Boolean (integer)
67 > + @param newlines: Append newlines
68 > + @type newlines: Boolean (integer)
69 > @rtype: Dictionary
70 > @return:
71 > 1. Returns the lines in a file in a dictionary, for example:
72 > @@ -379,6 +381,8 @@ def grabdict(myfilename, juststrings=0, empty=0,
73 > recursive=0, incremental=1): continue
74 > if len(myline) < 1 and empty == 1:
75 > continue
76 > + if newlines:
77 > + myline.append("\n")
78 > if incremental:
79 > newdict.setdefault(myline[0],
80 > []).extend(myline[1:]) else:
81 > @@ -424,7 +428,7 @@ def read_corresponding_eapi_file(filename,
82 > default="0"): return default
83 > return eapi
84 >
85 > -def grabdict_package(myfilename, juststrings=0, recursive=0,
86 > +def grabdict_package(myfilename, juststrings=0, recursive=0,
87 > newlines=0, allow_wildcard=False, allow_repo=False,
88 > allow_build_id=False, verify_eapi=False, eapi=None, eapi_default="0"):
89 > """ Does the same thing as grabdict except it validates keys
90 > @@ -438,7 +442,7 @@ def grabdict_package(myfilename, juststrings=0,
91 > recursive=0, atoms = {}
92 > for filename in file_list:
93 > d = grabdict(filename, juststrings=False,
94 > - empty=True, recursive=False,
95 > incremental=True)
96 > + empty=True, recursive=False,
97 > incremental=True, newlines=newlines) if not d:
98 > continue
99 > if verify_eapi and eapi is None:
100
101 yeah, LGTM
102
103 --
104 Brian Dolbec <dolsen>