Skip to content

Commit

Permalink
Adjust status messaging again
Browse files Browse the repository at this point in the history
  • Loading branch information
Buried-In-Code committed Jul 18, 2024
1 parent 84040e3 commit 54eb48e
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions perdoo/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ def convert_collection(path: Path, output: OutputFormat) -> None:
formats = list(ARCHIVE_EXTENSIONS)
formats.remove(format_)
for file in list_files(path, *formats):
LOGGER.info("Converting %s to %s format", file.name, output.name)
archive = get_archive(path=file)
archive_type.convert(old_archive=archive)
with CONSOLE.status(
f"Converting {file.name} to {output.name}", spinner="simpleDotsScrolling"
):
archive = get_archive(path=file)
archive_type.convert(old_archive=archive)


def read_meta(archive: BaseArchive) -> tuple[Meta | None, Details | None]:
Expand Down Expand Up @@ -303,10 +305,7 @@ def process_pages(
def start(settings: Settings, force: bool = False) -> None:
LOGGER.info("Starting Perdoo")

with CONSOLE.status(
f"Searching for non-{settings.output.format} files", spinner="simpleDotsScrolling"
):
convert_collection(path=settings.input_folder, output=settings.output.format)
convert_collection(path=settings.input_folder, output=settings.output.format)

with CONSOLE.status(
f"Searching for {settings.output.format} files", spinner="simpleDotsScrolling"
Expand All @@ -331,20 +330,19 @@ def start(settings: Settings, force: bool = False) -> None:
)

with TemporaryDirectory(prefix=f"{new_file.stem}_") as temp_str, CONSOLE.status(
"Extracting files", spinner="simpleDotsScrolling"
f"Extracting {archive.path.stem} files", spinner="simpleDotsScrolling"
) as status:
temp_folder = Path(temp_str)
if not archive.extract_files(destination=temp_folder):
return
status.update("Processing pages", spinner="simpleDotsScrolling")
status.update("Processing files")
process_pages(
folder=temp_folder,
metadata=metadata,
metron_info=metron_info,
comic_info=comic_info,
filename=new_file.stem,
)
status.update("Packaging archive", spinner="simpleDotsScrolling")
metadata.meta = Meta(date_=date.today())
files = list_files(temp_folder, *IMAGE_EXTENSIONS)
if settings.output.create_metadata:
Expand All @@ -359,6 +357,7 @@ def start(settings: Settings, force: bool = False) -> None:
comic_info_file = temp_folder / "ComicInfo.xml"
comic_info.to_file(file=comic_info_file)
files.append(comic_info_file)
status.update(f"Archiving {new_file.stem}")
archive_file = archive.archive_files(
src=temp_folder, output_name=archive.path.stem, files=files
)
Expand Down

0 comments on commit 54eb48e

Please sign in to comment.