From 3dbbe1397ed5e181d77d203860e0e399ddd7121f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 25 Nov 2020 13:06:00 +0530 Subject: [PATCH] Remove code to check for Qt5 incompatibility in plugins The Qt 5 transition is done and dusted now. The ones that arent going to be ported will anyway need to be ported to Python 3 as well, which is also never going to happen. --- setup/plugins_mirror.py | 62 +---------------------------------------- 1 file changed, 1 insertion(+), 61 deletions(-) diff --git a/setup/plugins_mirror.py b/setup/plugins_mirror.py index 1a9a5738a5..bb82424666 100644 --- a/setup/plugins_mirror.py +++ b/setup/plugins_mirror.py @@ -308,19 +308,7 @@ def parse_metadata(raw, namelist, zf): raise ValueError('Could not find plugin class') -def check_qt5_compatibility(zf, names): - uses_qt = False - for name in names: - if name.endswith('.py'): - raw = zf.read(name) - has_qt4 = (b'PyQt' + b'4') in raw - uses_qt = uses_qt or has_qt4 - if uses_qt and has_qt4 and b'PyQt5' not in raw: - return False - return True - - -def get_plugin_info(raw, check_for_qt5=False): +def get_plugin_info(raw): metadata = None with zipfile.ZipFile(io.BytesIO(raw)) as zf: names = {x.decode('utf-8') if isinstance(x, bytes) else x : x for x in zf.namelist()} @@ -339,8 +327,6 @@ def get_plugin_info(raw, check_for_qt5=False): raw = zf.open(metadata).read() ans = parse_metadata(raw, names, zf) if isinstance(ans, dict): - if check_for_qt5: - ans['qt5'] = check_qt5_compatibility(zf, names) return ans # The plugin is importing its base class from somewhere else, le sigh for mod, _ in ans: @@ -352,8 +338,6 @@ def get_plugin_info(raw, check_for_qt5=False): raw = zf.open(names[mod]).read() ans = parse_metadata(raw, names, zf) if isinstance(ans, dict): - if check_for_qt5: - ans['qt5'] = check_qt5_compatibility(zf, names) return ans raise ValueError('Failed to find plugin class') @@ -614,49 +598,6 @@ def update_stats(): return stats -def check_for_qt5_incompatibility(): - ok_plugins, bad_plugins = [], [] - for name in os.listdir('.'): - if name.endswith('.zip') and not name.endswith('-deprecated.zip'): - with open(name, 'rb') as f: - info = get_plugin_info(f.read(), check_for_qt5=True) - if info['qt5']: - ok_plugins.append(info) - else: - bad_plugins.append(info) - plugs = ['
  • %s
  • ' % x['name'] for x in bad_plugins] - gplugs = ('
  • %s
  • ' % x['name'] for x in ok_plugins) - stats = ''' - - -Stats for porting of calibre plugins to Qt 5 - - - - -

    Stats for porting of calibre plugins to Qt 5

    -

    Number of Qt 5 compatible plugins: %s
    Number of Qt 5 incompatible plugins: %s
    Percentage of plugins ported: %.0f%%

    -

    Plugins that have been ported

    - -

    Plugins still to be ported

    - - - - ''' % (len(ok_plugins), len(bad_plugins), len(ok_plugins)/(max(1, len(ok_plugins) + len(bad_plugins))) * 100, - '\n'.join(sorted(gplugs, key=lambda x:x.lower())), - '\n'.join(sorted(plugs, key=lambda x:x.lower()))) - with open('porting.html', 'wb') as f: - f.write(stats.encode('utf-8')) - - def main(): try: os.chdir(WORKDIR) @@ -678,7 +619,6 @@ def main(): plugins_index = load_plugins_index() plugins_index = fetch_plugins(plugins_index) create_index(plugins_index, stats) - check_for_qt5_incompatibility() except: import traceback log('Failed to run at:', datetime.utcnow().isoformat())