[SCM] calf/master: + Big Bull: LV2 plugin information is wrapped in Python classes, return feature list, allow methods and function as command result handlers
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:37:19 UTC 2013
The following commit has been merged in the master branch:
commit fe33158e465952e8348d5ab5f12992e7335b7a2e
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Wed Jun 18 22:07:17 2008 +0000
+ Big Bull: LV2 plugin information is wrapped in Python classes, return feature list, allow methods and function as command result handlers
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@205 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/bigbull/client.py b/bigbull/client.py
index 5024e2f..e646af3 100644
--- a/bigbull/client.py
+++ b/bigbull/client.py
@@ -1,6 +1,7 @@
import os
import sys
import fakeserv
+import types
class CommandExec:
nextId = 1
@@ -27,23 +28,54 @@ class CommandExec:
self.result = result
#print "OK: %s(%s) -> %s" % (self.type, self.args, self.result)
for h in self.okHandlers:
- h.receiveData(self)
+ if type(h) is types.FunctionType or type(h) is types.MethodType:
+ h(self)
+ else:
+ h.receiveData(self)
def calledOnError(self, message):
self.error = message
print "Error: %s(%s) -> %s" % (self.type, self.args, message)
for h in self.errorHandlers:
- h.receiveError(self)
+ if type(h) is types.FunctionType or type(h) is types.MethodType:
+ h(self)
+ else:
+ h.receiveError(self)
-class LV2Plugin:
- def __init__(self, uri):
- self.uri = uri
- self.name = uri
- self.license = ""
+class LV2Port(object):
+ def __init__(self, data):
+ for prop in ["symbol", "name", "classes", "isAudio", "isControl", "isEvent", "isInput", "isOutput", "default", "maximum", "minimum", "scalePoints", "index"]:
+ if prop in data:
+ self.__dict__[prop] = data[prop]
+ else:
+ self.__dict__[prop] = None
+
+class LV2Plugin(object):
+ def __init__(self, data):
+ self.uri = data["uri"]
+ self.name = data["name"]
+ self.license = data["license"]
+ self.classes = set(data["classes"])
+ self.requiredFeatures = set(data["requiredFeatures"])
+ self.optionalFeatures = set(data["optionalFeatures"])
self.ports = []
- self.requiredFeatures = {}
- self.optionalFeatures = {}
+ for port in data["ports"]:
+ self.ports.append(LV2Port(port))
def decode(self, data):
self.name = data['doap:name']
+class BBClient(object):
+ def __init__(self):
+ self.plugins = []
+ cmd = CommandExec('get_uris', 'http://lv2plug.in/ns/lv2core#')
+ cmd.onOK(self.uris_received)
+ cmd.run()
+ def uris_received(self, data):
+ self.uris = data.result
+ for uri in self.uris:
+ cmd = CommandExec('get_plugin_info', uri)
+ cmd.onOK(self.uri_info_received)
+ cmd.run()
+ def uri_info_received(self, data):
+ self.plugins.append(LV2Plugin(data.result))
diff --git a/bigbull/fakeserv.py b/bigbull/fakeserv.py
index f022faa..fefe6da 100644
--- a/bigbull/fakeserv.py
+++ b/bigbull/fakeserv.py
@@ -4,6 +4,8 @@ import sys
import glob
import yappy.parser
+lv2 = "http://lv2plug.in/ns/lv2core#"
+lv2evt = "http://lv2plug.in/ns/ext/event#"
rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
rdfs = "http://www.w3.org/2000/01/rdf-schema#"
rdf_type = rdf + "type"
@@ -176,8 +178,6 @@ def parseTTL(uri, content, model):
class FakeServer(object):
def __init__(self):
- self.lv2 = "http://lv2plug.in/ns/lv2core#"
- self.lv2evt = "http://lv2plug.in/ns/ext/event#"
self.initManifests()
#parseTTL("http://lv2plug.in/ns/lv2core#", file("/usr/lib/lv2/lv2core.lv2/lv2.ttl").read(), m)
@@ -193,8 +193,8 @@ class FakeServer(object):
if os.path.exists(fn):
parseTTL(fn, file(fn).read(), self.manifests)
# Read all specifications from all manifests
- if (self.lv2 + "Specification" in self.manifests.bySubject["$classes"]):
- specs = self.manifests.getByType(self.lv2 + "Specification")
+ if (lv2 + "Specification" in self.manifests.bySubject["$classes"]):
+ specs = self.manifests.getByType(lv2 + "Specification")
filenames = set()
for spec in specs:
subj = self.manifests.bySubject[spec]
@@ -205,14 +205,14 @@ class FakeServer(object):
parseTTL(fn, file(fn).read(), self.manifests)
#fn = "/usr/lib/lv2/lv2core.lv2/lv2.ttl"
#parseTTL(fn, file(fn).read(), self.manifests)
- self.plugins = self.manifests.getByType(self.lv2 + "Plugin")
+ self.plugins = self.manifests.getByType(lv2 + "Plugin")
def get_uris(self, base_uri):
if base_uri == 'http://lv2plug.in/ns/lv2core#':
return self.plugins
raise StringException("Invalid base URI")
- def get_info(self, uri):
+ def get_plugin_info(self, uri):
if uri not in self.plugin_info:
world = SimpleRDFModel()
world.copyFrom(self.manifests)
@@ -223,29 +223,32 @@ class FakeServer(object):
self.plugin_info[uri] = world
info = self.plugin_info[uri]
dest = {}
+ dest['uri'] = uri
dest['name'] = info.bySubject[uri]['http://usefulinc.com/ns/doap#name'][0]
dest['license'] = info.bySubject[uri]['http://usefulinc.com/ns/doap#license'][0]
- dest['classes'] = set(info.bySubject[uri]["a"])
+ dest['classes'] = info.bySubject[uri]["a"]
+ dest['requiredFeatures'] = info.getProperty(uri, lv2 + "requiredFeature", optional = True)
+ dest['optionalFeatures'] = info.getProperty(uri, lv2 + "optionalFeature", optional = True)
ports = []
porttypes = {
- "isAudio" : self.lv2 + "AudioPort",
- "isControl" : self.lv2 + "ControlPort",
- "isEvent" : self.lv2evt + "EventPort",
- "isInput" : self.lv2 + "InputPort",
- "isOutput" : self.lv2 + "OutputPort",
+ "isAudio" : lv2 + "AudioPort",
+ "isControl" : lv2 + "ControlPort",
+ "isEvent" : lv2evt + "EventPort",
+ "isInput" : lv2 + "InputPort",
+ "isOutput" : lv2 + "OutputPort",
}
- for port in info.bySubject[uri][self.lv2 + "port"]:
+ for port in info.bySubject[uri][lv2 + "port"]:
psubj = info.bySubject[port]
pdata = {}
- pdata['index'] = info.getProperty(psubj, self.lv2 + "index")[0]
- pdata['symbol'] = info.getProperty(psubj, self.lv2 + "symbol")[0]
- pdata['name'] = info.getProperty(psubj, self.lv2 + "name")[0]
+ pdata['index'] = int(info.getProperty(psubj, lv2 + "index")[0])
+ pdata['symbol'] = info.getProperty(psubj, lv2 + "symbol")[0]
+ pdata['name'] = info.getProperty(psubj, lv2 + "name")[0]
classes = set(info.getProperty(psubj, "a"))
pdata['classes'] = classes
for pt in porttypes.keys():
pdata[pt] = porttypes[pt] in classes
- sp = info.getProperty(psubj, self.lv2 + "scalePoint")
+ sp = info.getProperty(psubj, lv2 + "scalePoint")
if sp and len(sp):
splist = []
for pt in sp:
@@ -257,10 +260,11 @@ class FakeServer(object):
pdata['scalePoints'] = splist
else:
pdata['scalePoints'] = []
- pdata['default'] = info.getProperty(psubj, [self.lv2 + "default"], optional = True, single = True)
- pdata['minimum'] = info.getProperty(psubj, [self.lv2 + "minimum"], optional = True, single = True)
- pdata['maximum'] = info.getProperty(psubj, [self.lv2 + "maximum"], optional = True, single = True)
+ pdata['default'] = info.getProperty(psubj, [lv2 + "default"], optional = True, single = True)
+ pdata['minimum'] = info.getProperty(psubj, [lv2 + "minimum"], optional = True, single = True)
+ pdata['maximum'] = info.getProperty(psubj, [lv2 + "maximum"], optional = True, single = True)
ports.append(pdata)
+ ports.sort(lambda x, y: cmp(x['index'], y['index']))
dest['ports'] = ports
return dest
diff --git a/bigbull/inspect.py b/bigbull/inspect.py
index 793be55..baf71a4 100644
--- a/bigbull/inspect.py
+++ b/bigbull/inspect.py
@@ -11,7 +11,7 @@ class URIListReceiver:
def receiveData(self, data):
#print "URI list received: " + repr(data.result)
for uri in data.result:
- cmd = client.CommandExec('get_info', uri)
+ cmd = client.CommandExec('get_plugin_info', uri)
cmd.run()
res = cmd.result
plugins[res["name"]] = res
@@ -22,21 +22,24 @@ cmd.run()
for p in plugins.keys():
pl = plugins[p]
- print "Plugin: %s" % pl["name"]
- print "License: %s" % pl["license"]
- print "Classes: %s" % pl["classes"]
+ plugin = client.LV2Plugin(pl)
+ print "Plugin: %s" % plugin.name
+ print "License: %s" % plugin.license
+ print "Classes: %s" % plugin.classes
+ print "Required features: %s" % list(plugin.requiredFeatures)
+ print "Optional features: %s" % list(plugin.optionalFeatures)
print "Ports:"
types = ["Audio", "Control", "Event", "Input", "Output"]
- for port in pl["ports"]:
+ for port in plugin.ports:
extra = []
for type in types:
- if port["is" + type]:
+ if port.__dict__["is" + type]:
extra.append(type)
for sp in ["default", "minimum", "maximum"]:
- if port[sp] != None:
- extra.append("%s=%s" % (sp, port[sp]))
- print "%4s %-20s %-40s %s" % (port["index"], port["symbol"], port["name"], ", ".join(extra))
- splist = port["scalePoints"]
+ if port.__dict__[sp] != None:
+ extra.append("%s=%s" % (sp, port.__dict__[sp]))
+ print "%4s %-20s %-40s %s" % (port.index, port.symbol, port.name, ", ".join(extra))
+ splist = port.scalePoints
splist.sort(lambda x, y: cmp(x[1], y[1]))
if len(splist):
for sp in splist:
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list