1 '''
2 Defines functions that make queryInterface more Pythonic.
3
4 @author: Peter Parente
5 @author: Pete Brunet
6 @organization: IBM Corporation
7 @copyright: Copyright (c) 2005, 2007 IBM Corporation
8 @license: The BSD License
9
10 All rights reserved. This program and the accompanying materials are made
11 available under the terms of the BSD license which accompanies
12 this distribution, and is available at
13 U{http://www.opensource.org/licenses/bsd-license.php}
14 '''
15
16 import Constants
17
19 '''
20 Queries an object for another interface.
21
22 @param obj: Object to query for another interface
23 @type obj: object
24 @param idl: Desired interface identifier
25 @type idl: string
26 @return: An object with the desired interface
27 @rtype: object
28 @raise NotImplementedError: When the desired interface is not supported
29 '''
30 try:
31 i = obj.queryInterface(idl)
32 except Exception:
33 raise NotImplementedError
34 if i is None:
35 raise NotImplementedError
36 i = i._narrow(i.__class__)
37 return i
38
45
52
59
66
73
75 '''
76 @return: Object with the Desktop interface or None if not supported
77 @rtype: Accessibility.Desktop
78 '''
79 return queryInterface(obj, Constants.DESKTOP_IDL)
80
87
89 '''
90 @return: Object with the EditableText interface or None if not supported
91 @rtype: Accessibility.EditableText
92 '''
93 return queryInterface(obj, Constants.EDITABLE_TEXT_IDL)
94
101
102 -def IHypertext(obj):
103 '''
104 @return: Object with the Hypertext interface or None if not supported
105 @rtype: Accessibility.Hypertext
106 '''
107 return queryInterface(obj, Constants.HYPERTEXT_IDL)
108
110 '''
111 @return: Object with the Image interface or None if not supported
112 @rtype: Accessibility.Image
113 '''
114 return queryInterface(obj, Constants.IMAGE_IDL)
115
122
124 '''
125 @return: Object with the StreamableContent interface or None if not supported
126 @rtype: Accessibility.StreamableContent
127 '''
128 return queryInterface(obj, Constants.STREAMABLE_CONTENT_IDL)
129
131 '''
132 @return: Object with the Table interface or None if not supported
133 @rtype: Accessibility.Table
134 '''
135 return queryInterface(obj, Constants.TABLE_IDL)
136
138 '''
139 @return: Object with the Text interface or None if not supported
140 @rtype: Accessibility.Text
141 '''
142 return queryInterface(obj, Constants.TEXT_IDL)
143
145 '''
146 @return: Object with the Value interface or None if not supported
147 @rtype: Accessibility.Value
148 '''
149 return queryInterface(obj, Constants.VALUE_IDL)
150
152 '''
153 @return: Object with the Selection interface or None if not supported
154 @rtype: Accessibility.Selection
155 '''
156 return queryInterface(obj, Constants.SELECTION_IDL)
157