AlkantarClanX12

Your IP : 13.58.38.184


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/coverage/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/coverage/__pycache__/sqldata.cpython-311.pyc

�

�܋f_�����dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!ddl"m#Z#m$Z$m%Z%ddl&m'Z'm(Z(ddl)m*Z*ddl+m,Z,m-Z-dd	l.m/Z/m0Z0m1Z1dd
l2m3Z3m4Z4m5Z5m6Z6m7Z7ddl8m9Z9e-e	��Z	dZ:d
Z;e dedef���Z<dd�Z=Gd�de$��Z>dd�Z?Gd�de$��Z@dS)zSQLite coverage data.�)�annotationsN)�cast�Any�Callable�
Collection�Dict�Iterable�Iterator�List�Mapping�Optional�Sequence�Set�Tuple�TypeVar�Union)�NoDebugging�
AutoReprMixin�clipped_repr)�CoverageException�	DataError)�PathAliases)�file_be_gone�isolate_module)�numbits_to_nums�
numbits_union�nums_to_numbits)�FilePath�TArc�	TDebugCtl�TLineNo�TWarnFn)�__version__�a�CREATE TABLE coverage_schema (
    -- One row, to record the version of the schema in this db.
    version integer
);

CREATE TABLE meta (
    -- Key-value pairs, to record metadata about the data
    key text,
    value text,
    unique (key)
    -- Possible keys:
    --  'has_arcs' boolean      -- Is this data recording branches?
    --  'sys_argv' text         -- The coverage command line that recorded the data.
    --  'version' text          -- The version of coverage.py that made the file.
    --  'when' text             -- Datetime when the file was created.
);

CREATE TABLE file (
    -- A row per file measured.
    id integer primary key,
    path text,
    unique (path)
);

CREATE TABLE context (
    -- A row per context measured.
    id integer primary key,
    context text,
    unique (context)
);

CREATE TABLE line_bits (
    -- If recording lines, a row per context per file executed.
    -- All of the line numbers for that file/context are in one numbits.
    file_id integer,            -- foreign key to `file`.
    context_id integer,         -- foreign key to `context`.
    numbits blob,               -- see the numbits functions in coverage.numbits
    foreign key (file_id) references file (id),
    foreign key (context_id) references context (id),
    unique (file_id, context_id)
);

CREATE TABLE arc (
    -- If recording branches, a row per context per from/to line transition executed.
    file_id integer,            -- foreign key to `file`.
    context_id integer,         -- foreign key to `context`.
    fromno integer,             -- line number jumped from.
    tono integer,               -- line number jumped to.
    foreign key (file_id) references file (id),
    foreign key (context_id) references context (id),
    unique (file_id, context_id, fromno, tono)
);

