+
+ def _friendly_format(val):
+ if not isinstance(val, str):
+ return val
+ if len(val) == 6:
+ return '{!s} ({!s})'.format(val, ':'.join(['{:02x}'.format(
+ ord(x)) for x in val]))
+ try:
+ return '{!s} ({!s})'.format(val, str(
+ ipaddress.ip_address(val)))
+ except ipaddress.AddressValueError:
+ return val
+
+ _args = ', '.join("{!s}={!r}".format(key, _friendly_format(val)) for
+ (key, val) in api_args.items())