From f70d870a63f7c75d89518ad33ea486e63f9ac75f Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 21 Mar 2019 19:28:18 +0100 Subject: [WIP] Check whether the package is actually a devel package for Factory. --- dlpcvp.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'dlpcvp.py') diff --git a/dlpcvp.py b/dlpcvp.py index c786741..b4dacb6 100755 --- a/dlpcvp.py +++ b/dlpcvp.py @@ -115,6 +115,27 @@ def update_etags(con: sqlite3.Connection, pkg: str, con.commit() +def is_develpackage(proj: str, pkg: str) -> bool: + req = Request(url=OBS_base + f'/source/openSUSE:Factory/{pkg}/_meta') + log.debug('Looking up URL: %s', req.full_url) + try: + with opener.open(req) as resp: + xml_data = ET.parse(resp) + for pel in xml_data.iter('package'): + for delem in pel.iter('devel'): + if pel.attrib['name'] == pkg and \ + delem.attrib['package'] == pkg and \ + delem.attrib['project'] == proj: + return True + return False + except HTTPError as ex: + if ex.getcode() == 404: + log.warning(f'Cannot acquire _meta of {pkg}.') + return None + else: + raise + + def parse_spec(spec_file: Union[str, bytes]) -> LooseVersion: if isinstance(spec_file, bytes): spec_file = spec_file.decode() @@ -260,6 +281,8 @@ def main(prj): suse_ver = package_version(prj, pkg, conn) if suse_ver is None: raise RuntimeError('not in OBS') + if not is_develpackage(prj, pkg): + continue pypi_ver = get_version_from_pypi(pypi_name, conn) if pypi_ver is None: raise RuntimeError('not in PyPI') -- cgit