diff --git a/swh/lister/launchpad/lister.py b/swh/lister/launchpad/lister.py --- a/swh/lister/launchpad/lister.py +++ b/swh/lister/launchpad/lister.py @@ -25,6 +25,9 @@ LaunchpadPageType = Tuple[VcsType, Collection] +SUPPORTED_VCS_TYPES = ("git", "bzr") + + @dataclass class LaunchpadListerState: """State of Launchpad lister""" @@ -76,7 +79,7 @@ } def state_from_dict(self, d: Dict[str, Any]) -> LaunchpadListerState: - for vcs_type in ["git", "bzr"]: + for vcs_type in SUPPORTED_VCS_TYPES: key = f"{vcs_type}_date_last_modified" date_last_modified = d.get(key) if date_last_modified is not None: @@ -86,7 +89,7 @@ def state_to_dict(self, state: LaunchpadListerState) -> Dict[str, Any]: d: Dict[str, Optional[str]] = {} - for vcs_type in ["git", "bzr"]: + for vcs_type in SUPPORTED_VCS_TYPES: attribute_name = f"{vcs_type}_date_last_modified" d[attribute_name] = None @@ -126,7 +129,7 @@ "git": self.state.git_date_last_modified, "bzr": self.state.bzr_date_last_modified, } - for vcs_type in ["git", "bzr"]: + for vcs_type in SUPPORTED_VCS_TYPES: try: result = self._page_request( launchpad, vcs_type, self.date_last_modified[vcs_type] @@ -147,19 +150,11 @@ vcs_type, repos = page - assert vcs_type in {"git", "bzr"} - - prev_origin_url: Dict[str, Optional[str]] = {"git": None, "bzr": None} - for repo in repos: origin_url = origin(vcs_type, repo) - # filter out origins with invalid URL or origin previously listed - # (last modified repository will be listed twice by launchpadlib) - if ( - not origin_url.startswith("https://") - or origin_url == prev_origin_url[vcs_type] - ): + # filter out origins with invalid URL + if not origin_url.startswith("https://"): continue last_update = repo.date_last_modified @@ -173,8 +168,6 @@ last_update, ) - prev_origin_url[vcs_type] = origin_url - yield ListedOrigin( lister_id=self.lister_obj.id, visit_type=vcs_type,