Skip to content

Commit

Permalink
Homebrew parser: chase updated urls format
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Oct 16, 2023
1 parent 1b59eac commit eb24c79
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions repology/parsers/parsers/homebrew.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,44 @@
from repology.parsers.json import iter_json_list


_FILE_USINGS = {
'homebrew_curl',
'nounzip',
}

_VCS_USINGS = {
'bzr',
'cvs',
'fossil',
'git',
'hg',
'svn',
}


@dataclass
class _UrlData:
url: str
tag: str | None = None
revision: str | None = None
checksum: str | None = None
branch: str | None = None
using: str | None = None

# checksum presence is sufficient ATOW, howerver be stricter,
# as there seem to be ongoing migration onto `using` field in homebrew
# and things may break unexpectedly
def is_file(self) -> bool:
# just checksum seems to be sufficient
return self.checksum is not None
if self.using is not None:
return self.using in _FILE_USINGS and self.checksum is not None
else:
return self.checksum is not None

def is_vcs(self) -> bool:
return self.checksum is None
if self.using is not None:
return self.using in _VCS_USINGS and self.checksum is None
else:
return self.checksum is None


class HomebrewJsonParser(Parser):
Expand Down

0 comments on commit eb24c79

Please sign in to comment.