Changeset View
Changeset View
Standalone View
Standalone View
swh/clearlydefined/mapping_utils.py
Show All 34 Lines | class ToolType(Enum): | ||||
DEFINITION = "definition" | DEFINITION = "definition" | ||||
SCANCODE = "scancode" | SCANCODE = "scancode" | ||||
CLEARLYDEFINED = "clearlydefined" | CLEARLYDEFINED = "clearlydefined" | ||||
LICENSEE = "licensee" | LICENSEE = "licensee" | ||||
FOSSOLOGY = "fossology" | FOSSOLOGY = "fossology" | ||||
AUTHORITY = MetadataAuthority( | AUTHORITY = MetadataAuthority( | ||||
type=MetadataAuthorityType.REGISTRY, | type=MetadataAuthorityType.REGISTRY, | ||||
url="https://clearlydefined.io/", | url="https://clearlydefined.io/", | ||||
metadata=None, | metadata={}, | ||||
) | ) | ||||
FETCHER = MetadataFetcher( | FETCHER = MetadataFetcher( | ||||
name="swh-clearlydefined", | name="swh-clearlydefined", | ||||
version="0.0.1", | version="0.0.1", | ||||
metadata=None, | metadata={}, | ||||
) | ) | ||||
vlorentz: and undo this change | |||||
Done Inline Actionsmetadata = None, gives error TG1999: metadata = None, gives error | |||||
Done Inline ActionsUse attr.evolve vlorentz: Use `attr.evolve` | |||||
Done Inline ActionsWhere ? In orchestrator ? TG1999: Where ? In orchestrator ? | |||||
Done Inline Actionswhere you need it to be not-None, yes vlorentz: where you need it to be not-`None`, yes | |||||
def map_row_data_with_metadata( | def map_row_data_with_metadata( | ||||
swh_id: str, | swh_id: str, | ||||
type: MetadataTargetType, | type: MetadataTargetType, | ||||
origin: Optional[Origin], | origin: Optional[Origin], | ||||
metadata: Dict, | metadata: Dict, | ||||
date: datetime, | date: datetime, | ||||
▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | return True, [ | ||||
origin=origin, | origin=origin, | ||||
metadata=metadata, | metadata=metadata, | ||||
date=date, | date=date, | ||||
format="clearlydefined-definition-json", | format="clearlydefined-definition-json", | ||||
) | ) | ||||
] | ] | ||||
def get_type_of_tool(cd_path) -> ToolType: | def get_type_of_tool(cd_path) -> ToolType: | ||||
Done Inline Actionsreturn an enum instead. vlorentz: return an enum instead. | |||||
""" | """ | ||||
Take cd_path as input if cd_path is invalid then raise exception, | Take cd_path as input if cd_path is invalid then raise exception, | ||||
else return tyoe of tool of that row | else return tyoe of tool of that row | ||||
""" | """ | ||||
list_cd_path = cd_path.split("/") | list_cd_path = cd_path.split("/") | ||||
# For example: maven/mavencentral/cobol-parser/abc/0.4.0.json | # For example: maven/mavencentral/cobol-parser/abc/0.4.0.json | ||||
if list_cd_path[4] != "revision": | if list_cd_path[4] != "revision": | ||||
raise RevisionNotFound( | raise RevisionNotFound( | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |
and undo this change