CREATE TABLE tracer (
    -- A row per file indicating the tracer used for that file.
    file_id integer primary key,
    tracer text,
    foreign key (file_id) references file (id)
);
�TMethod.)�bound�method�returnc�H��tj���d�fd���}|S)	z4A decorator for methods that should hold self._lock.�self�CoverageData�argsr�kwargsr(c�n��|j�d��r*|j�d|j�d�j����|j5|j�d��r*|j�d|j�d�j�����|g|�Ri|��cddd��S#1swxYwYdS)N�lockzLocking z for zLocked  )�_debug�should�write�_lock�__name__)r*r,r-r's   ��c/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/coverage/sqldata.py�_wrappedz_locked.<locals>._wrappedws����;���f�%�%�	O��K���M���M�M�F�O�M�M�N�N�N�
�Z�	1�	1��{�!�!�&�)�)�
S���!�!�"Q�T�Z�"Q�"Q���"Q�"Q�R�R�R��6�$�0��0�0�0��0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s�
AB*�*B.�1B.)r*r+r,rr-rr(r)�	functools�wraps)r'r6s` r5�_lockedr9us=����_�V���1�1�1�1�1���1��O�c��eZdZdZ					dWdXd�ZdYd�ZdYd�ZdYd�ZdYd�ZdZd�Z	d[d�Z
d\d�Zd]d�Zd^d�Z
d_d`d"�Zdad$�Zedbd&���ZdYd'�Zdcd(�Zdcd)�Zeddd,���Zeded/���Zdfdgd2�Zedhd5���Zdidjd8�Zdkdld;�Zdmd<�Zdkdnd@�Zd_dodB�ZdYdC�ZdYdD�ZdYdE�Z d\dF�Z!dpdH�Z"dpdI�Z#dqdJ�Z$drdK�Z%dsdN�Z&dtdP�Z'dudR�Z(dvdT�Z)e*dwdV���Z+dS)xr+a}Manages collected coverage data, including file storage.

    This class is the public supported API to the data that coverage.py
    collects during program execution.  It includes information about what code
    was executed. It does not include information from the analysis phase, to
    determine what lines could have been executed, or what lines were not
    executed.

    .. note::

        The data file is currently a SQLite database file, with a
        :ref:`documented schema <dbschema>`. The schema is subject to change
        though, so be careful about querying it directly. Use this API if you
        can to isolate yourself from changes.

    There are a number of kinds of data that can be collected:

    * **lines**: the line numbers of source lines that were executed.
      These are always available.

    * **arcs**: pairs of source and destination line numbers for transitions
      between source lines.  These are only available if branch coverage was
      used.

    * **file tracer names**: the module names of the file tracer plugins that
      handled each file in the data.

    Lines, arcs, and file tracer names are stored for each source file. File
    names in this API are case-sensitive, even on platforms with
    case-insensitive file systems.

    A data file either stores lines, or arcs, but not both.

    A data file is associated with the data when the :class:`CoverageData`
    is created, using the parameters `basename`, `suffix`, and `no_disk`. The
    base name can be queried with :meth:`base_filename`, and the actual file
    name being used is available from :meth:`data_filename`.

    To read an existing coverage.py data file, use :meth:`read`.  You can then
    access the line, arc, or file tracer data with :meth:`lines`, :meth:`arcs`,
    or :meth:`file_tracer`.

    The :meth:`has_arcs` method indicates whether arc data is available.  You
    can get a set of the files in the data with :meth:`measured_files`.  As
    with most Python containers, you can determine if there is any data at all
    by using this object as a boolean value.

    The contexts for each line in a file can be read with
    :meth:`contexts_by_lineno`.

    To limit querying to certain contexts, use :meth:`set_query_context` or
    :meth:`set_query_contexts`. These will narrow the focus of subsequent
    :meth:`lines`, :meth:`arcs`, and :meth:`contexts_by_lineno` calls. The set
    of all measured context names can be retrieved with
    :meth:`measured_contexts`.

    Most data files will be created by coverage.py itself, but you can use
    methods here to create data files if you like.  The :meth:`add_lines`,
    :meth:`add_arcs`, and :meth:`add_file_tracers` methods add data, in ways
    that are convenient for coverage.py.

    To record data for contexts, use :meth:`set_context` to set a context to
    be used for subsequent :meth:`add_lines` and :meth:`add_arcs` calls.

    To add a source file without any measured data, use :meth:`touch_file`,
    or :meth:`touch_files` for a list of such files.

    Write the data to its file with :meth:`write`.

    You can clear the data in memory with :meth:`erase`.  Data for specific
    files can be removed from the database with :meth:`purge_files`.

    Two data collections can be combined by using :meth:`update` on one
    :class:`CoverageData`, passing it the other.

    Data in a :class:`CoverageData` can be serialized and deserialized with
    :meth:`dumps` and :meth:`loads`.

    The methods used during the coverage.py collection phase
    (:meth:`add_lines`, :meth:`add_arcs`, :meth:`set_context`, and
    :meth:`add_file_tracers`) are thread-safe.  Other methods may not be.

    NF�basename�Optional[FilePath]�suffix�Optional[Union[str, bool]]�no_disk�bool�warn�Optional[TWarnFn]�debug�Optional[TDebugCtl]r(�Nonec��||_tj�|pd��|_||_||_|p
t��|_|�	��i|_
i|_tj��|_
tj��|_d|_d|_d|_d|_d|_d|_dS)a�Create a :class:`CoverageData` object to hold coverage-measured data.

        Arguments:
            basename (str): the base name of the data file, defaulting to
                ".coverage". This can be a path to a file in another directory.
            suffix (str or bool): has the same meaning as the `data_suffix`
                argument to :class:`coverage.Coverage`.
            no_disk (bool): if True, keep all data in memory, and don't
                write any disk file.
            warn: a warning callback function, accepting a warning message
                argument.
            debug: a `DebugControl` object (optional)

        z	.coverageFN)�_no_disk�os�path�abspath�	_basename�_suffix�_warnrr0�_choose_filename�	_file_map�_dbs�getpid�_pid�	threading�RLockr3�
_have_used�
_has_lines�	_has_arcs�_current_context�_current_context_id�_query_context_ids)r*r<r>r@rBrDs      r5�__init__zCoverageData.__init__�s���, ��
������)@�[�A�A��������
��,�{�}�}���������)+���)+��	��I�K�K��	��_�&�&��
� ���������/3���26�� �7;����r:c��|jr	d|_dS|j|_t|j��}|r|xjd|zz
c_dSdS)z.Set self._filename based on inited attributes.�:memory:�.N)rH�	_filenamerL�filename_suffixrM)r*r>s  r5rOzCoverageData._choose_filenamesY���=�	/�'�D�N�N�N�!�^�D�N�$�T�\�2�2�F��
/����#��,�.�����
/�
/r:c��|js7|j���D]}|����i|_i|_d|_d|_dS)zReset our attributes.FN)rHrQ�values�closerPrVrZ)r*�dbs  r5�_resetzCoverageData._resets[���}�	��i�&�&�(�(�
�
�����
�
�
�
��D�I�������#'�� � � r:c��|j�d��r"|j�d|j����t	|j|j��|jt
j��<|���dS)z0Open an existing db file, and read its metadata.�dataiozOpening data file N)	r0r1r2r`�SqliteDbrQrT�	get_ident�_read_db�r*s r5�_open_dbzCoverageData._open_dbsp���;���h�'�'�	G��K���E�4�>�E�E�F�F�F�+3�D�N�D�K�+P�+P��	�)�%�'�'�(��
�
�����r:c��|jtj��5}	|�d��}|�J�	|d}|tkr.td�|j|t�����ng#t$rZ}dt|��vr|�
|��n)td�|j|����|�Yd}~nd}~wwxYw|�d��}|�4tt|d����|_
|j
|_|�d��5}|D]\}}||j|<�	ddd��n#1swxYwYddd��dS#1swxYwYdS)	zARead the metadata from a database so that we are ready to use it.z#select version from coverage_schemaNrz;Couldn't use data file {!r}: wrong schema: {} instead of {}zno such table: coverage_schemaz:Data file {!r} doesn't seem to be a coverage data file: {}z-select value from meta where key = 'has_arcs'�select id, path from file)rQrTrj�execute_one�SCHEMA_VERSIONr�formatr`�	Exception�str�_init_dbrA�intrXrW�executerP)r*re�row�schema_version�exc�cur�file_idrJs        r5rkzCoverageData._read_db!s7��
�Y�y�*�,�,�
-�	3��
��n�n�%J�K�K�������"%�Q���!�^�3�3�#�U�\�\� �N�N�N������4���
�
�
�3�s�3�x�x�?�?��M�M�"�%�%�%�%�#�T�[�[� �N�C������	�&�%�%�%�%�����
����$�.�.�!P�Q�Q�C���!%�c�#�a�&�k�k�!2�!2���&*�n�"4������7�8�8�
3�C�%(�3�3�M�G�T�+2�D�N�4�(�(�3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�7	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3s`�E<�A=�AE<�=
C!�AC�E<�C!�!A#E<�E$�E<�$E(	�(E<�+E(	�,E<�<F�Freric
�4�|j�d��r"|j�d|j����|�t
��|�dtf��dtfg}|j�d��rk|�	dtttdd����fd	tj
����d
��fg��|�d|��dS)z+Write the initial contents of the database.rhzIniting data file z0insert into coverage_schema (version) values (?)�version�process�sys_argv�argvN�whenz%Y-%m-%d %H:%M:%S�5insert or ignore into meta (key, value) values (?, ?))r0r1r2r`�
executescript�SCHEMA�execute_voidrqr#�extendrt�getattr�sys�datetime�now�strftime�executemany_void)r*re�	meta_datas   r5ruzCoverageData._init_dbBs���;���h�'�'�	G��K���E�4�>�E�E�F�F�F�
���� � � �
���J�^�L]�^�^�^�
��$�
�	��;���i�(�(�	�����S���f�d�!;�!;�<�<�=���*�.�.�0�0�9�9�:M�N�N�O��
�
�
�	���S�U^�_�_�_�_�_r:c��tj��|jvr|���|jtj��S)zGet the SqliteDb object to use.)rTrjrQrmrls r5�_connectzCoverageData._connectUs;���� � ��	�1�1��M�M�O�O�O��y��,�.�.�/�/r:c��tj��|jvr&tj�|j��sdS	|���5}|�d��5}tt|����cddd��cddd��S#1swxYwY	ddd��dS#1swxYwYdS#t$rYdSwxYw)NFzselect * from file limit 1)rTrjrQrIrJ�existsr`r�rwrA�listr)r*�conr{s   r5�__bool__zCoverageData.__bool__[sk����!�!���2�2�2�7�>�>�$�.�;Y�;Y�2��5�	������
+�C��[�[�!=�>�>�+�#���S�	�	�?�?�+�+�+�+�+�+�+�
+�
+�
+�
+�
+�
+�
+�
+�+�+�+�+����+�+�+�+�+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+����
+�
+�
+�
+�
+�
+��!�	�	�	��5�5�	���s`�C�B:�,B!�B:�C�!B%	�%B:�(B%	�)B:�-C�:B>�>C�B>�C�
C�C�bytesc�R�|j�d��r"|j�d|j����|���5}|���}dt
j|�d����zcddd��S#1swxYwYdS)aSerialize the current data to a byte string.

        The format of the serialized data is not documented. It is only
        suitable for use with :meth:`loads` in the same version of
        coverage.py.

        Note that this serialization is not what gets stored in coverage data
        files.  This method is meant to produce bytes that can be transmitted
        elsewhere and then deserialized with :meth:`loads`.

        Returns:
            A byte string of serialized data.

        .. versionadded:: 5.0

        rhzDumping data from data file �z�utf-8N)	r0r1r2r`r��dump�zlib�compress�encode)r*r��scripts   r5�dumpszCoverageData.dumpses���"�;���h�'�'�	Q��K���O�T�^�O�O�P�P�P�
�]�]�_�_�	@���X�X�Z�Z�F��$�-��
�
�g�(>�(>�?�?�?�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�	@�	@s�>B�B �#B �datac�L�|j�d��r"|j�d|j����|dd�dkr+t	d|dd��dt|���d	����t
j|dd����d
��}t|j|j��x|j
tj��<}|5|�
|��ddd��n#1swxYwY|���d|_dS)a�Deserialize data from :meth:`dumps`.

        Use with a newly-created empty :class:`CoverageData` object.  It's
        undefined what happens if the object already has data in it.

        Note that this is not for reading data from a coverage data file.  It
        is only for use on data you produced with :meth:`dumps`.

        Arguments:
            data: A byte string of serialized data produced by :meth:`dumps`.

        .. versionadded:: 5.0

        rhzLoading data into data file N�r�zUnrecognized serialization: �(z
 (head of z bytes)r�T)r0r1r2r`r�lenr��
decompress�decoderirQrTrjr�rkrV)r*r�r�res    r5�loadszCoverageData.loads|s]���;���h�'�'�	Q��K���O�T�^�O�O�P�P�P�����8�t����X�t�C�R�C�y�X�X�c�$�i�i�X�X�X���
����a�b�b��*�*�1�1�'�:�:��08�����0U�0U�U��	�)�%�'�'�(�2�
�	%�	%����V�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%��
�
��������s�C>�>D�D�filenamert�add�
Optional[int]c���||jvrM|rK|���5}|�d|f��|j|<ddd��n#1swxYwY|j�|��S)z�Get the file id for `filename`.

        If filename is not in the database yet, add it if `add` is True.
        If `add` is not True, return None.
        z-insert or replace into file (path) values (?)N)rPr��execute_for_rowid�get)r*r�r�r�s    r5�_file_idzCoverageData._file_id�s����4�>�)�)��
��]�]�_�_���/2�/D�/D�G�!��0�0�D�N�8�,�������������������
�~�!�!�(�+�+�+s� A�A�A�contextc��|�J�|���|���5}|�d|f��}|�'tt|d��cddd��S	ddd��dS#1swxYwYdS)zGet the id for a context.N�(select id from context where context = ?r)�_start_usingr�rprrv)r*r�r�rxs    r5�_context_idzCoverageData._context_id�s����"�"�"�������
�]�]�_�_�	���/�/�"L�w�j�Y�Y�C����C��Q��(�(�	�	�	�	�	�	�	�	�
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�4A<�.A<�<B�B�
Optional[str]c��|j�d��r|j�d|����||_d|_dS)z�Set the current context for future :meth:`add_lines` etc.

        `context` is a str, the name of the context to use for the next data
        additions.  The context persists until the next :meth:`set_context`.

        .. versionadded:: 5.0

        �dataopzSetting context: N)r0r1r2rYrZ)r*r�s  r5�set_contextzCoverageData.set_context�sQ���;���h�'�'�	?��K���=�'�=�=�>�>�>� '���#'�� � � r:c���|jpd}|�|��}|�	||_dS|���5}|�d|f��|_ddd��dS#1swxYwYdS)z4Use the _current_context to set _current_context_id.�Nz(insert into context (context) values (?))rYr�rZr�r�)r*r��
context_idr�s    r5�_set_context_idzCoverageData._set_context_id�s����'�-�2���%�%�g�.�.�
��!�'1�D�$�$�$������
�C�+.�+@�+@�>��J�,�,��(�
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
s�A(�(A,�/A,c��|jS)zLThe base filename for storing data.

        .. versionadded:: 5.0

        )rLrls r5�
base_filenamezCoverageData.base_filename�����~�r:c��|jS)zBWhere is the data stored?

        .. versionadded:: 5.0

        )r`rls r5�
