def getchild(self, window_name, child_name='<STR_LIT>', role='<STR_LIT>', parent='<STR_LIT>'):
matches = []<EOL>if role:<EOL><INDENT>role = re.sub('<STR_LIT:U+0020>', '<STR_LIT:_>', role)<EOL><DEDENT>self._windows = {}<EOL>if parent and (child_name or role):<EOL><INDENT>_window_handle, _window_name =self._get_window_handle(window_name)[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>if not _window_handle:<EOL><INDENT>raise LdtpServerException('<STR_LIT>' %window_name)<EOL><DEDENT>appmap = self._get_appmap(_window_handle, _window_name)<EOL>obj = self._get_object_map(window_name, parent)<EOL>def _get_all_children_under_obj(obj, child_list):<EOL><INDENT>if role and obj['<STR_LIT:class>'] == role:<EOL><INDENT>child_list.append(obj['<STR_LIT:label>'])<EOL><DEDENT>elif child_name and self._match_name_to_appmap(child_name, obj):<EOL><INDENT>child_list.append(obj['<STR_LIT:label>'])<EOL><DEDENT>if obj:<EOL><INDENT>children = obj['<STR_LIT>']<EOL><DEDENT>if not children:<EOL><INDENT>return child_list<EOL><DEDENT>for child in children.split():<EOL><INDENT>return _get_all_children_under_obj(appmap[child],<EOL>child_list)<EOL><DEDENT><DEDENT>matches = _get_all_children_under_obj(obj, [])<EOL>if not matches:<EOL><INDENT>if child_name:<EOL><INDENT>_name = '<STR_LIT>' % child_name<EOL><DEDENT>if role:<EOL><INDENT>_role = '<STR_LIT>' % role<EOL><DEDENT>if parent:<EOL><INDENT>_parent = '<STR_LIT>' % parent<EOL><DEDENT>exception = '<STR_LIT>' % (_name, _role, _parent)<EOL>raise LdtpServerException(exception)<EOL><DEDENT>return matches<EOL><DEDENT>_window_handle, _window_name =self._get_window_handle(window_name)[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>if not _window_handle:<EOL><INDENT>raise LdtpServerException('<STR_LIT>' %window_name)<EOL><DEDENT>appmap = self._get_appmap(_window_handle, _window_name)<EOL>for name in appmap.keys():<EOL><INDENT>obj = appmap[name]<EOL>if role and not child_name and obj['<STR_LIT:class>'] == role:<EOL><INDENT>matches.append(name)<EOL><DEDENT>if parent and child_name and not role andself._match_name_to_appmap(parent, obj):<EOL><INDENT>matches.append(name)<EOL><DEDENT>if child_name and not role andself._match_name_to_appmap(child_name, obj):<EOL><INDENT>return name<EOL>matches.append(name)<EOL><DEDENT>if role and child_name and obj['<STR_LIT:class>'] == role andself._match_name_to_appmap(child_name, obj):<EOL><INDENT>matches.append(name)<EOL><DEDENT><DEDENT>if not matches:<EOL><INDENT>_name = '<STR_LIT>'<EOL>_role = '<STR_LIT>'<EOL>_parent = '<STR_LIT>'<EOL>if child_name:<EOL><INDENT>_name = '<STR_LIT>' % child_name<EOL><DEDENT>if role:<EOL><INDENT>_role = '<STR_LIT>' % role<EOL><DEDENT>if parent:<EOL><INDENT>_parent = '<STR_LIT>' % parent<EOL><DEDENT>exception = '<STR_LIT>' % (_name, _role, _parent)<EOL>raise LdtpServerException(exception)<EOL><DEDENT>return matches<EOL>
Gets the list of object available in the window, which matches
component name or role name or both.

@param window_name: Window name to look for, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param child_name: Child name to search for.
@type child_name: string
@param role: role name to search for, or an empty string for wildcard.
@type role: string
@param parent: parent name to search for, or an empty string for wildcard.
@type role: string
@return: list of matched children names
@rtype: list