Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/nixguix/lister.py
Show First 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | def get_pages(self) -> Iterator[PageResult]: | ||||
# "type": "hg", | # "type": "hg", | ||||
# "type": "no-origin", <<<<<<<<< noise | # "type": "no-origin", <<<<<<<<< noise | ||||
# "type": "svn", | # "type": "svn", | ||||
# "type": "url", | # "type": "url", | ||||
# grep '"type"' nixpkgs-sources-unstable.json | sort | uniq | # grep '"type"' nixpkgs-sources-unstable.json | sort | uniq | ||||
# "type": "url", | # "type": "url", | ||||
for artifact in raw_data["sources"]: | sources = raw_data["sources"] | ||||
vlorentz: More readable, IMO.
(and remove the import) | |||||
random.shuffle(sources) | |||||
for artifact in sources: | |||||
artifact_type = artifact["type"] | artifact_type = artifact["type"] | ||||
if artifact_type in VCS_SUPPORTED: | if artifact_type in VCS_SUPPORTED: | ||||
plain_url = artifact[VCS_KEYS_MAPPING[artifact_type]["url"]] | plain_url = artifact[VCS_KEYS_MAPPING[artifact_type]["url"]] | ||||
plain_ref = artifact[VCS_KEYS_MAPPING[artifact_type]["ref"]] | plain_ref = artifact[VCS_KEYS_MAPPING[artifact_type]["ref"]] | ||||
artifact_url = ( | artifact_url = ( | ||||
self.github_session.get_canonical_url(plain_url) | self.github_session.get_canonical_url(plain_url) | ||||
if self.github_session | if self.github_session | ||||
else plain_url | else plain_url | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | def artifact_to_listed_origin(self, artifact: Artifact) -> Iterator[ListedOrigin]: | ||||
) | ) | ||||
def get_origins_from_page( | def get_origins_from_page( | ||||
self, artifact_tuple: PageResult | self, artifact_tuple: PageResult | ||||
) -> Iterator[ListedOrigin]: | ) -> Iterator[ListedOrigin]: | ||||
"""Given an artifact tuple (type, artifact), yield a ListedOrigin.""" | """Given an artifact tuple (type, artifact), yield a ListedOrigin.""" | ||||
artifact_type, artifact = artifact_tuple | artifact_type, artifact = artifact_tuple | ||||
mapping_type_fn = getattr(self, f"{artifact_type.value}_to_listed_origin") | mapping_type_fn = getattr(self, f"{artifact_type.value}_to_listed_origin") | ||||
yield from mapping_type_fn(artifact) | yield from mapping_type_fn(artifact) | ||||
Done Inline ActionsI did not push it in lister.pattern directly but i wondered... ardumont: I did not push it in lister.pattern directly but i wondered... |
More readable, IMO.
(and remove the import)