mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Added /-/metadata /-/plugins /-/inspect, closes #225
This commit is contained in:
parent
6e28ed447f
commit
b55809a1e2
5 changed files with 111 additions and 14 deletions
|
|
@ -4,6 +4,7 @@ import hashlib
|
|||
import imp
|
||||
import json
|
||||
import os
|
||||
import pkg_resources
|
||||
import re
|
||||
import shlex
|
||||
import sqlite3
|
||||
|
|
@ -683,3 +684,20 @@ def module_from_path(path, name):
|
|||
code = compile(file.read(), path, 'exec', dont_inherit=True)
|
||||
exec(code, mod.__dict__)
|
||||
return mod
|
||||
|
||||
|
||||
def get_plugins(pm):
|
||||
plugins = []
|
||||
for plugin in pm.get_plugins():
|
||||
static_path = None
|
||||
try:
|
||||
if pkg_resources.resource_isdir(plugin.__name__, 'static'):
|
||||
static_path = pkg_resources.resource_filename(plugin.__name__, 'static')
|
||||
except (KeyError, ImportError):
|
||||
# Caused by --plugins_dir= plugins - KeyError/ImportError thrown in Py3.5
|
||||
pass
|
||||
plugins.append({
|
||||
'name': plugin.__name__,
|
||||
'static_path': static_path,
|
||||
})
|
||||
return plugins
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue