示例#1
0
 def _generate_side(typeof):
     '''Internal usage only.'''
     source = random.randrange(2)
     if (source == 0):
         side = literal.generate(typeof)
     else:
         side = command.generate_with_type(typeof)
     return side
示例#2
0
 def _generate_side(typeof):
     '''Internal usage only.'''
     source = random.randrange(2)
     if (source == 0):
         side = literal.generate(typeof)
     else:
         side = command.generate_with_type(typeof)
     return side
示例#3
0
    def generate_with_type(typeof):
        '''
        Static method for generating a command with specific return type. The new generated
        command is randomly selected from all registered commands that have the given return
        type.
        '''
        new_command = command()
        while True:
            cmd = command.registered_commands[random.randrange(len(command.registered_commands))]
            if (cmd[1] == typeof):
                break
        new_command.command = cmd

        #create parameters to command if needed
        new_command.parameters = []
        if (len(new_command.command[3]) > 0):
            for param in new_command.command[3]:
                new_command.parameters.append(literal.generate(param))
        return new_command    
示例#4
0
    def generate():
        '''
        Static method for generating a command instance. Generated command instance
        will be randomly selected from the all registered commands. Returns the generated
        command. 
        '''
        new_command = command()

        #Find a command that is not a status command
        while (True):
            new_command.command = command.registered_commands[random.randrange(len(command.registered_commands))]
            if (new_command.command[4] == False):
                break

        #create parameters to command if needed
        new_command.parameters = []
        if (len(new_command.command[3]) > 0):
            for param in new_command.command[3]:
                new_command.parameters.append(literal.generate(param))
        return new_command    
示例#5
0
    def generate_with_type(typeof):
        '''
        Static method for generating a command with specific return type. The new generated
        command is randomly selected from all registered commands that have the given return
        type.
        '''
        new_command = command()
        while True:
            cmd = command.registered_commands[random.randrange(
                len(command.registered_commands))]
            if (cmd[1] == typeof):
                break
        new_command.command = cmd

        #create parameters to command if needed
        new_command.parameters = []
        if (len(new_command.command[3]) > 0):
            for param in new_command.command[3]:
                new_command.parameters.append(literal.generate(param))
        return new_command
示例#6
0
    def generate():
        '''
        Static method for generating a command instance. Generated command instance
        will be randomly selected from the all registered commands. Returns the generated
        command. 
        '''
        new_command = command()

        #Find a command that is not a status command
        while (True):
            new_command.command = command.registered_commands[random.randrange(
                len(command.registered_commands))]
            if (new_command.command[4] == False):
                break

        #create parameters to command if needed
        new_command.parameters = []
        if (len(new_command.command[3]) > 0):
            for param in new_command.command[3]:
                new_command.parameters.append(literal.generate(param))
        return new_command