swh.lister.nuget.lister module#

class swh.lister.nuget.lister.NugetListerState(last_listing_date: datetime | None = None)[source]#

Bases: object

Store lister state for incremental mode operations

last_listing_date: datetime | None = None#

Last date from main http api endpoint when lister was executed

class swh.lister.nuget.lister.NugetLister(scheduler: SchedulerInterface, url: str = 'https://api.nuget.org/v3/catalog0/index.json', instance: str = 'nuget', credentials: Dict[str, Dict[str, List[Dict[str, str]]]] | None = None, max_origins_per_page: int | None = None, max_pages: int | None = None, enable_origins: bool = True)[source]#

Bases: Lister[NugetListerState, List[Dict[str, str]]]

List Nuget (Package manager for .NET) origins.

LISTER_NAME: str = 'nuget'#
INSTANCE = 'nuget'#
API_INDEX_URL = 'https://api.nuget.org/v3/catalog0/index.json'#
state_from_dict(d: Dict[str, Any]) NugetListerState[source]#

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

state_to_dict(state: NugetListerState) 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[List[Dict[str, str]]][source]#

Yield an iterator which returns ‘page’

It uses the following endpoint https://api.nuget.org/v3/catalog0/index.json to get a list of pages endpoint to iterate.

get_origins_from_page(page: List[Dict[str, str]]) Iterator[ListedOrigin][source]#

Iterate on all pages and yield ListedOrigin instances. .NET packages are binary, dll, etc. We retrieve only packages for which we can find a vcs repository.

To check if a vcs repository exists, we need for each entry in a page to retrieve a .nuspec file, which is a package metadata xml file, and search for a repository value.

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.