mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-24 21:41:04 +02:00
Same adjudication as the client methods (42d57b6): pageindex.utils is
the documented 0.2.8 location, and the top-level modules are permanent
compatibility surface — "will be removed in a future release" was not
true. The shims stay; only the import-time warnings go.
31 lines
1.6 KiB
Python
31 lines
1.6 KiB
Python
# pageindex/page_index.py
|
|
# Compatibility shim. The PDF indexing pipeline now lives in
|
|
# pageindex/index/page_index.py (the single source of truth). This module
|
|
# re-exports it so legacy imports (`from pageindex.page_index import ...`,
|
|
# `from pageindex import page_index`) keep working.
|
|
import sys
|
|
import types
|
|
from .index.page_index import * # noqa: F401,F403,E402
|
|
|
|
# pageindex/__init__.py binds the FUNCTION `page_index` as the package
|
|
# attribute `pageindex.page_index` (`from .index.page_index import *`). But
|
|
# this file is ALSO a real submodule of the same name — the moment anything,
|
|
# anywhere in the process, does `import pageindex.page_index` (exactly what
|
|
# `from pageindex.page_index import X` triggers), Python's import machinery
|
|
# overwrites that package attribute with THIS module object, clobbering the
|
|
# function binding. Afterwards `from pageindex import page_index; page_index(x)`
|
|
# would raise "TypeError: 'module' object is not callable" — silently, and
|
|
# depending entirely on whether this submodule happened to be imported yet.
|
|
#
|
|
# Fix: make this module itself callable, delegating to the real function, so
|
|
# whichever object ends up sitting in the `pageindex.page_index` slot — the
|
|
# function or this module — is callable either way. Both `from pageindex.page_index
|
|
# import page_index_main` (module attribute access) and
|
|
# `from pageindex import page_index; page_index(x)` (call) keep working
|
|
# regardless of import order.
|
|
class _CallableModule(types.ModuleType):
|
|
def __call__(self, *args, **kwargs):
|
|
return page_index(*args, **kwargs)
|
|
|
|
|
|
sys.modules[__name__].__class__ = _CallableModule
|