swh.lister.launchpad.lister module

class swh.lister.launchpad.lister.LaunchpadListerState(date_last_modified: Optional[datetime.datetime] = None)[source]

Bases: object

State of Launchpad lister

date_last_modified: Optional[datetime.datetime] = None

modification date of last updated repository since last listing

class swh.lister.launchpad.lister.LaunchpadLister(scheduler: swh.scheduler.interface.SchedulerInterface, incremental: bool = False, credentials: Optional[Dict[str, Dict[str, List[Dict[str, str]]]]] = None)[source]

Bases: swh.lister.pattern.Lister[swh.lister.launchpad.lister.LaunchpadListerState, Iterator[lazr.restfulclient.resource.Collection]]

List git repositories from Launchpad.

Parameters
  • scheduler – instance of SchedulerInterface

  • incremental – defines if incremental listing should be used, in that case only modified or new repositories since last incremental listing operation will be returned

LISTER_NAME: str = 'launchpad'
state_from_dict(d: Dict[str, Any]) swh.lister.launchpad.lister.LaunchpadListerState[source]

Convert the state stored in the scheduler backend (as a dict), to the concrete StateType for this lister.

state_to_dict(state: swh.lister.launchpad.lister.LaunchpadListerState) Dict[str, Any][source]

Convert the StateType for this lister to its serialization as dict for storage in the scheduler.

Values must be JSON-compatible as that’s what the backend database expects.

get_pages() Iterator[Iterator[lazr.restfulclient.resource.Collection]][source]

Yields an iterator on all git repositories hosted on Launchpad sorted by last modification date in ascending order.

get_origins_from_page(page: Iterator[lazr.restfulclient.resource.Collection]) Iterator[swh.scheduler.model.ListedOrigin][source]

Iterate on all git repositories and yield ListedOrigin instances.

finalize() None[source]

Custom hook to finalize the lister state before returning from the main loop.

This method must set updated if the lister has done some work.

If relevant, this method can use :meth`get_state_from_scheduler` to merge the current lister state with the one from the scheduler backend, reducing the risk of race conditions if we’re running concurrent listings.

This method is called in a finally block, which means it will also run when the lister fails.