
    i                       d Z ddlmZ ddlmZmZmZmZmZ ddl	m
Z
 ddlmZ ddlmZmZ ddlmZ ddlmZmZ dd	lmZ g d
Zdej0                  eef	 	 	 	 	 	 	 	 	 	 	 ddZddej0                  eef	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)u?   Universal character encoding detector — MIT-licensed rewrite.    )annotations)_DEFAULT_CHUNK_SIZEDEFAULT_MAX_BYTESMINIMUM_THRESHOLD_validate_max_bytes_warn_deprecated_chunk_size)__version__)UniversalDetector)EncodingEraLanguageFilter)apply_legacy_rename)DetectionDictDetectionResult)run_pipeline)
r   r   r   r   r   r   r
   r	   detect
detect_allTc                    t        |       t        |       t        | t              r| n
t        |       }t	        |||      }|d   j                         }|rt        |       |S )a  Detect the encoding of the given byte string.

    Parameters match chardet 6.x for backward compatibility.
    *chunk_size* is accepted but has no effect.

    :param byte_str: The byte sequence to detect encoding for.
    :param should_rename_legacy: If ``True`` (the default), remap legacy
        encoding names to their modern equivalents.
    :param encoding_era: Restrict candidate encodings to the given era.
    :param chunk_size: Deprecated -- accepted for backward compatibility but
        has no effect.
    :param max_bytes: Maximum number of bytes to examine from *byte_str*.
    :returns: A dictionary with keys ``"encoding"``, ``"confidence"``, and
        ``"language"``.
    	max_bytesr   )r   r   
isinstancebytesr   to_dictr   )byte_strshould_rename_legacyencoding_era
chunk_sizer   dataresultsresults           `/Users/bowang/.openclaw/workspace/ChatDev/.venv/lib/python3.12/site-packages/chardet/__init__.pyr   r   !   sX    ,  
+	"!(E28hD4CGQZ!FF#M    Fc                \   t        |       t        |       t        | t              r| n
t        |       }t	        |||      }|D cg c]  }|j                          }	}|s |	D 
cg c]  }
|
d   t        kD  s|
 }}
|r|}	|r|	D ]  }
t        |
        t        |	d d      S c c}w c c}
w )ax  Detect all possible encodings of the given byte string.

    Parameters match chardet 6.x for backward compatibility.
    *chunk_size* is accepted but has no effect.

    When *ignore_threshold* is False (the default), results with confidence
    <= MINIMUM_THRESHOLD (0.20) are filtered out.  If all results are below
    the threshold, the full unfiltered list is returned as a fallback so the
    caller always receives at least one result.

    :param byte_str: The byte sequence to detect encoding for.
    :param ignore_threshold: If ``True``, return all candidate encodings
        regardless of confidence score.
    :param should_rename_legacy: If ``True`` (the default), remap legacy
        encoding names to their modern equivalents.
    :param encoding_era: Restrict candidate encodings to the given era.
    :param chunk_size: Deprecated -- accepted for backward compatibility but
        has no effect.
    :param max_bytes: Maximum number of bytes to examine from *byte_str*.
    :returns: A list of dictionaries, each with keys ``"encoding"``,
        ``"confidence"``, and ``"language"``, sorted by descending confidence.
    r   
confidencec                    | d   S )Nr#    )ds    r    <lambda>zdetect_all.<locals>.<lambda>k   s    qr!   T)keyreverse)	r   r   r   r   r   r   r   r   sorted)r   ignore_thresholdr   r   r   r   r   r   rdictsr&   filtereds               r    r   r   A   s    <  
+	"!(E28hD4CG")*'QQYY['E*$Lu!,:K(KAuLEA" %6EE +Ls   B$%B)7B)N)r   bytes | bytearrayr   boolr   r   r   intr   r1   returnr   )r   r/   r+   r0   r   r0   r   r   r   r1   r   r1   r2   zlist[DetectionDict])__doc__
__future__r   chardet._utilsr   r   r   r   r   chardet._versionr	   chardet.detectorr
   chardet.enumsr   r   chardet.equivalencesr   chardet.pipeliner   r   chardet.pipeline.orchestratorr   __all__ALLr   r   r%   r!   r    <module>r>      s    E "  ) . 5 4 ; 6  "& +)&  	
  D #!% +)&*F*F*F *F 	*F
 *F *F *Fr!   