#NEWLINE# def _find_form( el , form_id = None , form_index = None ) : #NEWLINE# #INDENT# if ( ( form_id is None ) and ( form_index is None ) ) : #NEWLINE# #INDENT# forms = _forms_xpath ( el ) #NEWLINE# for form in forms : #NEWLINE# #INDENT# return form #NEWLINE# #UNINDENT# raise FormNotFound ( 'No forms in page' ) #NEWLINE# #UNINDENT# if ( form_id is not None ) : #NEWLINE# #INDENT# form = el . get_element_by_id ( form_id ) #NEWLINE# if ( form is not None ) : #NEWLINE# #INDENT# return form #NEWLINE# #UNINDENT# forms = _form_name_xpath ( el , name = form_id ) #NEWLINE# if form : #NEWLINE# #INDENT# return forms [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise FormNotFound ( ( 'No form with the name or id of %r (forms: %s)' % ( id , ', ' . join ( _find_form_ids ( el ) ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( form_index is not None ) : #NEWLINE# #INDENT# forms = _forms_xpath ( el ) #NEWLINE# try : #NEWLINE# #INDENT# return forms [ form_index ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# raise FormNotFound ( ( 'There is no form with the index %r (%i forms found)' % ( form_index , len ( forms ) ) ) )