Skip to content

Commit e901c5f

Browse files
committed
Add custom TableFormater for keep same empty list behavior as prettytable 0.6
Fix bug 1165962 And upgrade cliff to 1.3.2, because cliff 1.3.1 depends on prettytable<0.7 Change-Id: I6b38a2d77f6b9bf88d6d64f6c02b98b6c21fda3a
1 parent 00935b8 commit e901c5f

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

quantumclient/quantum/v2_0/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import logging
2020
import re
2121

22+
from cliff.formatters import table
2223
from cliff import lister
2324
from cliff import show
2425

@@ -252,12 +253,30 @@ def update_dict(obj, dict, attributes):
252253
dict[attribute] = getattr(obj, attribute)
253254

254255

256+
class TableFormater(table.TableFormatter):
257+
"""This class is used to keep consistency with prettytable 0.6.
258+
259+
https://bugs.launchpad.net/python-quantumclient/+bug/1165962
260+
"""
261+
def emit_list(self, column_names, data, stdout, parsed_args):
262+
if column_names:
263+
super(TableFormater, self).emit_list(column_names, data, stdout,
264+
parsed_args)
265+
else:
266+
stdout.write('\n')
267+
268+
255269
class QuantumCommand(command.OpenStackCommand):
256270
api = 'network'
257271
log = logging.getLogger(__name__ + '.QuantumCommand')
258272
values_specs = []
259273
json_indent = None
260274

275+
def __init__(self, app, app_args):
276+
super(QuantumCommand, self).__init__(app, app_args)
277+
if hasattr(self, 'formatters'):
278+
self.formatters['table'] = TableFormater()
279+
261280
def get_client(self):
262281
return self.app.client_manager.quantum
263282

tools/pip-requires

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
argparse
2-
cliff>=1.3.1
2+
cliff>=1.3.2
33
httplib2
44
iso8601
55
prettytable>=0.6,<0.8

0 commit comments

Comments
 (0)