mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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.
This commit is contained in:
parent
72308168ef
commit
3dbbe1397e
@ -308,19 +308,7 @@ def parse_metadata(raw, namelist, zf):
|
|||||||
raise ValueError('Could not find plugin class')
|
raise ValueError('Could not find plugin class')
|
||||||
|
|
||||||
|
|
||||||
def check_qt5_compatibility(zf, names):
|
def get_plugin_info(raw):
|
||||||
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):
|
|
||||||
metadata = None
|
metadata = None
|
||||||
with zipfile.ZipFile(io.BytesIO(raw)) as zf:
|
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()}
|
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()
|
raw = zf.open(metadata).read()
|
||||||
ans = parse_metadata(raw, names, zf)
|
ans = parse_metadata(raw, names, zf)
|
||||||
if isinstance(ans, dict):
|
if isinstance(ans, dict):
|
||||||
if check_for_qt5:
|
|
||||||
ans['qt5'] = check_qt5_compatibility(zf, names)
|
|
||||||
return ans
|
return ans
|
||||||
# The plugin is importing its base class from somewhere else, le sigh
|
# The plugin is importing its base class from somewhere else, le sigh
|
||||||
for mod, _ in ans:
|
for mod, _ in ans:
|
||||||
@ -352,8 +338,6 @@ def get_plugin_info(raw, check_for_qt5=False):
|
|||||||
raw = zf.open(names[mod]).read()
|
raw = zf.open(names[mod]).read()
|
||||||
ans = parse_metadata(raw, names, zf)
|
ans = parse_metadata(raw, names, zf)
|
||||||
if isinstance(ans, dict):
|
if isinstance(ans, dict):
|
||||||
if check_for_qt5:
|
|
||||||
ans['qt5'] = check_qt5_compatibility(zf, names)
|
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
raise ValueError('Failed to find plugin class')
|
raise ValueError('Failed to find plugin class')
|
||||||
@ -614,49 +598,6 @@ def update_stats():
|
|||||||
return 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 = ['<li>%s</li>' % x['name'] for x in bad_plugins]
|
|
||||||
gplugs = ('<li>%s</li>' % x['name'] for x in ok_plugins)
|
|
||||||
stats = '''
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head><meta charset="utf-8"><title>Stats for porting of calibre plugins to Qt 5</title>
|
|
||||||
<link rel="icon" type="image/x-icon" href="//calibre-ebook.com/favicon.ico" />
|
|
||||||
<style type="text/css">
|
|
||||||
body { background-color: #eee; }
|
|
||||||
h1 img, h3 img { vertical-align: middle; margin-right: 0.5em; }
|
|
||||||
h1 { text-align: center }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1><img src="//manual.calibre-ebook.com/_static/logo.png">Stats for porting of calibre plugins to Qt 5</h1>
|
|
||||||
<p>Number of Qt 5 compatible plugins: %s<br>Number of Qt 5 incompatible plugins: %s<br>Percentage of plugins ported: %.0f%%</p>
|
|
||||||
<h2>Plugins that have been ported</h2>
|
|
||||||
<ul>
|
|
||||||
%s
|
|
||||||
</ul>
|
|
||||||
<h2>Plugins still to be ported</h2>
|
|
||||||
<ul>
|
|
||||||
%s
|
|
||||||
</ul>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
''' % (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():
|
def main():
|
||||||
try:
|
try:
|
||||||
os.chdir(WORKDIR)
|
os.chdir(WORKDIR)
|
||||||
@ -678,7 +619,6 @@ def main():
|
|||||||
plugins_index = load_plugins_index()
|
plugins_index = load_plugins_index()
|
||||||
plugins_index = fetch_plugins(plugins_index)
|
plugins_index = fetch_plugins(plugins_index)
|
||||||
create_index(plugins_index, stats)
|
create_index(plugins_index, stats)
|
||||||
check_for_qt5_incompatibility()
|
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
log('Failed to run at:', datetime.utcnow().isoformat())
|
log('Failed to run at:', datetime.utcnow().isoformat())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user