Page MenuHomeSoftware Heritage

D7587.id27498.diff
No OneTemporary

D7587.id27498.diff

diff --git a/swh/indexer/metadata_dictionary/__init__.py b/swh/indexer/metadata_dictionary/__init__.py
--- a/swh/indexer/metadata_dictionary/__init__.py
+++ b/swh/indexer/metadata_dictionary/__init__.py
@@ -27,7 +27,7 @@
@click.command()
@click.argument("mapping_name")
@click.argument("file_name")
-def main(mapping_name, file_name):
+def main(mapping_name: str, file_name: str):
from pprint import pprint
with open(file_name, "rb") as fd:
diff --git a/swh/indexer/metadata_dictionary/base.py b/swh/indexer/metadata_dictionary/base.py
--- a/swh/indexer/metadata_dictionary/base.py
+++ b/swh/indexer/metadata_dictionary/base.py
@@ -5,7 +5,7 @@
import json
import logging
-from typing import List
+from typing import List, Union
from swh.indexer.codemeta import SCHEMA_URI, compact, merge_values
@@ -32,7 +32,7 @@
raise NotImplementedError(f"{self.__class__.__name__}.name")
@classmethod
- def detect_metadata_files(cls, files):
+ def detect_metadata_files(cls, files: list):
"""
Detects files potentially containing metadata
@@ -62,7 +62,7 @@
@classmethod
def detect_metadata_files(cls, file_entries):
for entry in file_entries:
- if entry["name"].lower() == cls.filename.lower():
+ if str(entry["name"]).lower() == (cls.filename).lower():
return [entry["sha1"]]
return []
@@ -150,7 +150,7 @@
class JsonMapping(DictMapping, SingleFileMapping):
"""Base class for all mappings that use a JSON file as input."""
- def translate(self, raw_content):
+ def translate(self, raw_content) -> Union[dict, None]:
"""
Translates content by parsing content from a bytestring containing
json data and translating with the appropriate mapping
@@ -165,13 +165,15 @@
"""
try:
raw_content = raw_content.decode()
+ return None
except UnicodeDecodeError:
self.log.warning("Error unidecoding from %s", self.log_suffix)
- return
+ return None
try:
content_dict = json.loads(raw_content)
+ return None
except json.JSONDecodeError:
self.log.warning("Error unjsoning from %s", self.log_suffix)
- return
+ return None
if isinstance(content_dict, dict):
return self._translate_dict(content_dict)

File Metadata

Mime Type
text/plain
Expires
Nov 5 2024, 5:30 AM (19 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3223348

Event Timeline