mirror of
https://github.com/pypiserver/pypiserver
synced 2025-02-22 19:19:37 +01:00
handle package names case insensitive in filter_latest_pkgs
we probably also need to normalize _ vs - someday
This commit is contained in:
parent
16e3a2cd14
commit
b2c6410a39
@ -61,10 +61,12 @@ def filter_latest_pkgs(pkgs):
|
||||
pkgname2latest = {}
|
||||
|
||||
for x in pkgs:
|
||||
if x.pkgname not in pkgname2latest:
|
||||
pkgname2latest[x.pkgname] = x
|
||||
elif x.parsed_version > pkgname2latest[x.pkgname].parsed_version:
|
||||
pkgname2latest[x.pkgname] = x
|
||||
pkgname = x.pkgname.lower()
|
||||
|
||||
if pkgname not in pkgname2latest:
|
||||
pkgname2latest[pkgname] = x
|
||||
elif x.parsed_version > pkgname2latest[pkgname].parsed_version:
|
||||
pkgname2latest[pkgname] = x
|
||||
|
||||
return pkgname2latest.values()
|
||||
|
||||
|
@ -56,3 +56,12 @@ def test_filter_latest_pkgs():
|
||||
pkgs = [pkgfile_from_path(x) for x in paths]
|
||||
|
||||
assert frozenset(filter_latest_pkgs(pkgs)) == frozenset(pkgs[1:])
|
||||
|
||||
|
||||
def test_filter_latest_pkgs_case_insensitive():
|
||||
paths = ["/home/ralf/greenlet-0.2.zip",
|
||||
"/home/ralf/foo/baz-1.0.zip"
|
||||
"/home/ralf/bar/Greenlet-0.3.zip"]
|
||||
pkgs = [pkgfile_from_path(x) for x in paths]
|
||||
|
||||
assert frozenset(filter_latest_pkgs(pkgs)) == frozenset(pkgs[1:])
|
||||
|
Loading…
Reference in New Issue
Block a user