

def print_dict(dct, dict_property='Property', wrap=0, dict_value='Value', json_flag=False):
    'Print a `dict` as a table of two columns.\n\n    :param dct: `dict` to print\n    :param dict_property: name of the first column\n    :param wrap: wrapping for the second column\n    :param dict_value: header label for the value (second) column\n    :param json_flag: print `dict` as JSON instead of table\n    '
    if json_flag:
        print(json.dumps(dct, indent=4, separators=(',', ': ')))
        return
    pt = prettytable.PrettyTable([dict_property, dict_value])
    pt.align = 'l'
    for (k, v) in sorted(dct.items()):
        if isinstance(v, dict):
            v = six.text_type(v)
        if (wrap > 0):
            v = textwrap.fill(six.text_type(v), wrap)
        if (v and isinstance(v, six.string_types) and ('\\n' in v)):
            lines = v.strip().split('\\n')
            col1 = k
            for line in lines:
                pt.add_row([col1, line])
                col1 = ''
        else:
            pt.add_row([k, v])
    if six.PY3:
        print(encodeutils.safe_encode(pt.get_string()).decode())
    else:
        print(encodeutils.safe_encode(pt.get_string()))

dataset/ETHPy150Open openstack/python-ironicclient/ironicclient/common/cliutils.py print_dict/original