Verified Commit 5dab8eba authored by Jakob Moser's avatar Jakob Moser
Browse files

Add better batch conversion mode

parent 557baaf5
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
[project]
name = "coliverter"
version = "0.5.0"
version = "0.5.1"
authors = [
  { name="Jakob Moser", email="moser@cl.uni-heidelberg.de" },
]
+19 −8
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ from multiprocessing import Pool

from coliverter.documents.Document import Document
from coliverter.documents.DocumentType import DocumentType
from coliverter.documents.transform.TransformError import TransformError
from coliverter.files.FileFormat import FileFormat
from coliverter.cli.typer import typer
from coliverter.files.read import read
@@ -57,17 +58,27 @@ def _convert_single_guessing_output_path(
    output_format: FileFormat,
    document_type: DocumentType | None,
) -> None:
    guessed_out_file_path = output_dir_path / (
        markdown_file_path.relative_to(markdown_dir_path).with_suffix(
            f".{output_format}"
    new_name = markdown_file_path.stem + (
        "_nur_Beschlüsse" if document_type == DocumentType.MEETING_RESOLUTIONS else ""
    )
    relative_output_file_path = (
        markdown_file_path.relative_to(markdown_dir_path)
        .with_name(new_name)
        .with_suffix(f".{output_format}")
    )
    output_file_path = output_dir_path / relative_output_file_path

    guessed_out_file_path.parent.mkdir(parents=True, exist_ok=True)
    output_file_path.parent.mkdir(parents=True, exist_ok=True)

    try:
        _convert_single(
        markdown_file_path, guessed_out_file_path, output_format, document_type
            markdown_file_path, output_file_path, output_format, document_type
        )
    except TransformError:
        # TODO This is spectacularly ugly: As I know this function is called during batch processing, and I decided I
        #  want to silently ignore errors in batch processing (actually, I just want to replicate the behavior that
        #  we only generate resolution documents when needed), I put this there.
        pass  # Ignore transform errors


@typer.command()
+1 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ wheels = [

[[package]]
name = "coliverter"
version = "0.4.2"
version = "0.5.0"
source = { editable = "." }
dependencies = [
    { name = "pandoc" },