/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 02:33:00 UTC
  • Revision ID: teddy@recompile.se-20190302023300-cgss6bf71mwfb0ma
mandos-ctl: Refactor

* mandos-ctl (TableOfClients.__str__): New.
  (TableOfClients.__unicode__): New.
  (print_clients): Remove.
  (main): Create and print TableOfClients object directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
269
269
    return value
270
270
 
271
271
 
272
 
def print_clients(clients, keywords):
273
 
    print('\n'.join(TableOfClients(clients, keywords).rows()))
274
 
 
275
272
class TableOfClients(object):
276
273
    tablewords = {
277
274
        "Name": "Name",
302
299
        if tablewords is not None:
303
300
            self.tablewords = tablewords
304
301
 
 
302
    def __str__(self):
 
303
        return "\n".join(self.rows())
 
304
 
 
305
    if sys.version_info.major == 2:
 
306
        __unicode__ = __str__
 
307
        def __str__(self):
 
308
            return str(self).encode(locale.getpreferredencoding())
 
309
 
305
310
    def rows(self):
306
311
        format_string = self.row_formatting_string()
307
312
        rows = [self.header_line(format_string)]
501
506
                      separators=(',', ': '))
502
507
            print()
503
508
        else:
504
 
            print_clients(clients.values(), keywords)
 
509
            print(TableOfClients(clients.values(), keywords))
505
510
    else:
506
511
        # Process each client in the list by all selected options
507
512
        for client in clients: