HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/jsonlines/__pycache__/jsonlines.cpython-310.pyc
o

�h�M�@s�UdZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZddlZeejed<zddlZWney_dZYnweejed<zddlZWneyxdZYnweeee e!e"hZ#dej$�%�fZ&Gdd�dej'�Z(ee"e)e ej*fZ+e
ee"e)fge	fZ,e
e	gee"e)ffZ-eee"e	fee	fZ.eeee e"fZ/ee.e/fZ0ed	e0d
�Z1eddd
�Z2edur�ej3Z4nedur�ej3Z4nej3Z4d
e	de"fdd�Z5ej6ddd�Gdd�de7��Z8ej6dddd�Gdd�de8e9��Z:ej6ddd�Gdd�d��Z;ej6ddd�Gdd�de;��Z<ej6ddd�Gdd�de;��Z=e	d4dd �d!e+d"ed#d$ee,de<fd%d&��Z>eddddd'�d!e+d"ed(d)ee-d*eed+eed,eede=fd-d&��Z>e	d4dddddd.�d!e+d"e"d$ee,d)ee-d*eed+eed,eedee<e=ffd/d&��Z>	#d5dddddd.�d!e+d"e"d$ee,d)ee-d*eed+eed,eedee<e=ffd0d&�Z>d1ej?e	de"fd2d3�Z@dS)6z
jsonlines implementation
�N)�Any�Callable�Dict�Iterable�Iterator�List�Literal�Optional�Tuple�Type�TypeVar�Union�cast�overload�orjson�ujson�c@s$eZdZe��Ze��Ze��ZdS)�DumpsResultConversionN)�__name__�
__module__�__qualname__�enum�auto�	LeaveAsIs�
EncodeToBytes�DecodeToString�rr�F/usr/local/CyberCP/lib/python3.10/site-packages/jsonlines/jsonlines.pyr>sr�
TJSONValue)�bound�TRW�ReaderWriterBase�obj�returncC�t�)z?
    Fake ``dumps()`` function to use as a default marker.
    ��NotImplementedError)r"rrr�
default_dumpsasr'T)�auto_exc�auto_attribsc@seZdZUdZeed<dS)�Errorz
    Base error class.
    �messageN)rrr�__doc__�str�__annotations__rrrrr*hs
r*F)r(r)�initcsTeZdZUdZeeefed<eed<dedeeefdeddf�fdd�Z	�Z
S)	�InvalidLineErrora�
    Error raised when an invalid line is encountered.

    This happens when the line does not contain valid JSON, or if a
    specific data type has been requested, and the line contained a
    different data type.

    The original line itself is stored on the exception instance as the
    ``.line`` attribute, and the line number as ``.lineno``.

    This class subclasses both ``jsonlines.Error`` and the built-in
    ``ValueError``.
    �line�linenor+r#Ncs,|��|_||_t��|�d|�d��dS)Nz (line �))�rstripr1r2�super�__init__)�selfr+r1r2��	__class__rrr6�s
zInvalidLineError.__init__)rrrr,r
r-�bytesr.�intr6�
__classcell__rrr8rr0qs

.r0)r)�reprc@s�eZdZUdZejddd�Zeej	e
ej	edfed<ejddd�Z
eed<ejddd�Zeed<dd	d
�Zde
fdd�Zde
fd
d�Zdedefdd�Zdeeedeedeejddfdd�ZdS)r!zJ
    Base class with shared behaviour for both the reader and writer.
    NF��defaultr/�_fp�_closed�_should_close_fpr#cCs6|jrdSd|_|jdur|jr|j��dSdSdS)z�
        Close this reader/writer.

        This closes the underlying file if that file has been opened by
        this reader/writer. When an already opened file-like object was
        provided, the caller is responsible for closing it.
        NT)rAr@rB�close�r7rrrrC�s�zReaderWriterBase.closecCs0t|�j}|��}d|�dt|�d�d|�d�S)Nz<jsonlines.� at 0x�xz
 wrapping �>)�typer�_repr_for_wrapped�id)r7�cls_name�wrappedrrr�__repr__�s
zReaderWriterBase.__repr__cCr$�Nr%rDrrrrI��z"ReaderWriterBase._repr_for_wrappedr7cCs|SrNrrDrrr�	__enter__�rOzReaderWriterBase.__enter__�exc_type�exc_val�exc_tbcCs|��dSrN)rC)r7rQrRrSrrr�__exit__�szReaderWriterBase.__exit__�r#N)rrrr,�attr�ibr@r
�typing�IOr-r:r.rA�boolrBrCrMrIr rPr	r�
BaseException�types�
TracebackTyperTrrrrr!�s(
$�

����c@s"eZdZUdZeejeejee	eeeffe
d<ejdd�Z
eeeeeeffe
d<ejedd�Zee
d<d,dd�Zed
d
d
d�ded
dedded	efdd��Zed
d
d�ded
dedded	eefdd��Zed
d
d�deededded	efdd��Zed
d�deededded	eefdd��Zed
d
d
d�deeededed	eefdd��Zd
ddd�deeededed	eefdd�Zed
d
d
d
d�ded
deddeded	eef
dd��Zed
d
d
d �ded
deddeded	eef
d!d��Zed
d
d
d"�deededdeded	eef
d#d��Zed
d
d$�deededdeded	eeef
d%d��Zed
d
d
d
d�deeedededed	eeef
d&d��Z	
			d-deeedededed	eeef
d'd�Zd	eefd(d)�Zd	efd*d+�Z d
S).�Readera�
    Reader for the jsonlines format.

    The first argument must be an iterable that yields JSON encoded
    strings. Usually this will be a readable file-like object, such as
    an open file or an ``io.TextIO`` instance, but it can also be
    something else as long as it yields strings when iterated over.

    Instances are iterable and can be used as a context manager.

    The `loads` argument can be used to replace the standard json
    decoder. If specified, it must be a callable that accepts a
    (unicode) string and returns the decoded object.

    :param file_or_iterable: file-like object or iterable yielding lines as
        strings
    :param loads: custom json decoder callable
    �_file_or_iterableF)r/�
_line_iterT�r?�kw_only�_loadsr#NcCsBt|jtj�rtttjttjt	f|j�|_
t|jd�|_dS)N�)
�
isinstancer_�io�IOBaserr
rXrYr-r:r@�	enumerater`rDrrr�__attrs_post_init__�s�zReader.__attrs_post_init__.�rH�
allow_none�
skip_emptyrHrkrlcC�dSrNr�r7rHrkrlrrr�read��zReader.read)rHrlcCrmrNrrnrrrro�rp)rkrlcCrmrNrrnrrrro�rp)rlcCrmrNrrnrrrrorpcCrmrNrrnrrrrorpc

Csl|jrtd��|dur|tvrtd��zt|j�\}}|r.|��s.t|j�\}}|r.|��r!Wn
ty9td�wt	|t
�r_z|�d�}Wnty^}zt
d|��||�}||�d}~ww|�t�rj|dd�}z|�|�}Wnty�}zt
d|��||�}||�d}~ww|dur�|r�dSt
d||��|dur�t	||�}	|tur�t	|t�r�d	}	|	s�t
d
||��|S)a�
        Read and decode a line.

        The optional `type` argument specifies the expected data type.
        Supported types are ``dict``, ``list``, ``str``, ``int``,
        ``float``, and ``bool``. When specified, non-conforming lines
        result in :py:exc:`InvalidLineError`.

        By default, input lines containing ``null`` (in JSON) are
        considered invalid, and will cause :py:exc:`InvalidLineError`.
        The `allow_none` argument can be used to change this behaviour,
        in which case ``None`` will be returned instead.

        If `skip_empty` is set to ``True``, empty lines and lines
        containing only whitespace are silently skipped.
        zreader is closedNzinvalid type specified�utf-8zline is not valid utf-8: rdzline contains invalid json: zline contains null valueFz"line does not match requested type)rA�RuntimeError�VALID_TYPES�
ValueError�nextr`r4�
StopIteration�EOFErrorrer:�decode�UnicodeDecodeErrorr0�
startswith�SKIPPABLE_SINGLE_INITIAL_CHARSrcr;rZ)
r7rHrkrlr2r1�orig_exc�exc�value�validrrrros^���
���
���
�)rHrkrl�skip_invalidr�cCrmrNr�r7rHrkrlr�rrr�iter_�	zReader.iter)rHrlr�cCrmrNrr�rrrr�kr�)rkrlr�cCrmrNrr�rrrr�wr�)rlr�cCrmrNrr�rrrr��r�cCrmrNrr�rrrr��r�ccsL�z	z|j|||d�VWnty|s�Ynwqty%YdSw)a�
        Iterate over all lines.

        This is the iterator equivalent to repeatedly calling
        :py:meth:`~Reader.read()`. If no arguments are specified, this
        is the same as directly iterating over this :py:class:`Reader`
        instance.

        When `skip_invalid` is set to ``True``, invalid lines will be
        silently ignored.

        See :py:meth:`~Reader.read()` for a description of the other
        arguments.
        TrjN)ror0rwr�rrrr��s ������cCs|��S)z0
        See :py:meth:`~Reader.iter()`.
        )r�rDrrr�__iter__�szReader.__iter__cCs:|jdur
t|j�St|j�j}d|�dt|j�d�d�S)N�<rErFrG)r@�repr_for_fprHr_rrJ)r7�
class_namerrrrI�s

