def _parse_modes(mode_string, unary_modes=''):
 if ((not mode_string) or (not (mode_string[0] in '+-'))):
  return []
 modes = []
 parts = mode_string.split()
 (mode_part, args) = (parts[0], parts[1:])
 for ch in mode_part:
  if (ch in '+-'):
   sign = ch
   continue
  arg = (args.pop(0) if ((ch in unary_modes) and args) else None)
  modes.append([sign, ch, arg])
 return modes

def _parse_modes ( mode_string , unary_modes = '' ) : if ( ( not mode_string ) or ( not ( mode_string [ 0 ] in '+-' ) ) ) : return [ ] modes = [ ] parts = mode_string . split ( ) ( mode_part , args ) = ( parts [ 0 ] , parts [ 1 : ] ) for ch in mode_part : if ( ch in '+-' ) : sign = ch continue arg = ( args . pop ( 0 ) if ( ( ch in unary_modes ) and args ) else None ) modes . append ( [ sign , ch , arg ] ) return modes
parse the mode_string and return a list of triples .