Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o, Chun-Yu Shei <cshei@××××××.com>
Subject: Re: [gentoo-portage-dev] [PATCH] Add caching to use_reduce, vercmp, and catpkgsplit
Date: Sun, 12 Jul 2020 21:47:16
Message-Id: db754cb4-dd10-c8b3-aab5-ab1c946fcd39@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] Add caching to use_reduce, vercmp, and catpkgsplit by Chun-Yu Shei
1 On 7/9/20 12:03 AM, Chun-Yu Shei wrote:
2 > +def use_reduce(depstr, uselist=(), masklist=(), matchall=False, excludeall=(), is_src_uri=False, \
3 > + eapi=None, opconvert=False, flat=False, is_valid_flag=None, token_class=None, matchnone=False,
4 > + subset=None):
5 > + """
6 > + Takes a dep string and reduces the use? conditionals out, leaving an array
7 > + with subarrays. All redundant brackets are removed.
8 > +
9 > + @param depstr: depstring
10 > + @type depstr: String
11 > + @param uselist: Sequence of use enabled flags
12 > + @type uselist: Sequence
13 > + @param masklist: Sequence of masked flags (always treated as disabled)
14 > + @type masklist: Sequence
15 > + @param matchall: Treat all conditionals as active. Used by repoman.
16 > + @type matchall: Bool
17 > + @param excludeall: Sequence of flags for which negated conditionals are always treated as inactive.
18 > + @type excludeall: Sequence
19 > + @param is_src_uri: Indicates if depstr represents a SRC_URI
20 > + @type is_src_uri: Bool
21 > + @param eapi: Indicates the EAPI the dep string has to comply to
22 > + @type eapi: String
23 > + @param opconvert: Put every operator as first element into it's argument list
24 > + @type opconvert: Bool
25 > + @param flat: Create a flat list of all tokens
26 > + @type flat: Bool
27 > + @param is_valid_flag: Function that decides if a given use flag might be used in use conditionals
28 > + @type is_valid_flag: Function
29 > + @param token_class: Convert all non operator tokens into this class
30 > + @type token_class: Class
31 > + @param matchnone: Treat all conditionals as inactive. Used by digestgen().
32 > + @type matchnone: Bool
33 > + @param subset: Select a subset of dependencies conditional on the given flags
34 > + @type subset: Sequence
35 > + @rtype: List
36 > + @return: The use reduced depend array
37 > + """
38 > + if isinstance(depstr, list):
39 > + if portage._internal_caller:
40 > + warnings.warn(_("Passing paren_reduced dep arrays to %s is deprecated. " + \
41 > + "Pass the original dep string instead.") % \
42 > + ('portage.dep.use_reduce',), DeprecationWarning, stacklevel=2)
43 > + depstr = paren_enclose(depstr)
44 > +
45 > + if uselist is not None:
46 > + uselist = tuple(uselist)
47 > + if masklist is not None:
48 > + masklist = tuple(masklist)
49 > + if excludeall is not None:
50 > + excludeall = tuple(excludeall)
51 > + if subset is not None:
52 > + subset = tuple(subset)
53
54 The patch looks great, but maybe it's better if we use frozenset instead
55 of tuple for these.
56 --
57 Thanks,
58 Zac

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-portage-dev] [PATCH] Add caching to use_reduce, Chun-Yu Shei <cshei@××××××.com>