Skip to content
Snippets Groups Projects
Commit 0a628757 authored by Martin's avatar Martin
Browse files

fix linting

parent c5e4f26e
No related branches found
No related tags found
1 merge request!22Add style filter (handwritten, typewritten); support ignored_classes
Pipeline #74328 passed
......@@ -184,10 +184,7 @@ class HTRDataGenerator:
for elt in self.api_client.cached_paginate(
"ListElementChildren", id=page_id, with_classes=True
):
elem_classes = [c
for c in elt["classes"]
if c["state"] != "rejected"
]
elem_classes = [c for c in elt["classes"] if c["state"] != "rejected"]
should_accept = True
if self.should_filter_by_class:
......@@ -218,7 +215,9 @@ class HTRDataGenerator:
found_class = list(style_counts.keys())[0]
found_class = Style(found_class)
else:
raise ValueError(f"Multiple style classes on the same element! {elt['id']} - {elem_classes}")
raise ValueError(
f"Multiple style classes on the same element! {elt['id']} - {elem_classes}"
)
if found_class == self.style:
accepted_zones.append(elt["zone"]["id"])
......@@ -237,7 +236,6 @@ class HTRDataGenerator:
)
raise e
def _validate_transcriptions(self, page_id: str, lines: List[TranscriptionData]):
if not lines:
return
......@@ -296,9 +294,8 @@ class HTRDataGenerator:
and res["worker_version_id"] not in self.accepted_worker_version_ids
):
continue
if (
(self.should_filter_by_class or self.should_filter_by_style)
and res["element"]["zone"]["id"] not in accepted_zones
if (self.should_filter_by_class or self.should_filter_by_style) and (
res["element"]["zone"]["id"] not in accepted_zones
):
continue
if res["element"]["type"] != self.transcription_type:
......@@ -902,8 +899,10 @@ def main():
if args.style and args.accepted_classes:
if any(c in args.accepted_classes for c in STYLE_CLASSES):
parser.error(f"--style class values ({STYLE_CLASSES}) shouldn't be in the accepted_classes list "
"if both --style and --accepted_classes are used together.")
parser.error(
f"--style class values ({STYLE_CLASSES}) shouldn't be in the accepted_classes list "
"if both --style and --accepted_classes are used together."
)
logger.info(f"ARGS {args} \n")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment