swh.lister.elm.lister module#

class swh.lister.elm.lister.ElmListerState(all_packages_count: int | None = None)[source]#

Bases: object

Store lister state for incremental mode operations

all_packages_count: int | None = None#

Store the count of all existing packages, used as since argument of API endpoint url.

class swh.lister.elm.lister.ElmLister(scheduler: SchedulerInterface, credentials: Dict[str, Dict[str, List[Dict[str, str]]]] | None = None, url: str = 'https://package.elm-lang.org', instance: str = 'elm', max_origins_per_page: int | None = None, max_pages: int | None = None, enable_origins: bool = True)[source]#

Bases: Lister[ElmListerState, Set[str]]

List Elm packages origins

LISTER_NAME: str = 'elm'#
VISIT_TYPE = 'git'#
INSTANCE = 'elm'#
BASE_URL = 'https://package.elm-lang.org'#
ALL_PACKAGES_URL_PATTERN = '{base_url}/all-packages/since/{since}'#
REPO_URL_PATTERN = 'https://github.com/{name}'#
state_from_dict(d: Dict[str, Any]) ElmListerState[source]#

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

state_to_dict(state: ElmListerState) 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[Set[str]][source]#

Yield an iterator which returns ‘page’

It uses the Http api endpoint https://package.elm-lang.org/all-packages/since/:since to get a list of packages versions from where we get names corresponding to GitHub repository url suffixes.

There is only one page that list all origins urls.

get_origins_from_page(page: Set[str]) Iterator[ListedOrigin][source]#

Iterate on all pages 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.