Exemplo n.º 1
0
def org_list(config):
    check_connected_app(config)
    data = []
    headers = [
        'org', 'default', 'scratch', 'days', 'expired', 'config_name',
        'username'
    ]
    for org in config.project_config.list_orgs():
        org_config = config.project_config.get_org(org)
        row = [org]
        row.append('*' if org_config.default else '')
        row.append('*' if org_config.scratch else '')
        if org_config.days_alive:
            row.append('{} of {}'.format(org_config.days_alive, org_config.days
                                         ) if org_config.scratch else '')
        else:
            row.append(org_config.days if org_config.scratch else '')
        row.append('*' if org_config.scratch and org_config.expired else '')
        row.append(org_config.config_name if org_config.config_name else '')
        username = org_config.config.get(
            'username', org_config.userinfo__preferred_username)
        row.append(username if username else '')
        data.append(row)
    table = Table(data, headers)
    click.echo(table)
Exemplo n.º 2
0
def org_list(config):
    data = []
    headers = [
        "org",
        "default",
        "scratch",
        "days",
        "expired",
        "config_name",
        "username",
    ]
    for org in config.project_config.keychain.list_orgs():
        org_config = config.project_config.keychain.get_org(org)
        row = [org]
        row.append("*" if org_config.default else "")
        row.append("*" if org_config.scratch else "")
        if org_config.days_alive:
            row.append("{} of {}".format(org_config.days_alive, org_config.days
                                         ) if org_config.scratch else "")
        else:
            row.append(org_config.days if org_config.scratch else "")
        row.append("*" if org_config.scratch and org_config.expired else "")
        row.append(org_config.config_name if org_config.config_name else "")
        username = org_config.config.get(
            "username", org_config.userinfo__preferred_username)
        row.append(username if username else "")
        data.append(row)
    table = Table(data, headers)
    click.echo(table)
Exemplo n.º 3
0
def task_list(config):
    check_project_config(config)
    data = []
    headers = ['task', 'description']
    for task in config.project_config.list_tasks():
        data.append((task['name'], task['description']))
    table = Table(data, headers)
    click.echo(table)
Exemplo n.º 4
0
def task_list(config):
    config.check_project_config()
    data = []
    headers = ["task", "description"]
    for task in config.project_config.list_tasks():
        data.append((task["name"], task["description"]))
    table = Table(data, headers)
    click.echo(table)
Exemplo n.º 5
0
def flow_list(config):
    config.check_project_config()
    data = []
    headers = ["flow", "description"]
    for flow in config.project_config.list_flows():
        data.append((flow["name"], flow["description"]))
    table = Table(data, headers)
    click.echo(table)
Exemplo n.º 6
0
def flow_list(config):
    check_project_config(config)
    data = []
    headers = ['flow', 'description']
    for flow in config.project_config.flows:
        description = getattr(config.project_config, 'flows__{}__description'.format(flow))
        data.append((flow, description))
    table = Table(data, headers)
    click.echo(table)
Exemplo n.º 7
0
def service_list(config):
    headers = ["service", "description", "is_configured"]
    data = []
    for serv, schema in list(config.project_config.services.items()):
        is_configured = ""
        if serv in config.keychain.list_services():
            is_configured = "* "
        data.append((serv, schema["description"], is_configured))
    table = Table(data, headers)
    click.echo(table)
Exemplo n.º 8
0
def flow_list(config):
    data = []
    headers = ["flow", "description"]
    for flow in config.project_config.list_flows():
        data.append((flow["name"], flow["description"]))
    table = Table(data, headers)
    click.echo(table)
    click.echo("")
    click.echo("Use " + click.style("cci flow info <task_name>", bold=True) +
               " to get more information about a flow.")
Exemplo n.º 9
0
def service_list(config):
    headers = ['service', 'description', 'is_configured']
    data = []
    for serv, schema in list(config.project_config.services.items()):
        is_configured = ''
        if serv in config.keychain.list_services():
            is_configured = '* '
        data.append((serv, schema['description'], is_configured))
    table = Table(data, headers)
    click.echo(table)
Exemplo n.º 10
0
def task_list(config):
    data = []
    headers = ["task", "description"]
    for task in config.project_config.list_tasks():
        data.append((task["name"], task["description"]))
    table = Table(data, headers)
    click.echo(table)
    click.echo("")
    click.echo("Use " + click.style("cci task info <task_name>", bold=True) +
               " to get more information about a task.")
Exemplo n.º 11
0
def org_list(config):
    check_connected_app(config)
    data = []
    headers = ['org', 'is_default']
    for org in config.project_config.list_orgs():
        org_config = config.project_config.get_org(org)
        if org_config.default:
            data.append((org, '*'))
        else:
            data.append((org, ''))
    table = Table(data, headers)
    click.echo(table)
Exemplo n.º 12
0
def task_list(config):
    data = []
    headers = ["task", "description"]
    task_groups = OrderedDict()
    for task in config.project_config.list_tasks():
        group = task["group"] or "Other"
        if group not in task_groups:
            task_groups[group] = []
        task_groups[group].append(task)
    for group, tasks in task_groups.items():
        data.append(("", ""))
        data.append(("-- {} --".format(group), ""))
        for task in sorted(tasks, key=operator.itemgetter("name")):
            data.append((task["name"], task["description"]))
    table = Table(data, headers)
    click.echo(table)
    click.echo("")
    click.echo("Use " + click.style("cci task info <task_name>", bold=True) +
               " to get more information about a task.")
Exemplo n.º 13
0
def task_info(config, task_name):
    check_project_config(config)
    task_config = getattr(config.project_config, 'tasks__{}'.format(task_name))
    if not task_config:
        raise TaskNotFoundError('Task not found: {}'.format(task_name))

    task_config = TaskConfig(task_config)
    click.echo(rst2ansi(doc_task(task_name, task_config)))
    return
    class_path = task_config.get('class_path')
    task_class = import_class(class_path)

    # General task info
    click.echo('Description: {}'.format(task_config.get('description')))
    click.echo('Class: {}'.format(task_config.get('class_path')))

    # Default options
    default_options = task_config.get('options', {})
    if default_options:
        click.echo('')
        click.echo('Default Option Values')
        for key, value in default_options.items():
            click.echo('    {}: {}'.format(key, value))

    # Task options
    task_options = getattr(task_class, 'task_options', {})
    if task_options:
        click.echo('')
        data = []
        headers = ['Option', 'Required', 'Description']
        for key, option in task_options.items():
            if option.get('required'):
                data.append((key, '*', option.get('description')))
            else:
                data.append((key, '', option.get('description')))
        table = Table(data, headers)
        click.echo(table)
Exemplo n.º 14
0
from plaintable import Table

print('Standard Usage')
print('======== =====')
print()

data = [
    [1, 2, 3, 4, 5],
    [10, 11, 12, 13, 14],
    ['a', 'b', 'c', 'd', 'e'],
    [1.0, 2.0, 1.5, 4.25, 10.50],
]
headline = ['one', 'two', 'three', 'four', 'five']
table = Table(data, headline)
print(table)

print()
print()

print('Extended Usage')
print('======== =====')
print()

print('orig len:', len(table))

import math
new_row = [121.21, math.pi, math.e, -9.9999999, math.sqrt(2)]
table.append(new_row)
print('new len: ', len(table))
print()