Skip to content

Commit

Permalink
hackage parser: pass cabal file name as ident
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Mar 4, 2024
1 parent 04c4399 commit 4b619a7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions repology/parsers/parsers/hackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _extract_tarinfo(tar: tarfile.TarFile, tarinfo: tarfile.TarInfo) -> str:
return extracted.read().decode('utf-8-sig')


def _iter_hackage_tarfile_multipass(path: str) -> Iterable[dict[str, str]]:
def _iter_hackage_tarfile_multipass(path: str) -> Iterable[tuple[str, dict[str, str]]]:
preferred_versions: dict[str, str] = {}
latest_versions: dict[str, list[Any]] = {} # name -> [version, count]

Expand Down Expand Up @@ -118,7 +118,7 @@ def _iter_hackage_tarfile_multipass(path: str) -> Iterable[dict[str, str]]:
if latest_versions[name][1] > 1:
latest_versions[name][1] -= 1
else:
yield _parse_cabal_file(StringIO(_extract_tarinfo(tar, tarinfo)))
yield tarinfo.name, _parse_cabal_file(StringIO(_extract_tarinfo(tar, tarinfo)))


class HackageParserBase(Parser):
Expand All @@ -127,8 +127,8 @@ def _iterate(self, path: str) -> Iterable[dict[str, str]]:
pass

def iter_parse(self, path: str, factory: PackageFactory) -> Iterable[PackageMaker]:
for cabaldata in _iter_hackage_tarfile_multipass(path):
with factory.begin() as pkg:
for filename, cabaldata in _iter_hackage_tarfile_multipass(path):
with factory.begin(filename) as pkg:
pkg.add_name(cabaldata['name'], NameType.HACKAGE_NAME)
pkg.set_version(cabaldata['version'])

Expand Down

0 comments on commit 4b619a7

Please sign in to comment.