Revision c1912a48 lib/cli.py
b/lib/cli.py | ||
---|---|---|
315 | 315 |
constants.ISPECS_STD: constants.VTYPE_INT, |
316 | 316 |
} |
317 | 317 |
|
318 |
#: User-friendly names for query2 field types |
|
319 |
_QFT_NAMES = { |
|
320 |
constants.QFT_UNKNOWN: "Unknown", |
|
321 |
constants.QFT_TEXT: "Text", |
|
322 |
constants.QFT_BOOL: "Boolean", |
|
323 |
constants.QFT_NUMBER: "Number", |
|
324 |
constants.QFT_UNIT: "Storage size", |
|
325 |
constants.QFT_TIMESTAMP: "Timestamp", |
|
326 |
constants.QFT_OTHER: "Custom", |
|
327 |
} |
|
328 |
|
|
318 | 329 |
|
319 | 330 |
class _Argument: |
320 | 331 |
def __init__(self, min=0, max=None): # pylint: disable=W0622 |
... | ... | |
3064 | 3075 |
return constants.EXIT_SUCCESS |
3065 | 3076 |
|
3066 | 3077 |
|
3078 |
def _FieldDescValues(fdef): |
|
3079 |
"""Helper function for L{GenericListFields} to get query field description. |
|
3080 |
|
|
3081 |
@type fdef: L{objects.QueryFieldDefinition} |
|
3082 |
@rtype: list |
|
3083 |
|
|
3084 |
""" |
|
3085 |
return [ |
|
3086 |
fdef.name, |
|
3087 |
_QFT_NAMES.get(fdef.kind, fdef.kind), |
|
3088 |
fdef.title, |
|
3089 |
fdef.doc, |
|
3090 |
] |
|
3091 |
|
|
3092 |
|
|
3067 | 3093 |
def GenericListFields(resource, fields, separator, header, cl=None): |
3068 | 3094 |
"""Generic implementation for listing fields for a resource. |
3069 | 3095 |
|
... | ... | |
3088 | 3114 |
|
3089 | 3115 |
columns = [ |
3090 | 3116 |
TableColumn("Name", str, False), |
3117 |
TableColumn("Type", str, False), |
|
3091 | 3118 |
TableColumn("Title", str, False), |
3092 | 3119 |
TableColumn("Description", str, False), |
3093 | 3120 |
] |
3094 | 3121 |
|
3095 |
rows = [[fdef.name, fdef.title, fdef.doc] for fdef in response.fields]
|
|
3122 |
rows = map(_FieldDescValues, response.fields)
|
|
3096 | 3123 |
|
3097 | 3124 |
for line in FormatTable(rows, columns, header, separator): |
3098 | 3125 |
ToStdout(line) |
Also available in: Unified diff