Skip to content

Commit bbac18e

Browse files
committed
drop the nattka dependency
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent bfb9e98 commit bbac18e

4 files changed

Lines changed: 13 additions & 42 deletions

File tree

‎pyproject.toml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dynamic = ["version"]
2929

3030
dependencies = [
3131
"snakeoil~=0.11.1",
32-
"pkgcore~=0.12.38",
32+
"pkgcore@git+https://github.com/pkgcore/pkgcore.git#master",
3333
"pkgcheck~=0.10.42",
3434
]
3535

@@ -42,7 +42,6 @@ doc = [
4242
"sphinx",
4343
]
4444
tatt = [
45-
"nattka",
4645
"Jinja2",
4746
]
4847

‎src/pkgdev/scripts/pkgdev_bugs.py‎

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from pkgcore.ebuild.atom import atom
3636
from pkgcore.ebuild.ebuild_src import package
3737
from pkgcore.ebuild.errors import MalformedAtom
38+
from pkgcore.ebuild.keywording import suggested_keywords
3839
from pkgcore.ebuild.misc import sort_keywords
3940
from pkgcore.ebuild.repo_objs import LocalMetadataXml, ProjectsXml
4041
from 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-
302282
def 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(

‎src/pkgdev/scripts/pkgdev_tatt.py‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from pathlib import Path
1010
from typing import NamedTuple
1111

12+
from pkgcore.bugzilla import Bug, BugCategory, Bugzilla
1213
from pkgcore.bugzilla.apikey import BugzillaApiKey
1314
from pkgcore.restrictions import boolean, packages, values
1415
from pkgcore.restrictions.required_use import find_constraint_satisfaction, iter_flags
@@ -266,22 +267,11 @@ def _validate_args(parser, namespace):
266267

267268

268269
def _get_bugzilla_packages(namespace):
269-
from nattka.package import match_package_list
270-
271-
try:
272-
from nattka.bugzilla import BugCategory, NattkaBugzilla
273-
274-
nattka_bugzilla = NattkaBugzilla(api_key=namespace.api_key)
275-
bug = next(iter(nattka_bugzilla.find_bugs(bugs=[namespace.bug]).values()))
276-
except ImportError:
277-
from pkgcore.bugzilla import BugCategory, Bugzilla
278-
279-
bug = Bugzilla(api_key=namespace.api_key).get(namespace.bug)
280-
270+
bug: Bug = Bugzilla(namespace.api_key).get(namespace.bug)
281271
namespace.keywording = bug.category == BugCategory.KEYWORDREQ
282272
repo = namespace.domain.repos["gentoo"].raw_repo
283273
src_repo = namespace.domain.source_repos_raw
284-
for pkg, _ in match_package_list(repo, bug, only_new=True, filter_arch=[namespace.domain.arch]):
274+
for pkg, _ in bug.match_packages(repo, only_new=True, filter_arch=[namespace.domain.arch]):
285275
yield src_repo.match(pkg.versioned_atom)[0]
286276

287277

‎tests/scripts/test_pkgdev_bugs.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,21 @@ def test_missing_deps_of_existing_bug(self, repo, bugzilla_cassette):
121121

122122

123123
class TestSuggestedKeywords:
124+
"""pkgcore owns the rule; these pin the semantics pkgdev relies on."""
125+
124126
def test_stablereq(self, repo):
125127
repo.create_ebuild("cat/a-1", KEYWORDS=["amd64", "x86"])
126128
repo.create_ebuild("cat/a-2", KEYWORDS=["amd64", "~x86"])
127129
pkg = max(repo.itermatch(atom("=cat/a-2")))
128130
# only ~arch keywords here that are stable on another version may be stabilized
129-
assert bugs._get_suggested_keywords(repo, pkg, streq=True) == frozenset({"x86"})
131+
assert bugs.suggested_keywords(repo, pkg, stable=True) == frozenset({"x86"})
130132

131133
def test_keywordreq(self, repo):
132134
repo.create_ebuild("cat/a-1", KEYWORDS=["~amd64", "~x86"])
133135
repo.create_ebuild("cat/a-2", KEYWORDS=["~amd64"])
134136
pkg = max(repo.itermatch(atom("=cat/a-2")))
135137
# keywords present on other versions but missing here are suggested
136-
assert bugs._get_suggested_keywords(repo, pkg, streq=False) == frozenset({"x86"})
138+
assert bugs.suggested_keywords(repo, pkg, stable=False) == frozenset({"x86"})
137139

138140

139141
def mk_graph(repo, category=BugCategory.STABLEREQ):

0 commit comments

Comments
 (0)