HPI/my/reddit/__init__.py
Dima Gerasimov 9461df6aa5 general: extract the hack to warn of legacy imports and fallback to core/legacy.py
use it both in my.fbmessenger and my.reddit

if in the future any new modules need to be switched to namespace package structure with all.py it should make it easy to do

related:
- https://github.com/karlicoss/HPI/issues/12
- https://github.com/karlicoss/HPI/issues/89
- https://github.com/karlicoss/HPI/issues/102
2022-06-01 23:27:34 +01:00

31 lines
979 B
Python

"""
This is here temporarily, for backwards compatibility purposes
It should be removed in the future, and you should replace any imports
like:
from my.reddit import ...
to:
from my.reddit.all import ...
since that allows for easier overriding using namespace packages
See https://github.com/karlicoss/HPI/blob/master/doc/MODULE_DESIGN.org#allpy for more info.
"""
# prevent it from apprearing in modules list/doctor
from ..core import __NOT_HPI_MODULE__
# kinda annoying to keep it, but it's so legacy 'hpi module install my.reddit' works
# needs to be on the top level (since it's extracted via ast module)
REQUIRES = [
'git+https://github.com/karlicoss/rexport',
]
from my.core.legacy import handle_legacy_import
is_legacy_import = handle_legacy_import(
parent_module_name=__name__,
legacy_submodule_name='rexport',
parent_module_path=__path__,
)
if is_legacy_import:
# todo not sure if possible to move this into legacy.py
from .rexport import *