コード例 #1
0
def check_template_exists(template):
    """Check if template exists"""
   
    try: 
        commands.get_all_commands()[template]
    except KeyError:
        return False
    return True
コード例 #2
0
ファイル: tools.py プロジェクト: dreamsxin/quickly
def check_template_exists(template):
    """Check if template exists"""

    try:
        commands.get_all_commands()[template]
    except KeyError:
        return False
    return True
コード例 #3
0
def list_template_for_command(command_name):
    """from the command_name, return all templates containing it"""
    proposed_templates = []
    for template in commands.get_all_templates():
        try:
            commands.get_all_commands()[template][command_name]
            proposed_templates.append(template)
        except KeyError:
            pass
    return proposed_templates
コード例 #4
0
ファイル: tools.py プロジェクト: dreamsxin/quickly
def list_template_for_command(command_name):
    """from the command_name, return all templates containing it"""
    proposed_templates = []
    for template in commands.get_all_templates():
        try:
            commands.get_all_commands()[template][command_name]
            proposed_templates.append(template)
        except KeyError:
            pass
    return proposed_templates
コード例 #5
0
def get_all_commands():
    '''return a dictionnary of template: (commands)'''
    
    templates_commands_dict = {}
    all_commands = commands.get_all_commands()
    for template in all_commands:
        commands_in_template = (command_name for command_name in all_commands[template])
        templates_commands_dict[template] = commands_in_template
    return templates_commands_dict
コード例 #6
0
def run_command(command_name, template='builtins', path=None, *args):
    '''run a command from a template'''

    if not path:
        path = os.getcwd()
    configurationhandler.loadConfig(can_stop=False, config_file_path=path)
    try:
        project_template = configurationhandler.project_config['template']
    except KeyError:
        project_template = None
        if template != 'builtins':
            project_template = template
    command = commands.get_all_commands()[template][command_name]    
    return_code = command.launch(path, list(args), project_template)

    return return_code    
コード例 #7
0
def commands(project_template, project_dir, command_args, shell_completion=False):
    """List all commands ordered by templates"""

    # We have nothing for this
    if shell_completion:
        return("")

    all_commands = commands_module.get_all_commands()
    for template_available in all_commands:
        # copie all commands to a list (as sort() is an inplace function)
        command_for_this_template = list(all_commands[template_available].keys())
        command_for_this_template.sort()
        for command_name in command_for_this_template:
            command = all_commands[template_available][command_name]
            print "[%s]\t%s" % (template_available, command_name)
            
    return(0)