def _parse_selections(dpkgselection):
 ret = {}
 if isinstance(dpkgselection, six.string_types):
  dpkgselection = dpkgselection.split('\n')
 for line in dpkgselection:
  if line:
   (_pkg, _state) = line.split()
   if (_state in ret):
    ret[_state].append(_pkg)
   else:
    ret[_state] = [_pkg]
 return ret

def _parse_selections ( dpkgselection ) : ret = { } if isinstance ( dpkgselection , six . string_types ) : dpkgselection = dpkgselection . split ( '\n' ) for line in dpkgselection : if line : ( _pkg , _state ) = line . split ( ) if ( _state in ret ) : ret [ _state ] . append ( _pkg ) else : ret [ _state ] = [ _pkg ] return ret
parses the format from dpkg --get-selections and return a format that pkg .