data_filenamezCoverageData.data_filename�r�r:�	line_data�!Mapping[str, Collection[TLineNo]]c	�H�|j�d��rU|j�dt|��t	d�|���D����fz��|���|�d���|sdS|���5}|�	��|�
��D]�\}}t|��}|�|d���}d}|�
|||jf��5}t|��}	ddd��n#1swxYwY|	rt!||	d	d	��}|�d
||j|f����	ddd��dS#1swxYwYdS)z�Add measured line data.

        `line_data` is a dictionary mapping file names to iterables of ints::

            { filename: { line1, line2, ... }, ...}

        r�z&Adding lines: %d files, %d lines totalc3�NK�|] }tt|����V��!dS�N)rAr�)�.0�liness  r5�	<genexpr>z)CoverageData.add_lines.<locals>.<genexpr>�s0����#U�#U��D��U���$4�$4�#U�#U�#U�#U�#U�#Ur:T�r�N�r�zBselect numbits from line_bits where file_id = ? and context_id = ?rzQinsert or replace into line_bits  (file_id, context_id, numbits) values (?, ?, ?))r0r1r2r��sumrcr��_choose_lines_or_arcsr�r��itemsrr�rwrZr�rr�)
r*r�r�r��linenos�linemapr|�queryr{�existings
          r5�	add_lineszCoverageData.add_lines�s?���;���h�'�'�	��K���F��I����#U�#U�)�BR�BR�BT�BT�#U�#U�#U� U� U�J��
�
�
�	
�������"�"��"�.�.�.��	��F�
�]�]�_�_�	��� � �"�"�"�%.�_�_�%6�%6�

�

�!��'�)�'�2�2���-�-��d�-�;�;��\���[�[���$�2J�(K�L�L�)�PS�#�C�y�y�H�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)��E�+�G�X�a�[��^�D�D�G�� � �G��d�6��@�����

�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s8�2A3F�%E�5F�E�F�E�	AF�F�F�arc_data�Mapping[str, Collection[TArc]]c	�z����j�d��rU�j�dt|��t	d�|���D����fz��������d���|sdS����5}��	��|�
��D]D\}}|s���|d������fd�|D��}|�d	|���E	ddd��dS#1swxYwYdS)
z�Add measured arc data.

        `arc_data` is a dictionary mapping file names to iterables of pairs of
        ints::

            { filename: { (l1,l2), (l1,l2), ... }, ...}

        r�z$Adding arcs: %d files, %d arcs totalc3�4K�|]}t|��V��dSr�)r�)r��arcss  r5r�z(CoverageData.add_arcs.<locals>.<genexpr>s(����"K�"K��3�t�9�9�"K�"K�"K�"K�"K�"Kr:T�r�Nr�c�,��g|]\}}��j||f��S�)rZ)r��fromno�tonor|r*s   ��r5�
