summaryrefslogtreecommitdiff
path: root/patternutils/commands/tmv.py
diff options
context:
space:
mode:
Diffstat (limited to 'patternutils/commands/tmv.py')
-rw-r--r--patternutils/commands/tmv.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/patternutils/commands/tmv.py b/patternutils/commands/tmv.py
index 6ce45ed..0ddbbd2 100644
--- a/patternutils/commands/tmv.py
+++ b/patternutils/commands/tmv.py
@@ -1,6 +1,8 @@
import json
import os.path
import shutil
+from collections.abc import Iterable
+from typing import Any, TextIO
import click
@@ -83,13 +85,12 @@ def tmv(
template_engine: template.TemplateEngines,
abort_on_path_exist: bool,
use_predefined_template: bool,
- read_from: click.File,
+ read_from: TextIO,
key: str,
stream: bool,
dry_run: bool,
verbose: bool,
) -> None:
-
"""Rename files based on the OUTPUT_PATTERN.
It reads in a JSON list containing objects or a stream of objects (if the
@@ -99,14 +100,17 @@ def tmv(
generate the new filename.
"""
+ data: Iterable[dict[str, Any]]
if stream:
- data = map(utils.json_loads, read_from) # type: ignore
+ data = map(utils.json_loads, read_from)
else:
- data = utils.json_loads(read_from.read()) # type: ignore
+ data = utils.json_loads(read_from.read())
if use_predefined_template:
try:
- output_pattern, template_engine = config.load_template(output_pattern, "tmv")
+ output_pattern, template_engine = config.load_template(
+ output_pattern, "tmv"
+ )
except FileNotFoundError:
click.secho(f"Template {output_pattern} not found!", fg="red", err=True)
raise SystemExit