Remove keep variable, simplifying code.
@@ -1394,13 +1394,16 @@ def run(input_file: KGTKFiles,
if len(clean_line) > 1:
obj = json.loads(clean_line)
entry_type = obj["type"]
- keep: bool = False
- if entry_type == "item" or entry_type == "property":
- keep = True
- elif warn_if_missing:
+ if entry_type is None:
+ print("Object with no entry type.", file=sys.stderr, flush=True)
+ return
+
+ if entry_type not in ("item", "property"):
+ if warn_if_missing:
print("Unknown object type {}.".format(entry_type), file=sys.stderr, flush=True)
+ return
- if self.process_row_data and keep:
+ if self.process_row_data:
qnode: typing.Optional[str] = obj.get("id")
if qnode is None:
print("Object with no id.", file=sys.stderr, flush=True)
@@ -1552,7 +1555,6 @@ def run(input_file: KGTKFiles,
if parse_claims and CLAIMS_TAG in obj:
claims = obj[CLAIMS_TAG]
- if keep:
qnode = obj.get(ENTITY_ID_TAG, "")
if len(qnode) == 0:
if fail_if_missing:
