def _parse_repo_file(filename):
 repos = {}
 header = ''
 repo = ''
 with salt.utils.fopen(filename, 'r') as rfile:
  for line in rfile:
   if line.startswith('['):
    repo = line.strip().replace('[', '').replace(']', '')
    repos[repo] = {}
   if (not line):
    if (not repo):
     header += line
   if line.startswith('#'):
    if (not repo):
     header += line
    else:
     if ('comments' not in repos[repo]):
      repos[repo]['comments'] = []
     repos[repo]['comments'].append(line.strip())
    continue
   if ('=' in line):
    try:
     comps = line.strip().split('=')
     repos[repo][comps[0].strip()] = '='.join(comps[1:])
    except KeyError:
     log.error("Failed to parse line in %s, offending line was '%s'", filename, line.rstrip())
    if (comps[0].strip() == 'enabled'):
     repos[repo]['disabled'] = (comps[1] != '1')
 return (header, repos)

def _parse_repo_file ( filename ) : repos = { } header = '' repo = '' with salt . utils . fopen ( filename , 'r' ) as rfile : for line in rfile : if line . startswith ( '[' ) : repo = line . strip ( ) . replace ( '[' , '' ) . replace ( ']' , '' ) repos [ repo ] = { } if ( not line ) : if ( not repo ) : header += line if line . startswith ( '#' ) : if ( not repo ) : header += line else : if ( 'comments' not in repos [ repo ] ) : repos [ repo ] [ 'comments' ] = [ ] repos [ repo ] [ 'comments' ] . append ( line . strip ( ) ) continue if ( '=' in line ) : try : comps = line . strip ( ) . split ( '=' ) repos [ repo ] [ comps [ 0 ] . strip ( ) ] = '=' . join ( comps [ 1 : ] ) except KeyError : log . error ( "Failed to parse line in %s, offending line was '%s'" , filename , line . rstrip ( ) ) if ( comps [ 0 ] . strip ( ) == 'enabled' ) : repos [ repo ] [ 'disabled' ] = ( comps [ 1 ] != '1' ) return ( header , repos )
turn a single repo file into a dict .