def _parse_file(document_file, validate, entry_class, entry_keyword='r', start_position=None, end_position=None, section_end_keywords=(), extra_args=()):
 if start_position:
  document_file.seek(start_position)
 else:
  start_position = document_file.tell()
 if section_end_keywords:
  first_keyword = None
  line_match = KEYWORD_LINE.match(stem.util.str_tools._to_unicode(document_file.readline()))
  if line_match:
   first_keyword = line_match.groups()[0]
  document_file.seek(start_position)
  if (first_keyword in section_end_keywords):
   return
 while ((end_position is None) or (document_file.tell() < end_position)):
  (desc_lines, ending_keyword) = _read_until_keywords(((entry_keyword,) + section_end_keywords), document_file, ignore_first=True, end_position=end_position, include_ending_keyword=True)
  desc_content = bytes.join('', desc_lines)
  if desc_content:
   (yield entry_class(desc_content, validate, *extra_args))
   if (ending_keyword in section_end_keywords):
    break
  else:
   break

def _parse_file ( document_file , validate , entry_class , entry_keyword = 'r' , start_position = None , end_position = None , section_end_keywords = ( ) , extra_args = ( ) ) : if start_position : document_file . seek ( start_position ) else : start_position = document_file . tell ( ) if section_end_keywords : first_keyword = None line_match = KEYWORD_LINE . match ( stem . util . str_tools . _to_unicode ( document_file . readline ( ) ) ) if line_match : first_keyword = line_match . groups ( ) [ 0 ] document_file . seek ( start_position ) if ( first_keyword in section_end_keywords ) : return while ( ( end_position is None ) or ( document_file . tell ( ) < end_position ) ) : ( desc_lines , ending_keyword ) = _read_until_keywords ( ( ( entry_keyword , ) + section_end_keywords ) , document_file , ignore_first = True , end_position = end_position , include_ending_keyword = True ) desc_content = bytes . join ( '' , desc_lines ) if desc_content : ( yield entry_class ( desc_content , validate , * extra_args ) ) if ( ending_keyword in section_end_keywords ) : break else : break
iterates over a tordnsel file .