mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-02-14 04:34:28 +01:00
Allow imports of top level PyQt modules to work from the qt virtual module
This is needed for legacy compat of from PyQt5 import QtCore, QtGui, etc
This commit is contained in:
parent
1790843b79
commit
a8a4bb2f66
2 changed files with 23 additions and 0 deletions
|
|
@ -0,0 +1,10 @@
|
|||
# autogenerated by __main__.py do not edit
|
||||
top_level_module_names=('QtCore', 'QtGui', 'QtWidgets', 'QtNetwork', 'QtSvg', 'QtPrintSupport', 'QtWebEngineCore', 'QtWebEngineWidgets')
|
||||
|
||||
def __getattr__(name):
|
||||
if name in top_level_module_names:
|
||||
import importlib
|
||||
return importlib.import_module("PyQt6." + name)
|
||||
raise AttributeError(name)
|
||||
|
||||
|
||||
|
|
@ -53,5 +53,18 @@ def scan(name):
|
|||
print(')', file=f)
|
||||
|
||||
|
||||
top_level_module_names = ()
|
||||
for name in ('core', 'webengine'):
|
||||
top_level_module_names += module_lists[name]
|
||||
scan(name)
|
||||
with open(f'{base}/__init__.py', 'w') as f:
|
||||
print('# autogenerated by __main__.py do not edit', file=f)
|
||||
print(f'{top_level_module_names=}', file=f)
|
||||
print(f'''
|
||||
def __getattr__(name):
|
||||
if name in top_level_module_names:
|
||||
import importlib
|
||||
return importlib.import_module("{QT_WRAPPER}." + name)
|
||||
raise AttributeError(name)
|
||||
|
||||
''', file=f)
|
||||
|
|
|
|||
Loading…
Reference in a new issue