/mandos/release

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

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-03-03 01:16:47 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190303011647-x2oh2nmeuzjuj4bd
mandos-ctl: Rename "tablewords" to "tableheaders"

* mandos-ctl (TableOfClients.tablewords): Rename to "tableheaders";
                                          all users changed.
  (Test_TableOfClients.tablewords): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
269
269
 
270
270
 
271
271
class TableOfClients(object):
272
 
    tablewords = {
 
272
    tableheaders = {
273
273
        "Name": "Name",
274
274
        "Enabled": "Enabled",
275
275
        "Timeout": "Timeout",
292
292
        "LastCheckerStatus": "Last Checker Status",
293
293
    }
294
294
 
295
 
    def __init__(self, clients, keywords, tablewords=None):
 
295
    def __init__(self, clients, keywords, tableheaders=None):
296
296
        self.clients = clients
297
297
        self.keywords = keywords
298
 
        if tablewords is not None:
299
 
            self.tablewords = tablewords
 
298
        if tableheaders is not None:
 
299
            self.tableheaders = tableheaders
300
300
 
301
301
    def __str__(self):
302
302
        return "\n".join(self.rows())
316
316
    def row_formatting_string(self):
317
317
        "Format string used to format table rows"
318
318
        return " ".join("{{{key}:{width}}}".format(
319
 
            width=max(len(self.tablewords[key]),
 
319
            width=max(len(self.tableheaders[key]),
320
320
                      *(len(self.string_from_client(client, key))
321
321
                        for client in self.clients)),
322
322
            key=key)
335
335
        return str(value)
336
336
 
337
337
    def header_line(self, format_string):
338
 
        return format_string.format(**self.tablewords)
 
338
        return format_string.format(**self.tableheaders)
339
339
 
340
340
    def client_line(self, client, format_string):
341
341
        return format_string.format(
746
746
 
747
747
class Test_TableOfClients(unittest.TestCase):
748
748
    def setUp(self):
749
 
        self.tablewords = {
 
749
        self.tableheaders = {
750
750
            "Attr1": "X",
751
751
            "AttrTwo": "Yy",
752
752
            "AttrThree": "Zzz",
793
793
        ]
794
794
    def test_short_header(self):
795
795
        text = str(TableOfClients(self.clients, self.keywords,
796
 
                                  self.tablewords))
 
796
                                  self.tableheaders))
797
797
        expected_text = """
798
798
X  Yy
799
799
x1 y1
803
803
    def test_booleans(self):
804
804
        keywords = ["Bool", "NonDbusBoolean"]
805
805
        text = str(TableOfClients(self.clients, keywords,
806
 
                                  self.tablewords))
 
806
                                  self.tableheaders))
807
807
        expected_text = """
808
808
A D-BUS Boolean A Non-D-BUS Boolean
809
809
No              False              
814
814
        keywords = ["Integer", "Timeout", "Interval", "ApprovalDelay",
815
815
                    "ApprovalDuration", "ExtendedTimeout"]
816
816
        text = str(TableOfClients(self.clients, keywords,
817
 
                                  self.tablewords))
 
817
                                  self.tableheaders))
818
818
        expected_text = """
819
819
An Integer Timedelta 1 Timedelta 2 Timedelta 3 Timedelta 4 Timedelta 5
820
820
0          00:00:00    00:00:01    00:00:02    00:00:03    00:00:04   
824
824
    def test_empty_and_long_string_values(self):
825
825
        keywords = ["String"]
826
826
        text = str(TableOfClients(self.clients, keywords,
827
 
                                  self.tablewords))
 
827
                                  self.tableheaders))
828
828
        expected_text = """
829
829
A String                                                                                                                                                                                                                                                                                                                                  
830
830