<listcomp>z)CoverageData.add_arcs.<locals>.<listcomp>s*���c�c�c�l�f�VZ��$�":�F�D�I�c�c�cr:�Qinsert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?))
r0r1r2r�r�rcr�r�r�r�r�r�r�)r*r�r�r�r�r�r|s`     @r5�add_arcszCoverageData.add_arcss������;���h�'�'�	��K���D��H�
�
�s�"K�"K����9J�9J�"K�"K�"K�K�K�H��
�
�
�	
�������"�"��"�-�-�-��	��F�
�]�]�_�_�	��� � �"�"�"�"*�.�.�"2�"2�	
�	
���$�����-�-��d�-�;�;��c�c�c�c�c�^b�c�c�c���$�$�N������	
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�4A.D0�0D4�7D4r�r�c
�L�|s|sJ�|r|rJ�|rJ|jrC|j�d��r|j�d��t	d���|rJ|jrC|j�d��r|j�d��t	d���|jsv|jsq||_||_|���5}|�ddtt|����f��ddd��dS#1swxYwYdSdSdS)	z5Force the data file to choose between lines and arcs.r�z:Error: Can't add line measurements to existing branch dataz3Can't add line measurements to existing branch dataz:Error: Can't add branch measurements to existing line dataz3Can't add branch measurements to existing line datar��has_arcsN)
rXr0r1r2rrWr�r�rtrv)r*r�r�r�s    r5r�z"CoverageData._choose_lines_or_arcss��������}��#�d�#�#�#��	S�T�^�	S��{�!�!�(�+�+�
`���!�!�"^�_�_�_��Q�R�R�R��	S�D�O�	S��{�!�!�(�+�+�
`���!�!�"^�_�_�_��Q�R�R�R��~�	�d�o�	�#�D�O�!�D�N������
�C�� � �K���S��Y�Y���0����
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
�	�	�	�	s�3D�D�D�file_tracers�Mapping[str, str]c	�6�|j�d��r+|j�dt|��fz��|sdS|���|���5}|���D]x\}}|�|d���}|�|��}|r+||kr$td�
|||������^|r|�d||f���y	ddd��dS#1swxYwYdS)zdAdd per-file plugin information.

        `file_tracers` is { filename: plugin_name, ... }

        r�zAdding file tracers: %d filesNTr��3Conflicting file tracer name for '{}': {!r} vs {!r}z2insert into tracer (file_id, tracer) values (?, ?))r0r1r2r�r�r�r�r��file_tracerrrrr�)r*r�r�r��plugin_namer|�existing_plugins       r5�add_file_tracerszCoverageData.add_file_tracers4s����;���h�'�'�	V��K���=��\�AR�AR�@T�T�U�U�U��	��F�������
�]�]�_�_�	��)5�);�);�)=�)=�
�
�%��+��-�-��d�-�;�;��"&�"2�"2�8�"<�"<��"��&�+�5�5�'�Q�X�X� (�/�;������6�!���$�$�L� �+�.�����
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�2BD�D�Dr�r�c�4�|�|g|��dS)z�Ensure that `filename` appears in the data, empty if needed.

        `plugin_name` is the name of the plugin responsible for this file.
        It is used to associate the right filereporter, etc.
        N)�touch_files)r*r�r�s   r5�
touch_filezCoverageData.touch_fileQs"��	
���(��[�1�1�1�1�1r:�	filenames�Collection[str]c��|j�d��r|j�d|����|���|���5|js|jstd���|D]2}|�|d���|r|�	||i���3	ddd��dS#1swxYwYdS)z�Ensure that `filenames` appear in the data, empty if needed.

        `plugin_name` is the name of the plugin responsible for these files.
        It is used to associate the right filereporter, etc.
        r�z	Touching z*Can't touch files in an empty CoverageDataTr�N)
r0r1r2r�r�rXrWrr�r�)r*r�r�r�s    r5r�zCoverageData.touch_filesYsG���;���h�'�'�	9��K���7�)�7�7�8�8�8�������
�]�]�_�_�	C�	C��>�
N�$�/�
N�� L�M�M�M�%�
C�
C���
�
�h�D�
�1�1�1��C��)�)�8�[�*A�B�B�B��	
C�		C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C����	C�	C�	C�	C�	C�	Cs� AC�C�Cc��|j�d��r|j�d|����|���|���5}|jrd}n|jrd}ntd���|D]3}|�|d���}|��|�	||f���4	ddd��dS#1swxYwYdS)	zdPurge any existing coverage data for the given `filenames`.

        .. versionadded:: 7.2

        r�zPurging data for z%delete from line_bits where file_id=?zdelete from arc where file_id=?z*Can't purge files in an empty CoverageDataFr�N)
r0r1r2r�r�rWrXrr�r�)r*r�r��sqlr�r|s      r5�purge_fileszCoverageData.purge_filesls<���;���h�'�'�	A��K���?�)�?�?�@�@�@�������
�]�]�_�_�
	2����
N�=�����
N�7���� L�M�M�M�%�
2�
2���-�-��e�-�<�<���?��� � ��w�j�1�1�1�1�	
2�
	2�
	2�
	2�
	2�
	2�
	2�
	2�
	2�
	2�
	2�
	2�
	2����
	2�
	2�
	2�
	2�
	2�
	2s� AC�C�C�
other_data�aliases�Optional[PathAliases]c	������|j�d��r<|j�d�t	|dd������|jr|jrtd���|jr|jrtd����p
t���|�	��|�
��|���5}|�d��5}�fd�|D���d	d	d	��n#1swxYwY|�d
��5}d�|D��}d	d	d	��n#1swxYwY|�d��5}�fd
�|D��}d	d	d	��n#1swxYwY|�d��5}i}|D]/\}}	}
�||	f}||vrt|||
��}
|
||<�0	d	d	d	��n#1swxYwY|�d��5}�fd�|D��}d	d	d	��n#1swxYwYd	d	d	��n#1swxYwY|���5}|j�J�d|j_|�d��5}d�|D��}
d	d	d	��n#1swxYwY|�d��5}|
��fd�|D����d	d	d	��n#1swxYwY|�dd�����D����|�d��5}d�|D���d	d	d	��n#1swxYwY|j����|�dd�|D����|�d��5}d�|D���d	d	d	��n#1swxYwYi}����D]^}|
�|��}|�|d��}|�*||kr$td�|||�����|||<�_��fd�|D��}|�d��5}|D]<\}}	}
��|��|	f}||vrt|||
��}
|
||<�=	d	d	d	��n#1swxYwY|r,|�d� ��|�d!|��|r`|�d�"��|�d#��|�d$��fd%�|���D����|�d&�fd'�|���D����d	d	d	��n#1swxYwY|js*|���|�
��d	Sd	S)(a*Update this data with data from several other :class:`CoverageData` instances.

        If `aliases` is provided, it's a `PathAliases` object that is used to
        re-map paths to match the local machine's.  Note: `aliases` is None
        only when called directly from the test suite.

        r�zUpdating with data from {!r}r`z???z%Can't combine arc data with line dataz%Can't combine line data with arc datazselect path from filec�@��i|]\}|��|����Sr���map)r�rJr�s  �r5�
<dictcomp>z'CoverageData.update.<locals>.<dictcomp>�s)���D�D�D�W�d��w�{�{�4�0�0�D�D�Dr:Nzselect context from contextc��g|]\}|��Sr�r��r�r�s  r5r�z'CoverageData.update.<locals>.<listcomp>�s��:�:�:�
��G�:�:�:r:z�select file.path, context.context, arc.fromno, arc.tono from arc inner join file on file.id = arc.file_id inner join context on context.id = arc.context_idc�2��g|]\}}}}�||||f��Sr�r�)r�rJr�r�r��filess     �r5r�z'CoverageData.update.<locals>.<listcomp>�s>������5��w����4�[�'�6�4�8���r:z�select file.path, context.context, line_bits.numbits from line_bits inner join file on file.id = line_bits.file_id inner join context on context.id = line_bits.context_idzPselect file.path, tracer from tracer inner join file on file.id = tracer.file_idc�(��i|]\}}�||��Sr�r�)r�rJ�tracerr�s   �r5r�z'CoverageData.update.<locals>.<dictcomp>�s#���I�I�I�>�D�&�5��;��I�I�Ir:�	IMMEDIATEc��i|]\}|d��S�r�r�)r�rJs  r5r�z'CoverageData.update.<locals>.<dictcomp>�s��:�:�:�U�T��b�:�:�:r:c�B��i|]\}}��|��|��Sr�r�)r�rJrr�s   �r5r�z'CoverageData.update.<locals>.<dictcomp>�s;���%�%�%�$��f��K�K��%�%�v�%�%�%r:z,insert or ignore into file (path) values (?)c3�K�|]}|fV��dSr�r�)r��files  r5r�z&CoverageData.update.<locals>.<genexpr>�s$����4�4�T�$��4�4�4�4�4�4r:roc��i|]\}}||��	Sr�r�)r��idrJs   r5r�z'CoverageData.update.<locals>.<dictcomp>�s��9�9�9���T�D�"�9�9�9r:z2insert or ignore into context (context) values (?)c3�K�|]}|fV��dSr�r�r�s  r5r�z&CoverageData.update.<locals>.<genexpr>�s$����4�4��'��4�4�4�4�4�4r:zselect id, context from contextc��i|]\}}||��	Sr�r�)r�rr�s   r5r�z'CoverageData.update.<locals>.<dictcomp>�s��B�B�B�{�r�7�w��B�B�Br:r�r�c3�F�K�|]\}}}}�|�|||fV��dSr�r�)r�rr�r�r��context_ids�file_idss     ��r5r�z&CoverageData.update.<locals>.<genexpr>�sQ�������/�D�'�6�4��$���W�!5�v�t�D������r:Tr�r�r�zdelete from line_bitszEinsert into line_bits (file_id, context_id, numbits) values (?, ?, ?)c�>��g|]\\}}}�|�||f��Sr�r�)r�rr��numbitsrr
s    ��r5r�z'CoverageData.update.<locals>.<listcomp>sA������4�O�T�7�W�"�$���W�)=�w�G���r:z<insert or ignore into tracer (file_id, tracer) values (?, ?)c3�2�K�|]\}}�||fV��dSr�r�)r�r�rr
s   �r5r�z&CoverageData.update.<locals>.<genexpr>%s2�����Y�Y�2B�(�F�(�8�$�f�-�Y�Y�Y�Y�Y�Yr:)r0r1r2rrr�rWrXrrr��readr�rwrr��isolation_level�updater�rcrPr�r�r�r�r�rHrf)r*r�r�r�r{�contextsr�r�rJr�r�key�tracers�this_tracers�
tracer_map�this_tracer�other_tracer�arc_rowsrr
r�s  `               @@@r5rzCoverageData.update�sD
�������;���h�'�'�	��K���<�C�C��
�K��7�7���
�
�
��?�	E�z�3�	E��C�D�D�D��>�	E�j�3�	E��C�D�D�D��*�[�]�]��	
������	������
�
 �
 �
