Skip to content

Commit

Permalink
Add support for explicit list of binary names (repology/repology-weba…
Browse files Browse the repository at this point in the history
…pp#111)
  • Loading branch information
AMDmi3 committed Jun 3, 2020
1 parent 4fa0044 commit 1c76043
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions repology/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class Package:
'name',
'srcname',
'binname',
'binnames',
'trackname',
'visiblename',
'projectname_seed',
Expand Down Expand Up @@ -187,6 +188,7 @@ class Package:
name: Optional[str]
srcname: Optional[str]
binname: Optional[str]
binnames: Optional[List[str]]
trackname: Optional[str]
visiblename: str
projectname_seed: str
Expand Down Expand Up @@ -243,6 +245,7 @@ def __init__(self, *,
name: Optional[str] = None,
srcname: Optional[str] = None,
binname: Optional[str] = None,
binnames: Optional[List[str]] = None,
trackname: Optional[str] = None,

arch: Optional[str] = None,
Expand Down Expand Up @@ -277,6 +280,7 @@ def __init__(self, *,
self.name = name
self.srcname = srcname
self.binname = binname
self.binnames = binnames
self.trackname = trackname
self.visiblename = visiblename
self.projectname_seed = projectname_seed
Expand Down
11 changes: 11 additions & 0 deletions repology/packagemaker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class PackageTemplate:
'origversion',
'rawversion',

'binnames',

'arch',
'summary',
'maintainers',
Expand Down Expand Up @@ -69,6 +71,8 @@ class PackageTemplate:
origversion: Optional[str]
rawversion: Optional[str]

binnames: List[str]

arch: Optional[str]
summary: Optional[str]
maintainers: List[str]
Expand Down Expand Up @@ -99,6 +103,8 @@ def __init__(self) -> None:
self.origversion = None
self.rawversion = None

self.binnames = []

self.arch = None
self.summary = None
self.maintainers = []
Expand Down Expand Up @@ -233,6 +239,10 @@ def _get_ident(self) -> str:
def add_name(self, name: str, name_type: int) -> None:
self._name_mapper.add_name(name, name_type)

@_omnivorous_setter('binname', str, nzs.strip, nzs.forbid_newlines)
def add_binnames(self, *args: Any) -> None:
_extend_unique(self._package.binnames, args)

@_simple_setter('version', str, nzs.strip, nzs.forbid_newlines)
def set_version(self, version: str, version_normalizer: Optional[Callable[[str], str]] = None) -> None:
self._package.rawversion = version
Expand Down Expand Up @@ -323,6 +333,7 @@ def spawn(self, repo: str, family: str, subrepo: Optional[str] = None, shadow: b
name=names.name,
srcname=names.srcname,
binname=names.binname,
binnames=self._package.binnames if self._package.binnames else None,
trackname=names.trackname,
visiblename=names.visiblename,
projectname_seed=names.projectname_seed,
Expand Down
1 change: 1 addition & 0 deletions repology/parsers/parsers/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def _extra_handling(self, pkg: PackageMaker, pkgdata: Dict[str, str]) -> None:
assert('Binary' in pkgdata)
assert('Source' not in pkgdata)
pkg.add_name(pkgdata['Package'], NameType.DEBIAN_SOURCE_PACKAGE)
pkg.add_binnames(pkgdata['Binary'].split(', '))

def iter_parse(self, path: str, factory: PackageFactory, transformer: PackageTransformer) -> Iterable[PackageMaker]:
for pkgdata in _iter_packages(path):
Expand Down
2 changes: 2 additions & 0 deletions repology/test/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def check_package(self, reference: Dict[str, Any]) -> None:
'name': None,
'srcname': None,
'binname': None,
'binnames': None,
# trackname must be filled
# visiblename must be filled
# proectname_seed must be filled
Expand Down Expand Up @@ -262,6 +263,7 @@ def test_debian(self) -> None:
'category': 'devel',
'family': 'debuntu',
'srcname': 'a52dec',
'binnames': ['liba52-0.7.4', 'liba52-0.7.4-dev'],
'trackname': 'a52dec',
'visiblename': 'a52dec',
'projectname_seed': 'a52dec',
Expand Down
2 changes: 2 additions & 0 deletions sql.d/packages/add_packages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ INSERT INTO incoming_packages (
name,
srcname,
binname,
binnames,
visiblename,
projectname_seed,
trackname,
Expand Down Expand Up @@ -74,6 +75,7 @@ INSERT INTO incoming_packages (
%(name)s,
%(srcname)s,
%(binname)s,
%(binnames)s,
%(visiblename)s,
%(projectname_seed)s,
%(trackname)s,
Expand Down
1 change: 1 addition & 0 deletions sql.d/update/create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ CREATE TABLE packages (
name text NULL,
srcname text NULL,
binname text NULL,
binnames text[] NULL,
trackname text NOT NULL,
visiblename text NOT NULL,
projectname_seed text NOT NULL,
Expand Down
2 changes: 2 additions & 0 deletions sql.d/update/update_apply_packages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ INSERT INTO packages (
name,
srcname,
binname,
binnames,
trackname,
visiblename,
projectname_seed,
Expand Down Expand Up @@ -73,6 +74,7 @@ INSERT INTO packages (
name,
srcname,
binname,
binnames,
trackname,
visiblename,
projectname_seed,
Expand Down
2 changes: 2 additions & 0 deletions sql.d/update/update_names.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ FROM (
SELECT effname, repo, 'srcname'::project_name_type AS name_type, srcname FROM incoming_packages WHERE srcname IS NOT NULL
UNION
SELECT effname, repo, 'binname'::project_name_type AS name_type, binname FROM incoming_packages WHERE binname IS NOT NULL
UNION
SELECT effname, repo, 'binname'::project_name_type AS name_type, unnest(binnames) FROM incoming_packages WHERE binnames IS NOT NULL
) AS tmp;

{% if analyze %}
Expand Down
1 change: 1 addition & 0 deletions sql.d/update/update_start.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ CREATE TEMPORARY TABLE incoming_packages (
name text NULL,
srcname text NULL,
binname text NULL,
binnames text[] NULL,
trackname text NOT NULL,
visiblename text NOT NULL,
projectname_seed text NOT NULL,
Expand Down

0 comments on commit 1c76043

Please sign in to comment.