def parse_max_server_instances(value):
 if (':' not in value):
  try:
   max_server_instances = int(value)
  except ValueError:
   raise argparse.ArgumentTypeError(('Invalid instance count: %r' % value))
  else:
   if (not max_server_instances):
    raise argparse.ArgumentTypeError('Cannot specify zero instances for all servers')
   return max_server_instances
 else:
  server_to_max_instances = {}
  for server_instance_max in value.split(','):
   try:
    (server_name, max_instances) = server_instance_max.split(':')
    max_instances = int(max_instances)
   except ValueError:
    raise argparse.ArgumentTypeError(('Expected "server:max_instances": %r' % server_instance_max))
   else:
    server_name = server_name.strip()
    if (server_name in server_to_max_instances):
     raise argparse.ArgumentTypeError(('Duplicate max instance value: %r' % server_name))
    server_to_max_instances[server_name] = max_instances
  return server_to_max_instances

def parse_max_server_instances ( value ) : if ( ':' not in value ) : try : max_server_instances = int ( value ) except ValueError : raise argparse . ArgumentTypeError ( ( 'Invalid instance count: %r' % value ) ) else : if ( not max_server_instances ) : raise argparse . ArgumentTypeError ( 'Cannot specify zero instances for all servers' ) return max_server_instances else : server_to_max_instances = { } for server_instance_max in value . split ( ',' ) : try : ( server_name , max_instances ) = server_instance_max . split ( ':' ) max_instances = int ( max_instances ) except ValueError : raise argparse . ArgumentTypeError ( ( 'Expected "server:max_instances": %r' % server_instance_max ) ) else : server_name = server_name . strip ( ) if ( server_name in server_to_max_instances ) : raise argparse . ArgumentTypeError ( ( 'Duplicate max instance value: %r' % server_name ) ) server_to_max_instances [ server_name ] = max_instances return server_to_max_instances
returns the parsed value for the --max_server_instances flag .