"�
"�)	J�c����4�5�5�
E��D�D�D�D��D�D�D��
E�
E�
E�
E�
E�
E�
E�
E�
E�
E�
E����
E�
E�
E�
E����:�;�;�
;�s�:�:�c�:�:�:��
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;����D���	
�
�����9<�����
	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
����	
�	
�	
�	
����J���
)�
�68��.1�)�)�*�D�'�7� ��;��0�C��e�|�|�"/��c�
�G�"D�"D��!(�E�#�J�J�	)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)����
)�
)�
)�
)����>���
J��I�I�I�I�S�I�I�I��
J�
J�
J�
J�
J�
J�
J�
J�
J�
J�
J����
J�
J�
J�
J�I)	J�)	J�)	J�)	J�)	J�)	J�)	J�)	J�)	J�)	J�)	J����)	J�)	J�)	J�)	J�V�]�]�_�_�_	���7�&�&�&�&1�C�G�#����4�5�5�
;��:�:�c�:�:�:��
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;����>���
���#�#�%�%�%�%�(+�%�%�%����	
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
� � �>�4�4�U�\�\�^�^�4�4�4�
�
�
����8�9�9�
:�S�9�9�S�9�9�9��
:�
:�
:�
:�
:�
:�
:�
:�
:�
:�
:����
:�
:�
:�
:��N�!�!�(�+�+�+�� � �D�4�4�8�4�4�4�
�
�
����>�?�?�
C�3�B�B�c�B�B�B��
C�
C�
C�
C�
C�
C�
C�
C�
C�
C�
C����
C�
C�
C�
C��J������

0�

0��*�.�.�t�4�4��&�{�{�4��4�4���*�{�l�/J�/J�#�M�T�T� �+�|������
$0�
�4� � �
�����37����H����J���

)�
�.1�)�)�*�D�'�7�"�;�;�t�,�,�g�6�C��e�|�|�"/��c�
�G�"D�"D��!(�E�#�J�J�	)�

)�

)�

)�

)�

)�

)�

)�

)�

)�

)�

)����

)�

)�

)�

)��
��*�*��*�5�5�5��$�$�N������

��*�*��*�6�6�6�� � �!8�9�9�9��$�$�F������8=���
�
�������
� � �N�Y�Y�Y�Y�j�FV�FV�FX�FX�Y�Y�Y�
�
�
�y_	�_	�_	�_	�_	�_	�_	�_	�_	�_	�_	����_	�_	�_	�_	�B�}�	��K�K�M�M�M��I�I�K�K�K�K�K�	�	s��!H:�7D�H:�D	�H:�D	�H:�2
E�?H:�E	�H:�E	�H:�+F�:H:�F
	�
H:�
F
	�H:�&5G(�H:�(G,	�,H:�/G,	�0H:�H#�H:�#H'	�'H:�*H'	�+H:�:H>�H>�+V�
J�V�J!	�!V�$J!	�%V�="K+�V�+K/	�/V�2K/	�3A
V�=
M�
V�M	�V�M	�AV�0
O	�=V�	O
	�
V�O
	�BV�-AR:�.V�:R>	�>V�R>	�CV�V�V�parallelc��|���|jrdS|j�d��r"|j�d|j����t
|j��|r�tj�	|j��\}}tj�
tj�|��|��}tj
|��dz}tj|��D]J}|j�d��r|j�d|����t
|���IdSdS)z�Erase the data in this object.

        If `parallel` is true, then also deletes data files created from the
        basename by parallel-mode.

        NrhzErasing data file z.*zErasing parallel data file )rfrHr0r1r2r`rrIrJ�split�joinrK�glob�escape)r*r�data_dir�local�local_abs_path�patternr�s       r5�erasezCoverageData.erase-s8��	
���
�
�
��=�	��F��;���h�'�'�	G��K���E�4�>�E�E�F�F�F��T�^�$�$�$��	'� �g�m�m�D�N�;�;�O�H�e��W�\�\�"�'�/�/�(�*C�*C�U�K�K�N��k�.�1�1�D�8�G� �I�g�.�.�
'�
'���;�%�%�h�/�/�R��K�%�%�&P�H�&P�&P�Q�Q�Q��X�&�&�&�&�	'�	'�
'�
'r:c��tj�|j��r6|���5d|_ddd��dS#1swxYwYdSdS)z"Start using an existing data file.TN)rIrJr�r`r�rVrls r5rzCoverageData.readCs���
�7�>�>�$�.�)�)�	'������
'�
'�"&���
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'����
'�
'�
'�
'�
'�
'�	'�	's�A�A�Ac��dS)z,Ensure the data is written to the data file.Nr�rls r5r2zCoverageData.writeIs���r:c��|jtj��kr@|���|���tj��|_|js|���d|_dS)z+Call this before using the database at all.TN)rSrIrRrfrOrVr&rls r5r�zCoverageData._start_usingMsc���9��	���#�#��K�K�M�M�M��!�!�#�#�#��	���D�I���	��J�J�L�L�L�����r:c�*�t|j��S)z4Does the database have arcs (True) or lines (False).)rArXrls r5r�zCoverageData.has_arcsXs���D�N�#�#�#r:�Set[str]c�*�t|j��S)z�A set of all files that have been measured.

        Note that a file may be mentioned as measured even though no lines or
        arcs for that file are present in the data.

        )�setrPrls r5�measured_fileszCoverageData.measured_files\s���4�>�"�"�"r:c��|���|���5}|�d��5}d�|D��}ddd��n#1swxYwYddd��n#1swxYwY|S)zWA set of all contexts that have been measured.

        .. versionadded:: 5.0

        z%select distinct(context) from contextc��h|]
}|d��S�rr��r�rxs  r5�	<setcomp>z1CoverageData.measured_contexts.<locals>.<setcomp>ns��2�2�2�s�C��F�2�2�2r:N)r�r�rw)r*r�r{rs    r5�measured_contextszCoverageData.measured_contextses���	
������
�]�]�_�_�	3�����D�E�E�
3��2�2�c�2�2�2��
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3��s4�A/�
A�A/�A	�A/�A	� A/�/A3�6A3c�2�|���|���5}|�|��}|�	ddd��dS|�d|f��}|�|dpdcddd��S	ddd��dS#1swxYwYdS)aGet the plugin name of the file tracer for a file.

        Returns the name of the plugin that handles this file.  If the file was
        measured, but didn't use a plugin, then "" is returned.  If the file
        was not measured, then None is returned.

        Nz+select tracer from tracer where file_id = ?rr�)r�r�r�rp)r*r�r�r|rxs     r5r�zCoverageData.file_tracerqs��	
