Revision 9ec1bcbd lib/cli.py
b/lib/cli.py | ||
---|---|---|
4174 | 4174 |
return ipolicy_out |
4175 | 4175 |
|
4176 | 4176 |
|
4177 |
def _NotAContainer(data): |
|
4178 |
""" Checks whether the input is not a container data type. |
|
4179 |
|
|
4180 |
@rtype: bool |
|
4181 |
|
|
4182 |
""" |
|
4183 |
return not (isinstance(data, (list, dict, tuple))) |
|
4184 |
|
|
4185 |
|
|
4177 | 4186 |
def _SerializeGenericInfo(buf, data, level, afterkey=False): |
4178 | 4187 |
"""Formatting core of L{PrintGenericInfo}. |
4179 | 4188 |
|
... | ... | |
4219 | 4228 |
buf.write(key) |
4220 | 4229 |
buf.write(": ") |
4221 | 4230 |
_SerializeGenericInfo(buf, val, level + 1, afterkey=True) |
4222 |
elif isinstance(data, list): |
|
4231 |
elif isinstance(data, tuple) and all(map(_NotAContainer, data)): |
|
4232 |
# tuples with simple content are serialized as inline lists |
|
4233 |
buf.write("[%s]\n" % utils.CommaJoin(data)) |
|
4234 |
elif isinstance(data, list) or isinstance(data, tuple): |
|
4235 |
# lists and tuples |
|
4223 | 4236 |
if not data: |
4224 | 4237 |
buf.write("\n") |
4225 | 4238 |
else: |
Also available in: Unified diff