parameters: (fn, tag_dict)
return_statement: return etf_file_dict
docstring: Read FN, putting ETF info into
      a giant dictionary.  The keys of TAG_DICT indicate which tags
      to put into the dict.
docstring_summary: Read FN, putting ETF info into
      a giant dictionary.  The keys of TAG_DICT indicate which tags
      to put into the dict.
docstring_tokens: Read FN putting ETF info into a giant dictionary . The keys of TAG_DICT indicate which tags to put into the dict .
function: def parse_etf_file(fn, tag_dict):
      """ Read FN, putting ETF info into
      a giant dictionary.  The keys of TAG_DICT indicate which tags
      to put into the dict.
      """
  
      sys.stderr.write('parsing ... ')
      f = open(fn, encoding='utf-8')
  
      gulp = re.sub('[\n\r]+', '\n',  f.read())
      ls = gulp.split('\n^')
  
      etf_file_dict = {}
      for k in tag_dict:
          etf_file_dict[k] = {}
  
      last_tag = None
      last_numbers = None
  
      for l in ls:
          m = re.match(r'^([a-zA-Z0-9&]+)\(([^)]+)\)', l)
          if m and m.group(1) in tag_dict:
              tag = m.group(1)
  
              indices = tuple([int(s) for s in m.group(2).split(',')])
              content = l[m.end(2)+1:]
  
              tdict = etf_file_dict[tag]
              if indices not in tdict:
                  tdict[indices] = []
  
              parsed = []
  
              if tag == 'verse' or tag == 'block':
                  m2 = re.match(r'(.*)\^end', content)
                  if m2:
                      parsed = [m2.group(1)]
              else:
                  while content:
                      (v, content) = read_finale_value(content)
                      if v is not None:
                          parsed.append(v)
  
              tdict[indices].extend(parsed)
  
              last_indices = indices
              last_tag = tag
  
              continue
  
  # let's not do this: this really confuses when eE happens to be before  a ^text.
  #                if last_tag and last_indices:
  #                        etf_file_dict[last_tag][last_indices].append (l)
  
      sys.stderr.write('\n')
      return etf_file_dict
function_tokens: def parse_etf_file ( fn , tag_dict ) : sys . stderr . write ( 'parsing ... ' ) f = open ( fn , encoding = 'utf-8' ) gulp = re . sub ( '[\n\r]+' , '\n' , f . read ( ) ) ls = gulp . split ( '\n^' ) etf_file_dict = { } for k in tag_dict : etf_file_dict [ k ] = { } last_tag = None last_numbers = None for l in ls : m = re . match ( r'^([a-zA-Z0-9&]+)\(([^)]+)\)' , l ) if m and m . group ( 1 ) in tag_dict : tag = m . group ( 1 ) indices = tuple ( [ int ( s ) for s in m . group ( 2 ) . split ( ',' ) ] ) content = l [ m . end ( 2 ) + 1 : ] tdict = etf_file_dict [ tag ] if indices not in tdict : tdict [ indices ] = [ ] parsed = [ ] if tag == 'verse' or tag == 'block' : m2 = re . match ( r'(.*)\^end' , content ) if m2 : parsed = [ m2 . group ( 1 ) ] else : while content : ( v , content ) = read_finale_value ( content ) if v is not None : parsed . append ( v ) tdict [ indices ] . extend ( parsed ) last_indices = indices last_tag = tag continue # let's not do this: this really confuses when eE happens to be before  a ^text. #                if last_tag and last_indices: #                        etf_file_dict[last_tag][last_indices].append (l) sys . stderr . write ( '\n' ) return etf_file_dict