������
�]�]�_�_�	���m�m�H�-�-�G����	�	�	�	�	�	�	�	��/�/�"O�RY�Q[�\�\�C����1�v�|��
	�	�	�	�	�	�	�	��	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�B�"B�>B�B�Bc�,�|���|���5}|�d|f��5}d�|���D��|_ddd��n#1swxYwYddd��dS#1swxYwYdS)adSet a context for subsequent querying.

        The next :meth:`lines`, :meth:`arcs`, or :meth:`contexts_by_lineno`
        calls will be limited to only one context.  `context` is a string which
        must match a context exactly.  If it does not, no exception is raised,
        but queries will return no data.

        .. versionadded:: 5.0

        r�c��g|]
}|d��Sr1r�r2s  r5r�z2CoverageData.set_query_context.<locals>.<listcomp>�s��*L�*L�*L�c�3�q�6�*L�*L�*Lr:N)r�r�rw�fetchallr[)r*r�r�r{s    r5�set_query_contextzCoverageData.set_query_context�s0��	
������
�]�]�_�_�	M�����G�'��T�T�
M�X[�*L�*L�S�\�\�^�^�*L�*L�*L��'�
M�
M�
M�
M�
M�
M�
M�
M�
M�
M�
M����
M�
M�
M�
M�	M�	M�	M�	M�	M�	M�	M�	M�	M�	M�	M�	M����	M�	M�	M�	M�	M�	Ms5�B	�$A1�%B	�1A5	�5B	�8A5	�9B	�	B
�B
r�Optional[Sequence[str]]c��|���|r�|���5}d�dgt|��z��}|�d|z|��5}d�|���D��|_ddd��n#1swxYwYddd��dS#1swxYwYdSd|_dS)a�Set a number of contexts for subsequent querying.

        The next :meth:`lines`, :meth:`arcs`, or :meth:`contexts_by_lineno`
        calls will be limited to the specified contexts.  `contexts` is a list
        of Python regular expressions.  Contexts will be matched using
        :func:`re.search <python:re.search>`.  Data will be included in query
        results if they are part of any of the contexts matched.

        .. versionadded:: 5.0

        z or zcontext regexp ?zselect id from context where c��g|]
}|d��Sr1r�r2s  r5r�z3CoverageData.set_query_contexts.<locals>.<listcomp>�s��.P�.P�.P�#�s�1�v�.P�.P�.Pr:N)r�r�rr�rwr8r[)r*rr��context_clauser{s     r5�set_query_contextszCoverageData.set_query_contexts�sl��	
�������	+������
Q�C�!'���.@�-A�C��M�M�-Q�!R�!R���[�[�!@�>�!Q�S[�\�\�Q�`c�.P�.P������.P�.P�.P�D�+�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q����Q�Q�Q�Q�
Q�
Q�
Q�
Q�
Q�
Q�
Q�
Q�
Q�
Q�
Q�
Q����
Q�
Q�
Q�
Q�
Q�
Q�
'+�D�#�#�#s6�AB3�+$B�B3�B	�B3�"B	�#B3�3B7�:B7�Optional[List[TLineNo]]c�:�|���|���rO|�|��}|�8tj�|��}t
d�|D����S|���5}|�|��}|�	ddd��dSd}|g}|j	�?d�
dt|j	��z��}|d|zdzz
}||j	z
}|�||��5}	t
|	��}
ddd��n#1swxYwYt��}|
D]*}|�t|d�����+t
|��cddd��S#1swxYwYdS)	ajGet the list of lines executed for a source file.

        If the file was not measured, returns None.  A file might be measured,
        and have no lines executed, in which case an empty list is returned.

        If the file was executed, returns a list of integers, the line numbers
        executed in the file. The list is in no particular order.

        Nc��h|]
}|dk�|��Sr1r�)r��ls  r5r3z%CoverageData.lines.<locals>.<setcomp>�s��;�;�;�1�Q��U�U�Q�U�U�Ur:z/select numbits from line_bits where file_id = ?�, �?� and context_id in (�)r)r�r�r��	itertools�chain�
from_iterabler�r�r�r[rr�rwr-rr)
r*r�r��	all_linesr�r|r�r��	ids_arrayr{�bitmaps�numsrxs
             r5r�zCoverageData.lines�s-��	
�������=�=�?�?�	=��9�9�X�&�&�D���%�O�9�9�$�?�?�	��;�;�	�;�;�;�<�<�<�
�]�]�_�_�	"���m�m�H�-�-�G����	"�	"�	"�	"�	"�	"�	"�	"�
J���y���*�6� $�	�	�#��D�4K�0L�0L�*L� M� M�I��3�i�?�#�E�E�E��D�3�3�D��[�[���-�-�(��"�3�i�i�G�(�(�(�(�(�(�(�(�(�(�(����(�(�(�(��u�u��"�9�9�C��K�K���A�� 7� 7�8�8�8�8��D�z�z�!	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"s>�F�2A!F�D/�#F�/D3	�3F�6D3	�7AF�F�F�Optional[List[TArc]]c��|���|���5}|�|��}|�	ddd��dSd}|g}|j�?d�dt|j��z��}|d|zdzz
}||jz
}|�||��5}t|��cddd��cddd��S#1swxYwY	ddd��dS#1swxYwYdS)a�Get the list of arcs executed for a file.

        If the file was not measured, returns None.  A file might be measured,
        and have no arcs executed, in which case an empty list is returned.

        If the file was executed, returns a list of 2-tuples of integers. Each
        pair is a starting line number and an ending line number for a
        transition from one line to another. The list is in no particular
        order.

        Negative numbers have special meaning.  If the starting line number is
        -N, it represents an entry to the code object that starts at line N.
        If the ending ling number is -N, it's an exit from the code object that
        starts at line N.

        Nz7select distinct fromno, tono from arc where file_id = ?rCrDrErF)r�r�r�r[rr�rwr�)r*r�r�r|r�r�rKr{s        r5r�zCoverageData.arcs�s���"	
������
�]�]�_�_�	%���m�m�H�-�-�G����	%�	%�	%�	%�	%�	%�	%�	%�
R���y���*�6� $�	�	�#��D�4K�0L�0L�*L� M� M�I��3�i�?�#�E�E�E��D�3�3�D��[�[���-�-�%����9�9�%�%�%�%�%�%�%�	%�	%�	%�	%�	%�	%�	%�	%�%�%�%�%����%�%�%�%�%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	%�	%s<�C1�A!C1�0C�?C1�C	�C1�C	� C1�1C5�8C5�Dict[TLineNo, List[str]]c�L�|���|���5}|�|��}|�icddd��Stjt
��}|���r�d}|g}|j�?d�dt|j��z��}|d|zdzz
}||jz
}|�
||��5}|D]H\}	}
}|	dkr||	�|��|
dkr||
�|���I	ddd��n#1swxYwYn�d}|g}|j�?d�dt|j��z��}|d	|zdzz
}||jz
}|�
||��5}|D]2\}}t|��D]}
||
�|����3	ddd��n#1swxYwYddd��n#1swxYwYd
�|�
��D��S)z�Get the contexts for each line in a file.

        Returns:
            A dict mapping line numbers to a list of context names.

        .. versionadded:: 5.0

        Nztselect arc.fromno, arc.tono, context.context from arc, context where arc.file_id = ? and arc.context_id = context.idrCrDz and arc.context_id in (rFrzaselect l.numbits, c.context from line_bits l, context c where l.context_id = c.id and file_id = ?z and l.context_id in (c�4�i|]\}}|t|����Sr�)r�)r��linenors   r5r�z3CoverageData.contexts_by_lineno.<locals>.<dictcomp>s%��[�[�[�+;�6�8���X���[�[�[r:)r�r�r��collections�defaultdictr-r�r[rr�rwr�rr�)r*r�r�r|�lineno_contexts_mapr�r�rKr{r�r�r�rrSs              r5�contexts_by_linenozCoverageData.contexts_by_lineno�s��	
������
�]�]�_�_�%	E���m�m�H�-�-�G����%	E�%	E�%	E�%	E�%	E�%	E�%	E�%	E�
#.�"9�#�">�">���}�}���
E�L��
 �y���*�6� $�	�	�#��D�4K�0L�0L�*L� M� M�I��7�)�C�c�I�I�E��D�3�3�D��[�[���-�-�C��14�C�C�-���g�!�A�:�:�/��7�;�;�G�D�D�D��!�8�8�/��5�9�9�'�B�B�B��	C�C�C�C�C�C�C�C�C�C�C�C����C�C�C�C��&��
 �y���*�6� $�	�	�#��D�4K�0L�0L�*L� M� M�I��5�	�A�C�G�G�E��D�3�3�D��[�[���-�-�E��,/�E�E�(���&5�g�&>�&>�E�E�F�/��7�;�;�G�D�D�D�D�E�E�E�E�E�E�E�E�E�E�E�E�E����E�E�E�E�E%	E�%	E�%	E�%	E�%	E�%	E�%	E�%	E�%	E�%	E�%	E����%	E�%	E�%	E�%	E�N\�[�?R�?X�?X�?Z�?Z�[�[�[�[sb�G=�BG=�AD6�*G=�6D:	�:G=�=D:	�>A%G=�#6G&�G=�&G*	�*G=�-G*	�.G=�=H�H�List[Tuple[str, Any]]c���tdt�����5}|�d��5}d�|D��}ddd��n#1swxYwY|�d��5}d�|D��}ddd��n#1swxYwYtjd�|��d	�
��}ddd��n#1swxYwYdtjfd|fd
|fgS)zaOur information for `Coverage.sys_info`.

        Returns a list of (key, value) pairs.

        r^)rDzpragma temp_storec��g|]
}|d��Sr1r�r2s  r5r�z)CoverageData.sys_info.<locals>.<listcomp>'s��4�4�4��c�!�f�4�4�4r:Nzpragma compile_optionsc��g|]
}|d��Sr1r�r2s  r5r�z)CoverageData.sys_info.<locals>.<listcomp>)s��/�/�/�C��Q��/�/�/r:rC�K)�width�sqlite3_sqlite_version�sqlite3_temp_store�sqlite3_compile_options)rirrw�textwrap�wrapr�sqlite3�sqlite_version)�clsrer{�
temp_store�coptss     r5�sys_infozCoverageData.sys_infos����j��
�
�
6�
6�
6�	>�"����/�0�0�
5�C�4�4��4�4�4�
�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5����4�5�5�
0��/�/�3�/�/�/��
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0��M�$�)�)�E�"2�"2�"�=�=�=�E�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>����	>�	>�	>�	>�&�w�'=�>�
!�:�.�
&��.�
�	
sX�C�
A
�C�
A	�C�A	�C�-
B�:C�B
	�
