<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def docid(url, encoding='ascii'):
 """Get DocID from URL. DocID generation depends on bytes of the URL string. So, if non-ascii charactors in the URL, encoding should be considered properly. Args: url (str or bytes):
 Pre-encoded bytes or string will be encoded with the 'encoding' argument. encoding (str, optional):
 Defaults to 'ascii'. Used to encode url argument if it is not pre-encoded into bytes. Returns: DocID: The DocID object. Examples: 1d5920f4b44b27a8-ed646a3334ca891f-ff90821feeb2b02a33a6f9fc8e5f3fcd 1d5920f4b44b27a8-ed646a3334ca891f-ff90821feeb2b02a33a6f9fc8e5f3fcd 1d5920f4b44b27a8-ed646a3334ca891f-ff90821feeb2b02a33a6f9fc8e5f3fcd NotImplementedError: Not supported data format """


    if not isinstance(url, bytes):
        url = url.encode(encoding)

    parser = _URL_PARSER
    idx = 0
    for _c in url:
        if _c not in _HEX:
            if not (_c == _SYM_MINUS and (idx == _DOMAINID_LENGTH
                                          or idx == _HOSTID_LENGTH + 1)):
                return parser.parse(url, idx)
        idx += 1
        if idx > 4:
            break
    _l = len(url)
    if _l == _DOCID_LENGTH:
        parser = _DOCID_PARSER
    elif _l == _READABLE_DOCID_LENGTH \
            and url[_DOMAINID_LENGTH] == _SYM_MINUS \
            and url[_HOSTID_LENGTH + 1] == _SYM_MINUS:
        parser = _R_DOCID_PARSER
    else:
        parser = _PARSER

    return parser.parse(url, idx)