Fix print_list label name in troveclient/utils.py
The output of list make nice labels from fields. Fisrt, replace underscore with space. Then, replace "id" with "ID". Finally, capitalize each word. This works fine for "*_id"(for exmaple, "flavor_id" will be replaced to "Flavor ID"), but when a word has a "id" inside, it will be wrong. For example, "cidr" will be replaced to "CIDr", actually it should be "Cidr". This change fix the problem, only "id" after a underscore will be replaced to "ID". Change-Id: I8e357c946b21dc6f6c6c79d78a45f23b440a57da
This commit is contained in:
@@ -157,7 +157,7 @@ def print_list(objs, fields, formatters={}, order_by=None, obj_is_dict=False,
|
||||
for field in fields:
|
||||
if field not in labels:
|
||||
# No underscores (use spaces instead) and uppercase any ID's
|
||||
label = field.replace("_", " ").replace("id", "ID")
|
||||
label = field.replace("_", " ").replace(" id", " ID")
|
||||
# Uppercase anything else that's less than 3 chars
|
||||
if len(label) < 3:
|
||||
label = label.upper()
|
||||
|
Reference in New Issue
Block a user