def int_to_hex(int_value, delimiter=":"):
    """Convert an integer to a prettily formated hex string: for example,
    1234 (0x4d2) becomes 04:d2 and -1234 becomes ' -:04:d2'
    Args:
        int_value: the value to convert.
    Returns:
        the formatted hex string."""
    hex_string = "%x" % int_value
    ret = ""
    pos = 0
    # Accommodate for negative integers.
    if hex_string[0] == "-":
        ret += " -" + delimiter
        hex_string = hex_string[1:]
    # If the first digit is a half-byte, pad with a 0.
    remaining_len = len(hex_string) - pos
    hex_string = hex_string.zfill(remaining_len + remaining_len % 2)
    byte_values = [hex_string[i: i + 2] for i in range(pos, len(hex_string), 2)]
    return ret + delimiter.join(byte_values)