6 lv2
= "http://lv2plug.in/ns/lv2core#"
7 lv2evt
= "http://lv2plug.in/ns/ext/event#"
8 rdf
= "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
9 rdfs
= "http://www.w3.org/2000/01/rdf-schema#"
10 rdf_type
= rdf
+ "type"
13 def addTriple(self
, s
, p
, o
):
14 print "%s [%s] %s" % (s
, p
, repr(o
))
20 def getByType(self
, classname
):
21 classes
= self
.bySubject
["$classes"]
22 if classname
in classes
:
23 return classes
[classname
]
25 def getByPropType(self
, propname
):
26 if propname
in self
.byPredicate
:
27 return self
.byPredicate
[propname
]
29 def getProperty(self
, subject
, props
, optional
= False, single
= False):
30 if type(props
) is list:
34 if type(subject
) is str:
35 subject
= self
.bySubject
[subject
]
36 elif type(subject
) is dict:
45 for o
in subject
[prop
]:
47 if type(props
) is list:
52 value
= self
.getProperty(v
, props
[1:], optional
= optional
, single
= True)
56 result |
= set(self
.getProperty(v
, props
[1:], optional
= optional
, single
= False))
64 raise Exception, "More than one value of " + prop
65 return list(anyprops
)[0]
71 def addTriple(self
, s
, p
, o
):
74 if s
not in self
.bySubject
:
75 self
.bySubject
[s
] = {}
76 if p
not in self
.bySubject
[s
]:
77 self
.bySubject
[s
][p
] = []
78 self
.bySubject
[s
][p
].append(o
)
79 if p
not in self
.byPredicate
:
80 self
.byPredicate
[p
] = {}
81 if s
not in self
.byPredicate
[p
]:
82 self
.byPredicate
[p
][s
] = []
83 self
.byPredicate
[p
][s
].append(o
)
85 self
.addTriple("$classes", o
, s
)
86 def copyFrom(self
, src
):
87 for s
in src
.bySubject
:
91 self
.addTriple(s
, p
, o
)
93 for s
in self
.bySubject
.keys():
94 for p
in self
.bySubject
[s
].keys():
95 print "%s %s %s" % (s
, p
, self
.bySubject
[s
][p
])
97 class FakeServer(object):
103 instance
= FakeServer()
105 def queue(cmdObject
):
108 cmdObject
.calledOnOK(type(instance
).__dict
__[cmdObject
.type](instance
, *cmdObject
.args
))
110 # cmdObject.calledOnError(repr(sys.exc_info()))