zReader._repr_for_wrappedrU)NFFF)!rrrr,r
rXrYr-r:rr.rVrWr`rr
r;�
default_loadsrc�
LoadsCallablerirrrZ�	JSONValueror	rrrr�r�rIrrrrr^�s\
 �(

�����
�����
�����
�����
�
�����
���
�I�����������������������
��
����
��
����

�!r^c@seZdZUdZejdd�Zeej	e
ej	efed<ejddd�Z
eed<ejddd	�Zeed
<ejddd	�Zeed<ejddd	�Zeed<ejedd	�Zeed
<ejejdd�Zeed<ddd�Zdedefdd�Zdeedefdd�Zde
fdd�ZdS)�Writera�
    Writer for the jsonlines format.

    Instances can be used as a context manager.

    The `fp` argument must be a file-like object with a ``.write()``
    method accepting either text (unicode) or bytes.

    The `compact` argument can be used to to produce smaller output.

    The `sort_keys` argument can be used to sort keys in json objects,
    and will produce deterministic output.

    For more control, provide a a custom encoder callable using the
    `dumps` argument. The callable must produce (unicode) string output.
    If specified, the `compact` and `sort` arguments will be ignored.

    When the `flush` argument is set to ``True``, the writer will call
    ``fp.flush()`` after each written line.

    :param fp: writable file-like object
    :param compact: whether to use a compact output format
    :param sort_keys: whether to sort object keys
    :param dumps: custom encoder callable
    :param flush: whether to flush the file-like object after writing each line
    N)r?r@Fr>�
_fp_is_binaryTra�_compact�
_sort_keys�_flush�_dumps�_dumps_result_conversionr#cCs�t|jtj�rd|_n#t|jtj�rd|_nz|j�d�Wnty*d|_Ynwd|_|jt	urCt
jd|jr;dnd|j
d�j|_|�i�}t|t�rV|jrVtj|_dSt|t�rd|jsftj|_dSdSdS)NFT�)�,�:)z, z: )�ensure_ascii�
separators�	sort_keys)rer@rf�
TextIOBaser�rg�write�	TypeErrorr�r'�json�JSONEncoderr�r��encoder-rrr�r:r)r7�sample_dumps_resultrrrri�s0
�
��
�zWriter.__attrs_post_init__r"cCs�|jrtd��|�|�}|jtjkr|��}n
|jtjkr!|��}|j	}|�
|�|�
|jr0dnd�|jr:|�
�t|�dS)z�
        Encode and write a single object.

        :param obj: the object to encode and write
        :return: number of characters or bytes written
        zwriter is closed�
�
rd)rArrr�r�rrr�rrxr@r�r�r��flush�len)r7r"r1�fprrrr�s


zWriter.write�iterablecst�fdd�|D��S)z�
        Encode and write multiple objects.

        :param iterable: an iterable of objects
        :return: number of characters or bytes written
        c3s�|]}��|�VqdSrN)r�)�.0r"rDrr�	<genexpr>1s�z#Writer.write_all.<locals>.<genexpr>)�sum)r7r�rrDr�	write_all*szWriter.write_allcCs
t|j�SrN)r�r@rDrrrrI3s
zWriter._repr_for_wrappedrU)rrrr,rVrWr@r
rXrYr-r:r.r�rZr�r�r�r'r��
DumpsCallablerrr�rirr;r�rr�rIrrrrr��s
(�
	r�.)�loads�file�mode�rr�cCrmrNr)r�r�r�rrr�open7sr�)�dumps�compactr�r�)�w�arFr�r�r�r�cCrmrNr)r�r�r�r�r�r�rrrr�As
�r�r�r�r�r�cCrmrNr)r�r�r�r�r�r�r�rrrr�NscCs�|dvrtd��|dkrtnt}|dkrdnd}tj||d|d�}	t|||||d�}
d	d
�|
��D�}
||	fi|
��}d|_|S)u�
    Open a jsonlines file for reading or writing.

    This is a convenience function to open a file and wrap it in either a
    :py:class:`Reader` or :py:class:`Writer` instance, depending on the
    specified `mode`.

    Additional keyword arguments will be passed on to the reader and writer;
    see their documentation for available options.

    The resulting reader or writer must be closed after use by the
    caller, which will also close the opened file.  This can be done by
    calling ``.close()``, but the easiest way to ensure proper resource
    finalisation is to use a ``with`` block (context manager), e.g.

    ::

        with jsonlines.open('out.jsonl', mode='w') as writer:
            writer.write(...)

    :param file: name or ‘path-like object’ of the file to open
    :param mode: whether to open the file for reading (``r``),
        writing (``w``), appending (``a``), or exclusive creation (``x``).
    >r�r�r�rFz+'mode' must be either 'r', 'w', 'a', or 'x'r�z	utf-8-sigrq�t)r��encodingr�cSsi|]\}}|dur||�qSrNr)r��keyr~rrr�
<dictcomp>�szopen.<locals>.<dictcomp>T)rtr^r��builtinsr��dict�itemsrB)r�r�r�r�r�r�r��clsr�r��kwargs�instancerrrr�\s "�r�cCs$t|dd�}|durt|�St|�S)z@
    Helper to make a useful repr() for a file-like object.
    �nameN)�getattrr=)r�r�rrrr��sr�).)r�)Ar,r��codecsrrfr��osr\rXrrrrrrrr	r
rrr
rrrV�
ModuleTyper.r�ImportErrorrrZr��floatr;�listr-rs�BOM_UTF8rxr{�Enumrr:�PathLike�Openabler�r��JSONCollection�
JSONScalarr�rr r�r�r'�s�	Exceptionr*rtr0r!r^r�r�rYr�rrrr�<module>s@����-n������	�����������������
	����������
	
�5