'Converts settings to a canonical representation to compare easily'

@staticmethod
def _make_canonical(ip_version, settings):

    def canonicalize_fwmark_string(fwmark_mask):
        'Reformats    fwmark/mask    in    to    a    canonical    form\n\n                                                Examples,    these    are    all    equivalent:\n                                                                "0x1"\n                                                                0x1\n                                                                "0x1/0xfffffffff"\n                                                                (0x1,    0xfffffffff)\n\n                                                :param    fwmark_mask:    The    firewall    and    mask    (default    0xffffffff)\n                                                :type    fwmark_mask:    A    string    with    /    as    delimiter,    an    iterable,    or    a\n                                                                single    value.\n                                                '
        if isinstance(fwmark_mask, six.string_types):
            iterable = fwmark_mask.split('/')
        else:
            try:
                iterable = iter(fwmark_mask)
            except TypeError:
                iterable = [fwmark_mask]
        def to_i(s):
            if isinstance(s, six.string_types):
                return int(s, 0)
            return int(s)
        integers = [to_i(x) for x in iterable]
        if (len(integers) == 1):
            integers.append(4294967295)
        return '{0:#x}/{1:#x}'.format(*integers)
    def canonicalize(item):
        (k, v) = item
        if ((k == 'from') and (v == 'all')):
            return (k, constants.IP_ANY[ip_version])
        if (k == 'lookup'):
            return ('table', v)
        if (k == 'fwmark'):
            return (k, canonicalize_fwmark_string(v))
        return (k, v)
    if ('type' not in settings):
        settings['type'] = 'unicast'
    return {k: str(v) for (k, v) in map(canonicalize, settings.items())}
