@@ -73,6 +73,7 @@ def format_prettytable(table):
7373 for i , row in enumerate (table .rows ):
7474 for j , item in enumerate (row ):
7575 table .rows [i ][j ] = format_output (item )
76+
7677 ptable = table .prettytable ()
7778 ptable .hrules = prettytable .FRAME
7879 ptable .horizontal_char = '.'
@@ -83,12 +84,15 @@ def format_prettytable(table):
8384
8485def format_no_tty (table ):
8586 """Converts SoftLayer.CLI.formatting.Table instance to a prettytable."""
87+
8688 for i , row in enumerate (table .rows ):
8789 for j , item in enumerate (row ):
8890 table .rows [i ][j ] = format_output (item , fmt = 'raw' )
8991 ptable = table .prettytable ()
92+
9093 for col in table .columns :
9194 ptable .align [col ] = 'l'
95+
9296 ptable .hrules = prettytable .NONE
9397 ptable .border = False
9498 ptable .header = False
@@ -304,6 +308,30 @@ def __str__(self):
304308
305309 __repr__ = __str__
306310
311+ # Implement sorting methods.
312+ # NOTE(kmcdonald): functools.total_ordering could be used once support for
313+ # Python 2.6 is dropped
314+ def __eq__ (self , other ):
315+ return self .original == getattr (other , 'original' , other )
316+
317+ def __lt__ (self , other ):
318+ if self .original is None :
319+ return True
320+
321+ other_val = getattr (other , 'original' , other )
322+ if other_val is None :
323+ return False
324+ return self .original < other_val
325+
326+ def __gt__ (self , other ):
327+ return not (self < other or self == other )
328+
329+ def __le__ (self , other ):
330+ return self < other or self == other
331+
332+ def __ge__ (self , other ):
333+ return not self < other
334+
307335
308336def _format_python_value (value ):
309337 """If the value has to_python() defined then return that."""
0 commit comments