def _parse_add_values(argvish):
 (new_cmd_format, opts, args) = validate_args(argvish)
 parsed_devs = []
 if (len(args) > 0):
  if (new_cmd_format or ((len(args) % 2) != 0)):
   print(Commands.add.__doc__.strip())
   exit(EXIT_ERROR)
  devs_and_weights = izip(islice(args, 0, len(args), 2), islice(args, 1, len(args), 2))
  for (devstr, weightstr) in devs_and_weights:
   dev_dict = parse_add_value(devstr)
   if (dev_dict['region'] is None):
    stderr.write(('WARNING: No region specified for %s. Defaulting to region 1.\n' % devstr))
    dev_dict['region'] = 1
   if (dev_dict['replication_ip'] is None):
    dev_dict['replication_ip'] = dev_dict['ip']
   if (dev_dict['replication_port'] is None):
    dev_dict['replication_port'] = dev_dict['port']
   weight = float(weightstr)
   if (weight < 0):
    raise ValueError(('Invalid weight value: %s' % devstr))
   dev_dict['weight'] = weight
   parsed_devs.append(dev_dict)
 else:
  parsed_devs.append(build_dev_from_opts(opts))
 return parsed_devs

def _parse_add_values ( argvish ) : ( new_cmd_format , opts , args ) = validate_args ( argvish ) parsed_devs = [ ] if ( len ( args ) > 0 ) : if ( new_cmd_format or ( ( len ( args ) % 2 ) != 0 ) ) : print ( Commands . add . __doc__ . strip ( ) ) exit ( EXIT_ERROR ) devs_and_weights = izip ( islice ( args , 0 , len ( args ) , 2 ) , islice ( args , 1 , len ( args ) , 2 ) ) for ( devstr , weightstr ) in devs_and_weights : dev_dict = parse_add_value ( devstr ) if ( dev_dict [ 'region' ] is None ) : stderr . write ( ( 'WARNING: No region specified for %s. Defaulting to region 1.\n' % devstr ) ) dev_dict [ 'region' ] = 1 if ( dev_dict [ 'replication_ip' ] is None ) : dev_dict [ 'replication_ip' ] = dev_dict [ 'ip' ] if ( dev_dict [ 'replication_port' ] is None ) : dev_dict [ 'replication_port' ] = dev_dict [ 'port' ] weight = float ( weightstr ) if ( weight < 0 ) : raise ValueError ( ( 'Invalid weight value: %s' % devstr ) ) dev_dict [ 'weight' ] = weight parsed_devs . append ( dev_dict ) else : parsed_devs . append ( build_dev_from_opts ( opts ) ) return parsed_devs
parse devices to add as specified on the command line .