Skip to content

Commit 746db43

Browse files
committed
repo: drop repo id matching for RepoSet __getitem__() support
All string-based keys now are treated as pkg restrictions.
1 parent 5e96b5b commit 746db43

2 files changed

Lines changed: 2 additions & 10 deletions

File tree

src/pkgcraft/repo/set.pyx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,8 @@ cdef class RepoSet:
4646
elif isinstance(key, slice):
4747
# create a new RepoSet for slices
4848
return self.__class__(*list(self.repos)[key])
49-
elif isinstance(key, str):
50-
# matching repo name for strings
51-
matching_repos = (r for r in self.repos if r.id == key)
52-
if repo := next(matching_repos, None):
53-
return repo
54-
55-
# try to return the pkgs matching a restriction
56-
if pkgs := list(self.iter(key)):
49+
elif pkgs := list(self.iter(key)):
50+
# try to return the pkgs matching a restriction
5751
if len(pkgs) > 1:
5852
return pkgs
5953
return pkgs[0]

tests/repo/test_set.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ def test_getitem(self, make_fake_repo):
152152
s = self.cls(r1)
153153
assert s[:] == s
154154
assert s[0] == r1
155-
assert s["r1"] == r1
156155
assert s["cat/pkg"] == pkg
157156
assert s["cat/pkg-1"] == pkg
158157
assert s[Cpv("cat/pkg-1")] == pkg
@@ -166,7 +165,6 @@ def test_getitem(self, make_fake_repo):
166165
s = self.cls(r1, r2)
167166
assert s[:] == s
168167
assert s[-1] == r2
169-
assert s["r2"] == r2
170168
assert s["cat/pkg"] == [pkg, pkg1, pkg2]
171169
assert s["cat/pkg-1"] == [pkg, pkg1]
172170
assert s["=cat/pkg-1::r2"] == pkg1

0 commit comments

Comments
 (0)