Skip to content

Commit

Permalink
[py-tx] Refomating
Browse files Browse the repository at this point in the history
  • Loading branch information
Mackay-Fisher committed Nov 25, 2024
1 parent 00c0b09 commit 860f924
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions python-threatexchange/threatexchange/cli/hash_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ def execute(self, settings: CLISettings) -> None:
print(hasher.get_name(), hash_str)
return

def pre_processed_files() -> t.Iterator[t.Tuple[Path, bytes, t.Union[None, RotationType], str]]:
def pre_processed_files() -> (
t.Iterator[t.Tuple[Path, bytes, t.Union[None, RotationType], str]]
):
"""
Generator that yields preprocessed files and their metadata.
Each item is a tuple of (file path, processed bytes, rotation name, image format).
Expand All @@ -178,9 +180,7 @@ def pre_processed_files() -> t.Iterator[t.Tuple[Path, bytes, t.Union[None, Rotat
rotation_type,
image_format,
) in pre_processed_files():
output_extension = (
f".{image_format.lower()}" if image_format else ".png"
)
output_extension = f".{image_format.lower()}" if image_format else ".png"
# Use a temporary file with the correct extension
with tempfile.NamedTemporaryFile(
delete=not self.save_preprocess, suffix=output_extension
Expand All @@ -198,9 +198,9 @@ def pre_processed_files() -> t.Iterator[t.Tuple[Path, bytes, t.Union[None, Rotat
suffix = (
f"_{rotation_type.name}" if rotation_type else "_unletterboxed"
)
output_path = file.with_stem(
f"{file.stem}{suffix}"
).with_suffix(output_extension)
output_path = file.with_stem(f"{file.stem}{suffix}").with_suffix(
output_extension
)
temp_file_path.rename(
output_path
) # Move temp file to desired location
Expand Down

0 comments on commit 860f924

Please sign in to comment.