Fixed loading of plugins. (#1096)
This commit is contained in:
@@ -24,7 +24,7 @@ classifiers = [
|
|||||||
"Programming Language :: Python :: Implementation :: PyPy",
|
"Programming Language :: Python :: Implementation :: PyPy",
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"markitdown>=0.2.0a1",
|
"markitdown>=0.2.0a2",
|
||||||
"striprtf",
|
"striprtf",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# SPDX-FileCopyrightText: 2024-present Adam Fourney <adamfo@microsoft.com>
|
# SPDX-FileCopyrightText: 2024-present Adam Fourney <adamfo@microsoft.com>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
__version__ = "0.2.0a1"
|
__version__ = "0.2.0a2"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# SPDX-FileCopyrightText: 2024-present Adam Fourney <adamfo@microsoft.com>
|
# SPDX-FileCopyrightText: 2024-present Adam Fourney <adamfo@microsoft.com>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
__version__ = "0.2.0a1"
|
__version__ = "0.2.0a2"
|
||||||
|
|||||||
@@ -58,10 +58,10 @@ PRIORITY_GENERIC_FILE_FORMAT = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
_plugins: List[Any] = []
|
_plugins: Union[None, List[Any]] = None # If None, plugins have not been loaded yet.
|
||||||
|
|
||||||
|
|
||||||
def _load_plugins() -> List[Any]:
|
def _load_plugins() -> Union[None, List[Any]]:
|
||||||
"""Lazy load plugins, exiting early if already loaded."""
|
"""Lazy load plugins, exiting early if already loaded."""
|
||||||
global _plugins
|
global _plugins
|
||||||
|
|
||||||
@@ -186,7 +186,9 @@ class MarkItDown:
|
|||||||
"""
|
"""
|
||||||
if not self._plugins_enabled:
|
if not self._plugins_enabled:
|
||||||
# Load plugins
|
# Load plugins
|
||||||
for plugin in _load_plugins():
|
plugins = _load_plugins()
|
||||||
|
assert plugins is not None
|
||||||
|
for plugin in plugins:
|
||||||
try:
|
try:
|
||||||
plugin.register_converters(self, **kwargs)
|
plugin.register_converters(self, **kwargs)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
Reference in New Issue
Block a user