Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
hbmartin committed Jul 11, 2024
1 parent 1264ce5 commit 025a2d7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
6 changes: 2 additions & 4 deletions podcast_transcript_convert/converters/any_to_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
from typing import TypeAlias

from podcast_transcript_convert.converters.html_to_json import html_file_to_json_file
from podcast_transcript_convert.converters.json_to_simple import (
json_file_to_simple_file,
)
from podcast_transcript_convert.converters.json_to_json import json_file_to_json_file
from podcast_transcript_convert.converters.srt_to_json import srt_file_to_json_file
from podcast_transcript_convert.converters.vtt_to_json import vtt_file_to_json_file
from podcast_transcript_convert.converters.xml_to_json import xml_file_to_json_file
Expand All @@ -16,7 +14,7 @@

type_to_converter_map: dict[FileType, Converter] = {
FileType.HTML: html_file_to_json_file,
FileType.JSON: json_file_to_simple_file,
FileType.JSON: json_file_to_json_file,
FileType.SRT: srt_file_to_json_file,
FileType.VTT: vtt_file_to_json_file,
FileType.XML: xml_file_to_json_file,
Expand Down
4 changes: 2 additions & 2 deletions podcast_transcript_convert/converters/json_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


def json_file_to_json_file(
origin_file: str,
destination_file: str,
origin_file: str | Path,
destination_file: str | Path,
metadata: dict | None,
) -> None:
try:
Expand Down
6 changes: 5 additions & 1 deletion podcast_transcript_convert/converters/srt_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ def srt_to_podcast_dict(srt_string: str) -> dict:
}


def srt_file_to_json_file(srt_file: str, json_file: str, metadata: dict | None) -> None:
def srt_file_to_json_file(
srt_file: str | Path,
json_file: str | Path,
metadata: dict | None,
) -> None:
srt_string = Path(srt_file).read_text()
try:
transcript_dict = srt_to_podcast_dict(srt_string)
Expand Down
6 changes: 5 additions & 1 deletion podcast_transcript_convert/converters/vtt_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ def vtt_to_podcast_dict(vtt_string: str) -> dict:


# https://www.w3.org/TR/webvtt1/#file-structure
def vtt_file_to_json_file(vtt_file: str, json_file: str, metadata: dict | None) -> None:
def vtt_file_to_json_file(
vtt_file: str | Path,
json_file: str | Path,
metadata: dict | None,
) -> None:
vtt_string = Path(vtt_file).read_text()
try:
transcript_dict = vtt_to_podcast_dict(vtt_string)
Expand Down
6 changes: 5 additions & 1 deletion podcast_transcript_convert/converters/xml_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ def xml_to_podcast_dict(xml_string: str) -> dict:
}


def xml_file_to_json_file(xml_file: str, json_file: str, metadata: dict | None) -> None:
def xml_file_to_json_file(
xml_file: str | Path,
json_file: str | Path,
metadata: dict | None,
) -> None:
xml_string = Path(xml_file).read_text()
try:
transcript_dict = xml_to_podcast_dict(xml_string)
Expand Down

0 comments on commit 025a2d7

Please sign in to comment.