(body, omit_len=512)
return omitted_body + appendix_str
omit too long str/bytes
omit too long str/bytes
omit too long str / bytes
def omit_long_data(body, omit_len=512):
    """ omit too long str/bytes
    """
    if not isinstance(body, (str, bytes)):
        return body

    body_len = len(body)
    if body_len <= omit_len:
        return body

    omitted_body = body[0:omit_len]

    appendix_str = f" ... OMITTED {body_len - omit_len} CHARACTORS ..."
    if isinstance(body, bytes):
        appendix_str = appendix_str.encode("utf-8")

    return omitted_body + appendix_str
def omit_long_data ( body , omit_len = 512 ) : if not isinstance ( body , ( str , bytes ) ) : return body body_len = len ( body ) if body_len <= omit_len : return body omitted_body = body [ 0 : omit_len ] appendix_str = f" ... OMITTED {body_len - omit_len} CHARACTORS ..." if isinstance ( body , bytes ) : appendix_str = appendix_str . encode ( "utf-8" ) return omitted_body + appendix_str