Skip to content

Instantly share code, notes, and snippets.

@grejppi
Last active January 8, 2019 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grejppi/734700b8f8aee287352fc2d9e3f02c53 to your computer and use it in GitHub Desktop.
Save grejppi/734700b8f8aee287352fc2d9e3f02c53 to your computer and use it in GitHub Desktop.
import sys
from collections import defaultdict
import lilv
# FIXME: not sure if this is correct...
using_old_lilv = "lilv_nodes_begin" in dir(lilv)
show_details = '-d' in sys.argv or '--details' in sys.argv
required_total = defaultdict(set)
optional_total = defaultdict(set)
w = lilv.World()
w.load_all()
plugins = w.get_all_plugins()
for plugin in plugins:
required = plugin.get_required_features()
optional = plugin.get_optional_features()
uri = str(plugin.get_uri())
if using_old_lilv:
it = lilv.lilv_nodes_begin(required.me)
while not lilv.lilv_nodes_is_end(required, it):
feat = lilv.lilv_node_as_uri(lilv.lilv_nodes_get(required, it))
it = lilv.lilv_nodes_next(required, it)
required_total[feat].add(uri)
it = lilv.lilv_nodes_begin(optional.me)
while not lilv.lilv_nodes_is_end(optional, it):
feat = lilv.lilv_node_as_uri(lilv.lilv_nodes_get(optional, it))
it = lilv.lilv_nodes_next(optional, it)
optional_total[feat].add(uri)
else:
for feature in required:
required_total[str(feature)].add(uri)
for feature in optional:
optional_total[str(feature)].add(uri)
def bar(width, total, required, optional):
r = required / total
o = optional / total
r_width = round(r * width)
o_width = round(o * width)
r_bar = '\u2588' * r_width
o_bar = '\u2592' * o_width
return (r_bar + o_bar).ljust(width)
def fmt(s):
return s.replace('-', '\u2500').replace('+', '\u253c').replace('|', '\u2502')
if using_old_lilv:
total = plugins.size()
else:
total = len(plugins)
print("```")
print(total, "plugins installed on the system.")
print()
if show_details:
feature_uri_length = max((len(uri) for uri in required_total)) + len("<> ")
print(fmt("feature".ljust(feature_uri_length) + "| required by"))
for feature in sorted(required_total):
print(fmt("-" * feature_uri_length + "+------------"))
for i, plugin in enumerate(sorted(required_total[feature])):
if i == 0:
a = "<{}>".format(feature).ljust(feature_uri_length)
else:
a = " " * feature_uri_length
print(fmt(a + "| <" + plugin + ">"))
print()
print()
all_features = set()
all_features = all_features.union(set(required_total.keys()))
all_features = all_features.union(set(optional_total.keys()))
features_sorted = [(uri, len(required_total[uri]), len(optional_total[uri])) for uri in all_features]
features_sorted.sort(key=lambda x: x[0])
features_sorted.sort(key=lambda x: x[2])
features_sorted.sort(key=lambda x: x[1])
features_sorted.reverse()
print(fmt("0% 100%| required | optional | feature"))
print(fmt("----------+----------+----------+---------"))
for uri, required, optional in features_sorted:
print(fmt("{}| {} | {} | <{}>".format(bar(10, total, required, optional), str(required).rjust(8), str(optional).rjust(8), uri)))
print("```")
@SpotlightKid
Copy link

811 plugins installed on the system.


0%    100%│ required │ optional │ feature
──────────┼──────────┼──────────┼─────────
████      │      319 │       11 │ <http://lv2plug.in/ns/ext/urid#map>
█▒        │       65 │       59 │ <http://lv2plug.in/ns/ext/buf─size#boundedBlockLength>
█         │       56 │        0 │ <http://lv2plug.in/ns/ext/options#options>
          │       39 │       19 │ <http://lv2plug.in/ns/ext/worker#schedule>
          │       16 │        0 │ <http://lv2plug.in/ns/ext/urid#unmap>
          │       12 │       12 │ <http://lv2plug.in/ns/ext/state#loadDefaultState>
          │        3 │        1 │ <http://lv2plug.in/ns/ext/uri─map>
          │        3 │        1 │ <http://lv2plug.in/ns/ext/event>
          │        3 │        0 │ <http://lv2plug.in/ns/ext/buf─size#fixedBlockLength>
          │        1 │       21 │ <http://lv2plug.in/ns/ext/state#threadSafeRestore>
          │        1 │        1 │ <http://lv2plug.in/ns/ext/state#makePath>
▒▒▒▒▒▒▒▒  │        0 │      610 │ <http://lv2plug.in/ns/lv2core#hardRTCapable>
▒         │        0 │      105 │ <http://harrisonconsoles.com/lv2/inlinedisplay#queue_draw>
▒         │        0 │       87 │ <http://lv2plug.in/ns/ext/port─props#supportsStrictBounds>
          │        0 │       38 │ <http://lv2plug.in/ns/lv2core#hardRtCapable>
          │        0 │       28 │ <http://lv2plug.in/ns/lv2core#isLive>
          │        0 │        9 │ <http://open─music─kontrollers.ch/lv2/xpress#voiceMap>
          │        0 │        9 │ <http://open─music─kontrollers.ch/lv2/osc#schedule>
          │        0 │        1 │ <http://lv2plug.in/ns/ext/state#mapPath>
          │        0 │        1 │ <http://lv2plug.in/ns/ext/log#log>
          │        0 │        1 │ <http://lv2plug.in/ns/ext/buf─size#coarseBlockLength>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment