1 """I am the content handler for mimetype application/x-advene-type-constraint.
2 """
3
4 from advene.model.exceptions import ContentHandlingError
5
6 from gettext import gettext as _
7
8
9
11 """Is this view_handler likely to handle a view with that mimetype.
12
13 Return an int between 00 and 99, indicating the likelyhood of this handler
14 to handle correctly the given mimetype. 70 is used as a standard value when
15 the hanlder is pretty sure it can handle the mimetype.
16 """
17 if mimetype == "application/x-advene-type-constraint":
18 return 99
19 else:
20 return 0
21
23 """Return the mimetype of the content produced by that view.
24
25 Note that the output mimetype may depend on the mimetype of the view, as
26 well as the content of the view itself, but should not depend on the
27 element the view is applied to.
28 """
29 return "application/x-advene-diagnosis"
30
31
32
33
34
52
54 e1, e2 = expected.split("/")
55 a1, a2 = actual.split("/")
56 return (e1 == "*" or a1 == e1) and (e2 == "*" or a2 == e2)
57
60 assert value is None or isinstance(value, list)
61 if value is None:
62 value = []
63 self._v = value
64
66 return len(self._v) == 0
67
69 for template, args in self._v:
70 yield _(template) % args
71
73 return "\n".join(self)
74
76 return "Diagnosis(%r)" % self._v
77
79 if isinstance(rho, Diagnosis):
80 return Diagnosis(self._v + rho._v)
81 elif not rho:
82 return rho
83 else:
84 return self
85
87 if isinstance(lho, Diagnosis):
88 return Diagnosis(lho + self._v)
89 elif lho:
90 return self
91 else:
92 return lho
93
94 - def append(self, template, **args):
95 self._v.append((template, args))
96
97
98