added wrapper class for converter file input
This commit is contained in:
@@ -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",
|
||||
]
|
||||
|
||||
18
packages/markitdown/src/markitdown/_input.py
Normal file
18
packages/markitdown/src/markitdown/_input.py
Normal 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
|
||||
Reference in New Issue
Block a user