scout/commands/view/institutes.py
def institutes(context, institute_id, json):
    """Show all institutes in the database"""
    LOG.info("Running scout view institutes")
    adapter = context.obj['adapter']

    if institute_id:
        institute_objs = []
        institute_obj = adapter.institute(institute_id)
        if not institute_obj:
            LOG.info("Institute %s does not exost", institute_id)
            return
        institute_objs.append(institute_obj)
    else:
        institute_objs = [ins_obj for ins_obj in adapter.institutes()]
    
    if len(institute_objs) == 0:
        click.echo("No institutes found")
        context.abort()

    header = ''
    if not json:
        for key in institute_objs[0].keys():
            header = header + "{0}\t".format(key)
        
        click.echo(header)

    for institute_obj in institute_objs:
        if json:
            click.echo(institute_obj)
            continue

        row = ''
        for value in institute_obj.values():
            row = row + "{0}\t".format(value)

        click.echo(row)
def institutes(context, institute_id, json):
    """Show all institutes in the database"""
    LOG.info("Running scout view institutes")
    adapter = context.obj['adapter']

    if institute_id:
        institute_objs = []
        institute_obj = adapter.institute(institute_id)
        if not institute_obj:
            LOG.info("Institute %s does not exost", institute_id)
            return
        institute_objs.append(institute_obj)
    else:
        institute_objs = [ins_obj for ins_obj in adapter.institutes()]
    
    if len(institute_objs) == 0:
        click.echo("No institutes found")
        context.abort()

    header = ''
    if not json:
        for key in institute_objs[0].keys():
            header = header + "{0}\t".format(key)
        
        click.echo(header)

    for institute_obj in institute_objs:
        if json:
            click.echo(institute_obj)
            continue

        row = ''
        for value in institute_obj.values():
            row = row + "{0}\t".format(value)

        click.echo(row)
Show all institutes in the database