added wrapper class for converter file input

This commit is contained in:
Kenny Zhang
2025-02-18 12:44:18 -05:00
parent 63a7bafadd
commit 0027e6d425
2 changed files with 20 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ from ._exceptions import (
FileConversionException,
UnsupportedFormatException,
)
from ._input import ConverterInput
from .converters import DocumentConverter, DocumentConverterResult
__all__ = [
@@ -21,4 +22,5 @@ __all__ = [
"ConverterPrerequisiteException",
"FileConversionException",
"UnsupportedFormatException",
"ConverterInput",
]

View File

@@ -0,0 +1,18 @@
from typing import Any, Union
class ConverterInput:
"""
Wrapper for inputs to converter functions.
"""
def __init__(
self,
input_type: str = "filepath",
filepath: Union[str, None] = None,
file_object: Union[Any, None] = None,
):
if input_type not in ["filepath", "object"]:
raise ValueError(f"Invalid converter input type: {input_type}")
self.input_type = input_type
self.filepath = filepath
self.file_object = file_object