/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-03-02 00:26:04 UTC
  • Revision ID: teddy@recompile.se-20190302002604-r9kpfc7n8qllwg62
mandos-ctl (print_clients): Factor out making strings from printing

* mandos-ctl (table_rows_of_clients): New.

Show diffs side-by-side

added added

removed removed

Lines of Context:
292
292
 
293
293
 
294
294
def print_clients(clients, keywords):
 
295
    print('\n'.join(table_rows_of_clients(clients, keywords)))
 
296
 
 
297
def table_rows_of_clients(clients, keywords):
295
298
    def valuetostring(value, keyword):
296
299
        if isinstance(value, dbus.Boolean):
297
300
            return "Yes" if value else "No"
307
310
                      for client in clients)),
308
311
        key=key)
309
312
                             for key in keywords)
310
 
    # Print header line
311
 
    print(format_string.format(**tablewords))
 
313
    # Start with header line
 
314
    rows = [format_string.format(**tablewords)]
312
315
    for client in clients:
313
 
        print(format_string
314
 
              .format(**{key: valuetostring(client[key], key)
315
 
                         for key in keywords}))
 
316
        rows.append(format_string
 
317
                    .format(**{key: valuetostring(client[key], key)
 
318
                               for key in keywords}))
 
319
    return rows
316
320
 
317
321
 
318
322
def has_actions(options):