def read_conf(conf_file, out_format='simple'):
 ret_commented = []
 ret_simple = {}
 with salt.utils.fopen(conf_file, 'r') as fp_:
  for line in fp_.readlines():
   if ('=' not in line):
    ret_commented.append(line)
    continue
   comps = line.split('=')
   value = '='.join(comps[1:]).strip()
   comment = None
   if value.strip().startswith('#'):
    vcomps = value.strip().split('#')
    value = vcomps[1].strip()
    comment = '#'.join(vcomps[1:]).strip()
    ret_commented.append({comps[0].strip(): {'value': value, 'comment': comment}})
   else:
    ret_commented.append({comps[0].strip(): value})
    ret_simple[comps[0].strip()] = value
 if (out_format == 'simple'):
  return ret_simple
 return ret_commented

def read_conf ( conf_file , out_format = 'simple' ) : ret_commented = [ ] ret_simple = { } with salt . utils . fopen ( conf_file , 'r' ) as fp_ : for line in fp_ . readlines ( ) : if ( '=' not in line ) : ret_commented . append ( line ) continue comps = line . split ( '=' ) value = '=' . join ( comps [ 1 : ] ) . strip ( ) comment = None if value . strip ( ) . startswith ( '#' ) : vcomps = value . strip ( ) . split ( '#' ) value = vcomps [ 1 ] . strip ( ) comment = '#' . join ( vcomps [ 1 : ] ) . strip ( ) ret_commented . append ( { comps [ 0 ] . strip ( ) : { 'value' : value , 'comment' : comment } } ) else : ret_commented . append ( { comps [ 0 ] . strip ( ) : value } ) ret_simple [ comps [ 0 ] . strip ( ) ] = value if ( out_format == 'simple' ) : return ret_simple return ret_commented
read in an lxc configuration file .