mercurial/utils/stringutil.py
changeset 37941 af83a0ed0afb
parent 37932 bf6bb710b40f
child 37942 32bc3815efae
equal deleted inserted replaced
37940:31c37e703cee 37941:af83a0ed0afb
    38     elif isinstance(o, dict):
    38     elif isinstance(o, dict):
    39         return '{%s}' % (b', '.join(
    39         return '{%s}' % (b', '.join(
    40             '%s: %s' % (pprint(k, bprefix=bprefix),
    40             '%s: %s' % (pprint(k, bprefix=bprefix),
    41                         pprint(v, bprefix=bprefix))
    41                         pprint(v, bprefix=bprefix))
    42             for k, v in sorted(o.items())))
    42             for k, v in sorted(o.items())))
    43     elif isinstance(o, bool):
       
    44         return b'True' if o else b'False'
       
    45     elif isinstance(o, int):
       
    46         return '%d' % o
       
    47     elif isinstance(o, float):
       
    48         return '%f' % o
       
    49     elif isinstance(o, tuple):
    43     elif isinstance(o, tuple):
    50         return '(%s)' % (b', '.join(pprint(a, bprefix=bprefix) for a in o))
    44         return '(%s)' % (b', '.join(pprint(a, bprefix=bprefix) for a in o))
    51     elif o is None:
       
    52         return b'None'
       
    53     else:
    45     else:
    54         raise error.ProgrammingError('do not know how to format %r' % o)
    46         return pycompat.byterepr(o)
    55 
    47 
    56 def binary(s):
    48 def binary(s):
    57     """return true if a string is binary data"""
    49     """return true if a string is binary data"""
    58     return bool(s and '\0' in s)
    50     return bool(s and '\0' in s)
    59 
    51