C�
B
	�,C�C
�
C
)NNFNN)r<r=r>r?r@rArBrCrDrEr(rF�r(rF)rerir(rF�r(ri)r(rA)r(r�)r�r�r(rF)F)r�rtr�rAr(r�)r�rtr(r�)r�r�r(rF�r(rt)r�r�r(rF)r�r�r(rF)FF)r�rAr�rAr(rF)r�r�r(rFr)r�rtr�rtr(rFr�)r�r�r�r�r(rF)r�r�r(rF)r�r+r�r�r(rF)rrAr(rF)r(r+)r�rtr(r�)r�rtr(rF)rr:r(rF)r�rtr(r?)r�rtr(rN)r�rtr(rP)r(rX),r4�
__module__�__qualname__�__doc__r\rOrfrmrkrur�r�r�r�r�r�r9r�r�r�r�r�r�r�r�r�r�r�rr&rr2r�r�r.r4r�r9r>r�r�rW�classmethodrhr�r:r5r+r+�s�������R�R�l(,�-1��"&�%)�
-<�-<�-<�-<�-<�^/�/�/�/�(�(�(�(�����3�3�3�3�B`�`�`�`�&0�0�0�0�����@�@�@�@�.����8
,�
,�
,�
,�
,�	�	�	�	�
�(�(�(�
�W�(�������������
����
�W��B
����
�W��<�����*
����
�W��82�2�2�2�2�C�C�C�C�C�&2�2�2�2�0g�g�g�g�g�R'�'�'�'�'�,'�'�'�'�
�
�
�
�	�	�	�	�$�$�$�$�#�#�#�#�
�
�
�
�����$M�M�M�M� +�+�+�+�*!"�!"�!"�!"�F%�%�%�%�@1\�1\�1\�1\�f�
�
�
��[�
�
�
r:r+r>�Union[str, bool, None]�Union[str, None]c���|duretjtjd�����dd��}dtj��tj��|fz}n|durd}|S)z�Compute a filename suffix for a data file.

    If `suffix` is a string or None, simply return it. If `suffix` is True,
    then build a suffix incorporating the hostname, process id, and a random
    number.

    Returns a string or None.

    T�ri?Bz
%s.%s.%06dFN)�random�RandomrI�urandom�randint�socket�gethostnamerR)r>�dices  r5rara3sk����~�~�
�}�R�Z��]�]�+�+�3�3�A�v�>�>����!3�!5�!5�r�y�{�{�D� I�I���	�5������Mr:c��eZdZdZd"d�Zd#d	�Zd#d
�Zd$d�Zd#d�Zd%d�Z	e
j	d&d'd���Zd&d(d�Z
d&d)d�Zd&d*d�Zd+d�Zd,d�Zd-d�Zd.d �Zd!S)/ria(A simple abstraction over a SQLite database.

    Use as a context manager, then you can use it like a
    :class:`python:sqlite3.Connection` object::

        with SqliteDb(filename, debug_control) as db:
            db.execute("insert into schema (version) values (?)", (SCHEMA_VERSION,))

    r�rtrDr r(rFc�>�||_||_d|_d|_dS)Nr)rDr��nestr�)r*r�rDs   r5r\zSqliteDb.__init__Ss"����
� ��
���	�15����r:c���|j�dS|j�d��r"|j�d|j����	tj|jd���|_n2#t
j$r }td|j�d|����|�d}~wwxYw|j�	dd	d
���|�
d��|�
d��dS)
z2Connect to the db and do universal initialization.Nr�zConnecting to F)�check_same_thread�Couldn't use data file �: �REGEXP�c�0�tj||��duSr�)�re�search)�txt�pats  r5�<lambda>z#SqliteDb._connect.<locals>.<lambda>js��r�y��c�?R�?R�Z^�?^�r:zpragma journal_mode=offzpragma synchronous=off)r�rDr1r2r�rc�connect�Errorr�create_functionr�)r*rzs  r5r�zSqliteDb._connectYs���8���F��:���U�#�#�	A��J���?�d�m�?�?�@�@�@�	Y���t�}��N�N�N�D�H�H���}�	Y�	Y�	Y��N�d�m�N�N��N�N�O�O�UX�X�����	Y����	
�� � ��1�.^�.^�_�_�_�
	
