def parse_mapping(fileobj, filename=None):
 extractors = {}
 method_map = []
 options_map = {}
 parser = RawConfigParser()
 parser._sections = odict(parser._sections)
 parser.readfp(fileobj, filename)
 for section in parser.sections():
  if (section == 'extractors'):
   extractors = dict(parser.items(section))
  else:
   (method, pattern) = [part.strip() for part in section.split(':', 1)]
   method_map.append((pattern, method))
   options_map[pattern] = dict(parser.items(section))
 if extractors:
  for (idx, (pattern, method)) in enumerate(method_map):
   if (method in extractors):
    method = extractors[method]
   method_map[idx] = (pattern, method)
 return (method_map, options_map)

def parse_mapping ( fileobj , filename = None ) : extractors = { } method_map = [ ] options_map = { } parser = RawConfigParser ( ) parser . _sections = odict ( parser . _sections ) parser . readfp ( fileobj , filename ) for section in parser . sections ( ) : if ( section == 'extractors' ) : extractors = dict ( parser . items ( section ) ) else : ( method , pattern ) = [ part . strip ( ) for part in section . split ( ':' , 1 ) ] method_map . append ( ( pattern , method ) ) options_map [ pattern ] = dict ( parser . items ( section ) ) if extractors : for ( idx , ( pattern , method ) ) in enumerate ( method_map ) : if ( method in extractors ) : method = extractors [ method ] method_map [ idx ] = ( pattern , method ) return ( method_map , options_map )
parse an extraction method mapping from a file-like object .