3535from pkgcore .ebuild .atom import atom
3636from pkgcore .ebuild .ebuild_src import package
3737from pkgcore .ebuild .errors import MalformedAtom
38+ from pkgcore .ebuild .keywording import suggested_keywords
3839from pkgcore .ebuild .misc import sort_keywords
3940from pkgcore .ebuild .repo_objs import LocalMetadataXml , ProjectsXml
4041from pkgcore .package .mutated import MutatedPkg
@@ -57,7 +58,7 @@ class StoreTargetArches(commandline.StoreTarget):
5758 """``StoreTarget`` variant accepting trailing arches after each atom.
5859
5960 A target may carry a whitespace separated list of arches after the atom,
60- nattka-style , e.g. ``=cat/pkg-1.0 amd64 x86``. This produces 3-tuples
61+ as a bug's package list does , e.g. ``=cat/pkg-1.0 amd64 x86``. This produces 3-tuples
6162 ``(token, restriction, arches)`` instead of the usual ``(token, restriction)``.
6263
6364 Note: this reimplements ``StoreTarget.__call__`` (it cannot inject the arch
@@ -278,27 +279,6 @@ def _validate_args(parser, namespace):
278279 namespace .bugzilla = Bugzilla (namespace .api_key , user_agent = f"pkgdev-bugs/{ __version__ } " )
279280
280281
281- def _get_suggested_keywords (repo , pkg : package , streq : bool = True ):
282- # for stablereq only consider already stable keywords on other versions, for
283- # keywordreq also consider ~arch keywords (those can be propagated as new keywords)
284- disallow_prefix = "-~" if streq else "-"
285- match_keywords = {
286- x .lstrip ("~" )
287- for pkgver in repo .match (pkg .unversioned_atom )
288- for x in pkgver .keywords
289- if x [0 ] not in disallow_prefix
290- }
291-
292- if streq :
293- # limit stablereq to whatever is ~arch right now
294- match_keywords .intersection_update (x .lstrip ("~" ) for x in pkg .keywords if x [0 ] == "~" )
295- else :
296- # limit keywordreq to missing keywords (strip all keywords already present)
297- match_keywords .difference_update (x .lstrip ("~-" ) for x in pkg .keywords )
298-
299- return frozenset ({x for x in match_keywords if "-" not in x })
300-
301-
302282def parse_atom (pkg : str ):
303283 try :
304284 return atom (pkg )
@@ -369,7 +349,7 @@ def cleanup_keywords(self, repo):
369349 previous = frozenset (keywords )
370350
371351 for pkg , keywords in self .pkgs :
372- suggested = _get_suggested_keywords (repo , pkg , streq = not self .is_keywordreq )
352+ suggested = suggested_keywords (repo , pkg , stable = not self .is_keywordreq )
373353 if keywords == set (suggested ):
374354 keywords .clear ()
375355 keywords .add ("*" )
@@ -780,7 +760,7 @@ def explore_deps(pkg: package, arches: set[str], category: BugCategory):
780760 streq = category is STABLEREQ
781761 verb = category .verb
782762 if streq :
783- keywords .update (_get_suggested_keywords (self .options .repo , pkg , streq = True ))
763+ keywords .update (suggested_keywords (self .options .repo , pkg , stable = True ))
784764 if not keywords :
785765 # nothing left to stabilize (already stable or never keyworded)
786766 self .out .write (f"Nothing to stable for { pkg .unversioned_atom } " )
@@ -789,7 +769,7 @@ def explore_deps(pkg: package, arches: set[str], category: BugCategory):
789769 # explicit (command line) or dependency-driven arches are authoritative;
790770 # only fall back to the other-versions heuristic when none were given
791771 if not keywords :
792- keywords .update (_get_suggested_keywords (self .options .repo , pkg , streq = False ))
772+ keywords .update (suggested_keywords (self .options .repo , pkg , stable = False ))
793773 if not keywords :
794774 # keywordreq with no derivable arches: the user must specify them
795775 bugs .error (
0 commit comments