���3�4�4�4����2�3�3�3�3�3s� A(�(B�7B�Bc�r�|j�-|jdkr$|j���d|_dSdSdS)z If needed, close the connection.Nr^)r�r�rdrls r5rdzSqliteDb.closessA���8��D�M�Z�$?�$?��H�N�N�����D�H�H�H� ��$?�$?r:c��|jdkr6|���|j�J�|j���|xjdz
c_|S)Nrr�)r}r�r��	__enter__rls r5r�zSqliteDb.__enter__ysP���9��>�>��M�M�O�O�O��8�'�'�'��H��� � � ��	�	�Q��	�	��r:c�|�|xjdzc_|jdkr�	|j�J�|j�|||��|���dS#t$rW}|j�d��r|j�d|����td|j	�d|����|�d}~wwxYwdS)Nr�rr�zEXCEPTION from __exit__: zCouldn't end data file r�)
r}r��__exit__rdrsrDr1r2rr�)r*�exc_type�	exc_value�	tracebackrzs     r5r�zSqliteDb.__exit__�s����	�	�Q��	�	��9��>�>�
]��x�+�+�+���!�!�(�I�y�A�A�A��
�
��������
]�
]�
]��:�$�$�U�+�+�H��J�$�$�%F��%F�%F�G�G�G�� R�$�-� R� R�S� R� R�S�S�Y\�\�����
]�����>s�9A�
B9�"AB4�4B9r��
parameters�
Iterable[Any]�sqlite3.Cursorc���|j�d��r(|rd|��nd}|j�d|�|����	|j�J�	|j�||��S#t
$r|j�||��cYSwxYw#tj$r�}t|��}	t|j
d��5}d}|�t|����|krd}ddd��n#1swxYwYn#t
$rYnwxYw|j�d��r|j�d	|����td
|j
�d|����|�d}~wwxYw)z2Same as :meth:`python:sqlite3.Connection.execute`.r�� with r�z
Executing N�rbs&!coverage.py: This is a private formatzILooks like a coverage 4.x data file. Are you mixing versions of coverage?zEXCEPTION from execute: r�r�)rDr1r2r�rwrsrcr�rt�openr�rr�r)r*r�r��tailrz�msg�bad_file�cov4_sigs        r5�_executezSqliteDb._execute�s���:���U�#�#�	9�.8�@�*�J�*�*�*�b�D��J���7�#�7��7�7�8�8�8�	Y��8�'�'�'�
9��x�'�'��Z�8�8�8���
9�
9�
9��x�'�'��Z�8�8�8�8�8�	
9�����
�}�	Y�	Y�	Y��c�(�(�C�
��$�-��.�.��(�H�H��}�}�S��]�]�3�3�x�?�?�C�����������������������
�
�
���
�����z� � ��'�'�
C��
� � �!A�C�!A�!A�B�B�B��N�d�m�N�N��N�N�O�O�UX�X�����!	Y���s�	B�A)�)%B�B�B�B�E2�#E-�3D�+C?�3D�?D	�D�D	�D�
E-�
D�E-�D�AE-�-E2r��Iterator[sqlite3.Cursor]c#�K�|�||��}	|V�|���dS#|���wxYw)z�Context managed :meth:`python:sqlite3.Connection.execute`.

        Use with a ``with`` statement to auto-close the returned cursor.
        N�r�rd)r*r�r�r{s    r5rwzSqliteDb.execute�sL�����m�m�C��,�,��	��I�I�I��I�I�K�K�K�K�K��C�I�I�K�K�K�K���s	�4�A
c�V�|�||�����dS)zQSame as :meth:`python:sqlite3.Connection.execute` when you don't need the cursor.Nr�)r*r�r�s   r5r�zSqliteDb.execute_void�s(���
�
�c�:�&�&�,�,�.�.�.�.�.r:rvc���|�||��5}|j�J�|j}ddd��n#1swxYwY|j�d��r|j�d|����|S)z(Like execute, but returns the lastrowid.N�sqldatazRow id result: )rw�	lastrowidrDr1r2)r*r�r�r{�rowids     r5r�zSqliteDb.execute_for_rowid�s���
�\�\�#�z�
*�
*�	'�c��=�,�,�,���E�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'��:���Y�'�'�	:��J���8�u�8�8�9�9�9��s�4�8�8�Optional[Tuple[Any, ...]]c�b�|�||��5}t|��}ddd��n#1swxYwYt|��dkrdSt|��dkr(ttt
df|d��St
d|�dt|���d����)a6Execute a statement and return the one row that results.

        This is like execute(sql, parameters).fetchone(), except it is
        correct in reading the entire result set.  This will raise an
        exception if more than one row results.

        Returns a row, or None if there were no rows.
        Nrr�.zSQL z shouldn't return � rows)rwr�r�rrr�AssertionError)r*r�r�r{�rowss     r5rpzSqliteDb.execute_one�s����\�\�#�z�
*�
*�	�c���9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��t�9�9��>�>��4�
��Y�Y�!�^�^���c�3�h���a��1�1�1� �!Q��!Q�!Q��T���!Q�!Q�!Q�R�R�Rs�3�7�7r��	List[Any]c��|j�d��r�|j�d��rdnd}|j�d|�dt|���d|����|j�d��r5t	|��D]%\}}|j�|d�d	|�����&|j�J�	|j�||��S#t$r|j�||��cYSwxYw)
z6Same as :meth:`python:sqlite3.Connection.executemany`.r�r��:r�zExecuting many r�r��4dr�)rDr1r2r��	enumerater��executemanyrs)r*r�r��final�irxs      r5�_executemanyzSqliteDb._executemany�s.���:���U�#�#�	9��:�,�,�Y�7�7�?�C�C�R�E��J���S�s�S�S�C��I�I�S�S�E�S�S�T�T�T��z� � ��+�+�
9�'��o�o�9�9�F�A�s��J�$�$��%7�%7�%7��%7�%7�8�8�8�8��x�#�#�#�	3��8�'�'��T�2�2�2���	3�	3�	3��8�'�'��T�2�2�2�2�2�		3���s�C�%D�Dc�|�t|��}|r*|�||�����dSdS)zUSame as :meth:`python:sqlite3.Connection.executemany` when you don't need the cursor.N)r�r�rd)r*r�r�s   r5r�zSqliteDb.executemany_void�sG���D�z�z���	1����c�4�(�(�.�.�0�0�0�0�0�	1�	1r:r�c	�6�|j�d��rI|j�d�t	|��t|d������|j�J�|j�|�����dS)z8Same as :meth:`python:sqlite3.Connection.executescript`.r�z"Executing script with {} chars: {}�dN)	rDr1r2rrr�rr�r�rd)r*r�s  r5r�zSqliteDb.executescript�s����:���U�#�#�	��J���A�H�H��F���\�&�#�6�6���
�
�
��x�#�#�#�����v�&�&�,�,�.�.�.�.�.r:c�l�|j�J�d�|j�����S)z9Return a multi-line string, the SQL dump of the database.N�
)r�r�iterdumprls r5r�z
SqliteDb.dump�s0���x�#�#�#��y�y���*�*�,�,�-�-�-r:N)r�rtrDr r(rFrirj)r�rtr�r�r(r�)r�)r�rtr�r�r(r�)r�rtr�r�r(rF)r�rtr�r�r(rv)r�rtr�r�r(r�)r�rtr�r�r(r�)r�rtr�r�r(rF)r�rtr(rFrk)r4rlrmrnr\r�rdr�r�r��
contextlib�contextmanagerrwr�r�rpr�r�r�r�r�r:r5ririIsm��������6�6�6�6�4�4�4�4�4��������
]�
]�
]�
]�Y�Y�Y�Y�@��%'�
�
�
�
���
�/�/�/�/�/������S�S�S�S�S�$3�3�3�3�"1�1�1�1�/�/�/�/�.�.�.�.�.�.r:ri)r'r%r(r%)r>rpr(rq)Arn�
__future__rrTr�r�r7r rGrIrtr�rxrcr�rarTr��typingrrrrrr	r
rrr
rrrrr�coverage.debugrrr�coverage.exceptionsrr�coverage.filesr�
coverage.miscrr�coverage.numbitsrrr�coverage.typesrrr r!r"�coverage.versionr#rqr�r%r9r+rarir�r:r5�<module>r�s�����"�"�"�"�"�"�������������������������	�	�	�	�
�
�
�
�	�	�	�	�
�
�
�
�����
�
�
�
�����������������������������������������������
D�C�C�C�C�C�C�C�C�C�<�<�<�<�<�<�<�<�&�&�&�&�&�&�6�6�6�6�6�6�6�6�L�L�L�L�L�L�L�L�L�L�F�F�F�F�F�F�F�F�F�F�F�F�F�F�(�(�(�(�(�(��^�B����
��<
��|�'�)�8�C��H�#5�
6�
6�
6��
�
�
�
�n
�n
�n
�n
�n
�=�n
�n
�n
�b����,v.�v.�v.�v.�v.�}�v.�v.�v.�v.�v.r: