mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Show version on /-/plugins page, closes #248
This commit is contained in:
parent
d4da4c92c8
commit
ca290719ed
3 changed files with 10 additions and 3 deletions
|
|
@ -1434,6 +1434,7 @@ class Datasette:
|
||||||
'name': p['name'],
|
'name': p['name'],
|
||||||
'static': p['static_path'] is not None,
|
'static': p['static_path'] is not None,
|
||||||
'templates': p['templates_path'] is not None,
|
'templates': p['templates_path'] is not None,
|
||||||
|
'version': p.get('version'),
|
||||||
} for p in get_plugins(pm)]),
|
} for p in get_plugins(pm)]),
|
||||||
'/-/plugins<as_json:(\.json)?$>'
|
'/-/plugins<as_json:(\.json)?$>'
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -688,6 +688,7 @@ def module_from_path(path, name):
|
||||||
|
|
||||||
def get_plugins(pm):
|
def get_plugins(pm):
|
||||||
plugins = []
|
plugins = []
|
||||||
|
plugin_to_distinfo = dict(pm.list_plugin_distinfo())
|
||||||
for plugin in pm.get_plugins():
|
for plugin in pm.get_plugins():
|
||||||
static_path = None
|
static_path = None
|
||||||
templates_path = None
|
templates_path = None
|
||||||
|
|
@ -699,9 +700,13 @@ def get_plugins(pm):
|
||||||
except (KeyError, ImportError):
|
except (KeyError, ImportError):
|
||||||
# Caused by --plugins_dir= plugins - KeyError/ImportError thrown in Py3.5
|
# Caused by --plugins_dir= plugins - KeyError/ImportError thrown in Py3.5
|
||||||
pass
|
pass
|
||||||
plugins.append({
|
plugin_info = {
|
||||||
'name': plugin.__name__,
|
'name': plugin.__name__,
|
||||||
'static_path': static_path,
|
'static_path': static_path,
|
||||||
'templates_path': templates_path,
|
'templates_path': templates_path,
|
||||||
})
|
}
|
||||||
|
distinfo = plugin_to_distinfo.get(plugin)
|
||||||
|
if distinfo:
|
||||||
|
plugin_info['version'] = distinfo.version
|
||||||
|
plugins.append(plugin_info)
|
||||||
return plugins
|
return plugins
|
||||||
|
|
|
||||||
|
|
@ -763,7 +763,8 @@ def test_plugins_json(app_client):
|
||||||
assert {
|
assert {
|
||||||
'name': 'my_plugin.py',
|
'name': 'my_plugin.py',
|
||||||
'static': False,
|
'static': False,
|
||||||
'templates': False
|
'templates': False,
|
||||||
|
'version': None,
|
||||||
} in response.json
|
} in response.json
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue