Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
B

£fLI²$ã@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZmZddlmZmZmZddlmZddlmZmZmZmZmZddlmZmZm Z dd	l!m"Z"eeƒZd
Z#dZ$Gdd
„d
eƒZ%Gdd„deƒZ&dd„Z'dS)zSqlite coverage data.éN)Úenv)Ú
get_thread_idÚiitemsÚto_bytesÚ	to_string)ÚNoDebuggingÚSimpleReprMixinÚclipped_repr)ÚPathAliases)ÚCoverageExceptionÚcontractÚfile_be_goneÚfilename_suffixÚisolate_module)Únumbits_to_numsÚ
numbits_unionÚnums_to_numbits)Ú__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)
    -- 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)
);
c@sbeZdZdZdRdd„Zdd„Zdd	„Zd
d„Zdd
„Zdd„Z	dd„Z
dd„ZeZe
dddd„ƒZe
dddd„ƒZdSdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„ZdTd+d,„Zd-d.„ZdUd0d1„ZdVd2d3„ZdWd4d5„ZdXd6d7„Zd8d9„Zd:d;„Zd<d=„Z d>d?„Z!d@dA„Z"dBdC„Z#dDdE„Z$dFdG„Z%dHdI„Z&dJdK„Z'dLdM„Z(dNdO„Z)e*dPdQ„ƒZ+dS)YÚCoverageDataaZ
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`.  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`.

    NFcCsv||_tj |pd¡|_||_||_|p,tƒ|_| 	¡i|_
i|_t ¡|_
d|_d|_d|_d|_d|_d|_dS)aVCreate a :class:`CoverageData` object to hold coverage-measured data.

        Arguments:
            basename (str): the base name of the data file, defaulting to
                ".coverage".
            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Ú_warnrÚ_debugÚ_choose_filenameÚ	_file_mapÚ_dbsÚgetpidÚ_pidÚ
_have_usedÚ
_has_linesÚ	_has_arcsÚ_current_contextÚ_current_context_idÚ_query_context_ids)ÚselfÚbasenameÚsuffixZno_diskÚwarnÚdebug©r.úŽ/build/wlanpi-profiler-MIf3Xw/wlanpi-profiler-1.0.8/debian/wlanpi-profiler/opt/wlanpi-profiler/lib/python3.7/site-packages/coverage/sqldata.pyÚ__init__¸s
zCoverageData.__init__cCs:|jrd|_n(|j|_t|jƒ}|r6|jd|7_dS)z.Set self._filename based on inited attributes.z:memory:Ú.N)rÚ	_filenamerrr)r)r+r.r.r/rÝs
zCoverageData._choose_filenamecCs>|jr"x|j ¡D]}| ¡qWi|_i|_d|_d|_dS)zReset our attributes.FN)r ÚvaluesÚcloserr#r')r)Údbr.r.r/Ú_resetçszCoverageData._resetc
Csœ|j d¡r |j d |j¡¡t|j|jƒ|jtƒ<}|T| t	¡| 
dtf¡| ddt
ttddƒƒfdtfd	tj ¡ d
¡fg¡WdQRXdS)zgCreate a db file that doesn't exist yet.

        Initializes the schema and certain metadata.
        ÚdataiozCreating data file {!r}z0insert into coverage_schema (version) values (?)z+insert into meta (key, value) values (?, ?)Zsys_argvÚargvNÚversionÚwhenz%Y-%m-%d %H:%M:%S)rÚshouldÚwriteÚformatr2ÚSqliteDbr rÚ
executescriptÚSCHEMAÚexecuteÚSCHEMA_VERSIONÚexecutemanyÚstrÚgetattrÚsysrÚdatetimeÚnowÚstrftime)r)r5r.r.r/Ú
_create_dbñs
zCoverageData._create_dbcCsB|j d¡r |j d |j¡¡t|j|jƒ|jtƒ<| ¡dS)z0Open an existing db file, and read its metadata.r7zOpening data file {!r}N)	rr;r<r=r2r>r rÚ_read_db)r)r.r.r/Ú_open_dbszCoverageData._open_dbcCsÐ|jtƒº}y| d¡\}Wn4tk
rR}ztd |j|¡ƒ‚Wdd}~XYnX|tkrptd |j|t¡ƒ‚x.| d¡D] }t	t
|dƒƒ|_|j|_q|Wx | d¡D]\}}||j
|<q¬WWdQRXdS)zARead the metadata from a database so that we are ready to use it.z#select version from coverage_schemaz:Data file {!r} doesn't seem to be a coverage data file: {}Nz;Couldn't use data file {!r}: wrong schema: {} instead of {}z-select value from meta where key = 'has_arcs'rzselect path, id from file)r rÚexecute_oneÚ	Exceptionrr=r2rBrAÚboolÚintr%r$r)r)r5Zschema_versionÚexcÚrowrÚfile_idr.r.r/rKs zCoverageData._read_dbcCs8tƒ|jkr,tj |j¡r$| ¡n| ¡|jtƒS)zGet the SqliteDb object to use.)rr rrÚexistsr2rLrJ)r)r.r.r/Ú_connect&s

zCoverageData._connectc	Csbtƒ|jkrtj |j¡sdSy*| ¡}| d¡}tt	|ƒƒSQRXWnt
k
r\dSXdS)NFzselect * from file limit 1)rr rrrTr2rUrArOÚlistr)r)ÚconÚrowsr.r.r/Ú__nonzero__/s

zCoverageData.__nonzero__Úbytes)Zreturnsc	CsJ|j d¡r |j d |j¡¡| ¡}dt t| 	¡ƒ¡SQRXdS)a6Serialize 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.

        Returns:
            A byte string of serialized data.

        .. versionadded:: 5.0

        r7z Dumping data from data file {!r}ózN)
rr;r<r=r2rUÚzlibÚcompressrÚdump)r)rWr.r.r/Údumps;s
zCoverageData.dumps)Údatac	Cs¨|j d¡r |j d |j¡¡|dd…dkrLtd |dd…t|ƒ¡ƒ‚tt 	|dd…¡ƒ}t
|j|jƒ|jtƒ<}|| 
|¡WdQRX| ¡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.

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

        .. versionadded:: 5.0

        r7z Loading data into data file {!r}Nér[z3Unrecognized serialization: {!r} (head of {} bytes)é(T)rr;r<r=r2rÚlenrr\Ú
decompressr>r rr?rKr#)r)r`Úscriptr5r.r.r/ÚloadsNs
zCoverageData.loadsc	CsH||jkr<|r<| ¡ }| d|f¡}|j|j|<WdQRX|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)rrUrAÚ	lastrowidÚget)r)ÚfilenameÚaddrWÚcurr.r.r/Ú_file_idhs

zCoverageData._file_idc	CsN|dk	st‚| ¡| ¡(}| d|f¡}|dk	r<|dSdSWdQRXdS)zGet the id for a context.Nz(select id from context where context = ?r)ÚAssertionErrorÚ_start_usingrUrM)r)ÚcontextrWrRr.r.r/Ú_context_idus
zCoverageData._context_idcCs.|j d¡r|j d|f¡||_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: %rN)rr;r<r&r')r)ror.r.r/Úset_context€s	zCoverageData.set_contextc	CsR|jpd}| |¡}|dk	r$||_n*| ¡}| d|f¡}|j|_WdQRXdS)z4Use the _current_context to set _current_context_id.ÚNz(insert into context (context) values (?))r&rpr'rUrArg)r)roZ
context_idrWrkr.r.r/Ú_set_context_idŽs


zCoverageData._set_context_idcCs|jS)zLThe base filename for storing data.

        .. versionadded:: 5.0

        )r)r)r.r.r/Ú
base_filename™szCoverageData.base_filenamecCs|jS)zBWhere is the data stored?

        .. versionadded:: 5.0

        )r2)r)r.r.r/Ú
data_filename¡szCoverageData.data_filenamec		Csâ|j d¡r6|j dt|ƒtdd„| ¡Dƒƒf¡| ¡|jdd|sRdS| ¡~}| 	¡xnt
|ƒD]b\}}t|ƒ}|j|dd}d	}t
| |||jf¡ƒ}|r¼t||d
d
ƒ}| d||j|f¡qnWWdQRXdS)z Add measured line data.

        `line_data` is a dictionary mapping file names to dictionaries::

            { filename: { lineno: None, ... }, ...}

        rqz&Adding lines: %d files, %d lines totalcss|]}t|ƒVqdS)N)rc)Ú.0Úlinesr.r.r/ú	<genexpr>³sz)CoverageData.add_lines.<locals>.<genexpr>T)rxN)rjzBselect numbits from line_bits where file_id = ? and context_id = ?rzQinsert or replace into line_bits  (file_id, context_id, numbits) values (?, ?, ?))rr;r<rcÚsumr3rnÚ_choose_lines_or_arcsrUrtrrrlrVrAr'r)	r)Z	line_datarWriZlinenosZlinemaprSÚqueryÚexistingr.r.r/Ú	add_lines©s&"
zCoverageData.add_linesc	s¶ˆj d¡r6ˆj dt|ƒtdd„| ¡Dƒƒf¡ˆ ¡ˆjdd|sRdSˆ ¡R}ˆ 	¡xBt
|ƒD]6\}}ˆj|dd‰‡‡fd	d
„|Dƒ}| d|¡qnWWdQRXdS)zŸAdd measured arc data.

        `arc_data` is a dictionary mapping file names to dictionaries::

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

        rqz$Adding arcs: %d files, %d arcs totalcss|]}t|ƒVqdS)N)rc)rwÚarcsr.r.r/ryÓsz(CoverageData.add_arcs.<locals>.<genexpr>T)rN)rjcsg|]\}}ˆˆj||f‘qSr.)r')rwÚfromnoÚtono)rSr)r.r/ú
<listcomp>Ýsz)CoverageData.add_arcs.<locals>.<listcomp>zQinsert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?))
rr;r<rcrzr3rnr{rUrtrrlrC)r)Zarc_datarWrirr`r.)rSr)r/Úadd_arcsÉs"
zCoverageData.add_arcsc	Cs„|s|st‚|r|rt‚|r*|jr*tdƒ‚|r<|jr<tdƒ‚|js€|js€||_||_| ¡}| ddtt|ƒƒf¡WdQRXdS)z5Force the data file to choose between lines and arcs.z3Can't add line measurements to existing branch dataz3Can't add branch measurements to existing line dataz+insert into meta (key, value) values (?, ?)Úhas_arcsN)rmr%rr$rUrArDrP)r)rxrrWr.r.r/r{äs


z"CoverageData._choose_lines_or_arcsc	Cs¾|j d¡r"|j dt|ƒf¡|s*dS| ¡| ¡z}xrt|ƒD]f\}}| |¡}|dkrntd|fƒ‚| 	|¡}|r˜||kr¬td|||fƒ‚qF|rF| 
d||f¡qFWWdQRXdS)zdAdd per-file plugin information.

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

        rqzAdding file tracers: %d filesNz3Can't add file tracer data for unmeasured file '%s'z/Conflicting file tracer name for '%s': %r vs %rz2insert into tracer (file_id, tracer) values (?, ?))rr;r<rcrnrUrrlrÚfile_tracerrA)r)Zfile_tracersrWriÚplugin_namerSZexisting_pluginr.r.r/Úadd_file_tracersõs*


zCoverageData.add_file_tracersrscCs| |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)rir†r.r.r/Ú
touch_fileszCoverageData.touch_filec	Cs€|j d¡r|j d|f¡| ¡| ¡H|jsD|jsDtdƒ‚x,|D]$}|j|dd|rJ| 	||i¡qJWWdQRXdS)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.
        rqzTouching %rz*Can't touch files in an empty CoverageDataT)rjN)
rr;r<rnrUr%r$rrlr‡)r)Ú	filenamesr†rir.r.r/rˆs

zCoverageData.touch_filesc	s&|j d¡r&|j dt|ddƒf¡|jr:|jr:tdƒ‚|jrN|jrNtdƒ‚ˆpVtƒ‰| ¡| 	¡| 
¡¶}| d¡}‡fdd	„|Dƒ‰| ¡| d
¡}dd„|Dƒ}| ¡| d
¡}‡fdd„|Dƒ}| ¡| d¡}‡fdd	„|Dƒ}| ¡| d¡}‡fdd	„|Dƒ}| ¡WdQRX| 
¡Ö}d|j
_dd	„| d¡Dƒ}	|	 ‡fdd	„| d¡Dƒ¡| ddd„ˆ ¡Dƒ¡dd	„| d¡Dƒ‰| ddd„|Dƒ¡dd	„| d¡Dƒ‰i}
xVˆ ¡D]J}|	 |¡}| |d ¡}
|dk	r||
krtd!|||
fƒ‚|
|
|<qØW‡‡fd"d„|Dƒ}| d¡}xB|D]:\}}}ˆ |¡|f}||krzt|||ƒ}|||<qJW| ¡|r®|jd#d$| d%|¡|rê|jd#d&| d'¡| d(‡‡fd)d„| ¡Dƒ¡| d*‡fd+d„|
 ¡Dƒ¡WdQRX| ¡| 	¡dS),zÙ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.
        rqzUpdating with data from %rr2z???z%Can't combine arc data with line dataz%Can't combine line data with arc datazselect path from filecsi|]\}ˆ |¡|“qSr.)Úmap)rwr)Úaliasesr.r/ú
<dictcomp>Ksz'CoverageData.update.<locals>.<dictcomp>zselect context from contextcSsg|]
\}|‘qSr.r.)rwror.r.r/r‚Psz'CoverageData.update.<locals>.<listcomp>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_idcs$g|]\}}}}ˆ||||f‘qSr.r.)rwrror€r)Úfilesr.r/r‚Zszª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_idcs i|]\}}}|ˆ||f“qSr.r.)rwrroÚnumbits)rŽr.r/rdszPselect file.path, tracer from tracer inner join file on file.id = tracer.file_idcsi|]\}}|ˆ|“qSr.r.)rwrÚtracer)rŽr.r/rpsNZ	IMMEDIATEcSsi|]\}d|“qS)rsr.)rwrr.r.r/rzscsi|]\}}|ˆ |¡“qSr.)r‹)rwrr)rŒr.r/r{sz,insert or ignore into file (path) values (?)css|]}|fVqdS)Nr.)rwÚfiler.r.r/ry†sz&CoverageData.update.<locals>.<genexpr>cSsi|]\}}||“qSr.r.)rwÚidrr.r.r/rˆszselect id, path from filez2insert or ignore into context (context) values (?)css|]}|fVqdS)Nr.)rwror.r.r/ryŽscSsi|]\}}||“qSr.r.)rwr’ror.r.r/rszselect id, context from contextrsz/Conflicting file tracer name for '%s': %r vs %rc3s*|]"\}}}}ˆ|ˆ|||fVqdS)Nr.)rwr‘ror€r)Úcontext_idsÚfile_idsr.r/ry©sT)rzQinsert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?))rxzdelete from line_bitszEinsert into line_bits (file_id, context_id, numbits) values (?, ?, ?)cs&g|]\\}}}ˆ|ˆ||f‘qSr.r.)rwr‘ror)r“r”r.r/r‚Ìsz<insert or ignore into tracer (file_id, tracer) values (?, ?)c3s|]\}}ˆ||fVqdS)Nr.)rwrir)r”r.r/ryÒs)rr;r<rEr$r%rr
rnÚreadrUrAr4rWZisolation_levelÚupdaterCr3rhr‹rr{Úitemsr6)r)Z
other_datarŒÚconnrkÚcontextsrrxZtracersZthis_tracersZ
tracer_maprZthis_tracerZother_tracerZarc_rowsrorÚkeyr.)rŒr“r”rŽr/r–1s¤







"zCoverageData.updatecCs®| ¡|jrdS|j d¡r2|j d |j¡¡t|jƒ|rªtj	 
|j¡\}}|d}tj	 tj	 |¡|¡}x8t
 
|¡D]*}|j d¡rž|j d |¡¡t|ƒq|WdS)z™Erase the data in this object.

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

        Nr7zErasing data file {!r}z.*zErasing parallel data file {!r})r6rrr;r<r=r2r
rrÚsplitÚjoinrÚglob)r)ÚparallelÚdata_dirÚlocalZlocaldotÚpatternrir.r.r/ÚeraseÙs
zCoverageData.erasec	Cs| ¡d|_WdQRXdS)z"Start using an existing data file.TN)rUr#)r)r.r.r/r•ïs
zCoverageData.readcCsdS)z,Ensure the data is written to the data file.Nr.)r)r.r.r/r<ôszCoverageData.writecCs@|jt ¡kr(| ¡| ¡t ¡|_|js6| ¡d|_dS)z+Call this before using the database at all.TN)r"rr!r6rr#r¢)r)r.r.r/rnøs
zCoverageData._start_usingcCs
t|jƒS)z4Does the database have arcs (True) or lines (False).)rOr%)r)r.r.r/r„szCoverageData.has_arcscCs
t|jƒS)z*A set of all files that had been measured.)Úsetr)r)r.r.r/Úmeasured_filesszCoverageData.measured_filesc	Cs4| ¡| ¡}dd„| d¡Dƒ}WdQRX|S)zWA set of all contexts that have been measured.

        .. versionadded:: 5.0

        cSsh|]}|d’qS)rr.)rwrRr.r.r/ú	<setcomp>sz1CoverageData.measured_contexts.<locals>.<setcomp>z%select distinct(context) from contextN)rnrUrA)r)rWr™r.r.r/Úmeasured_contextss
zCoverageData.measured_contextsc	CsX| ¡| ¡>}| |¡}|dkr(dS| d|f¡}|dk	rJ|dpHdSdSQRXdS)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 = ?rrs)rnrUrlrM)r)rirWrSrRr.r.r/r…s

zCoverageData.file_tracerc	CsB| ¡| ¡(}| d|f¡}dd„| ¡Dƒ|_WdQRXdS)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

        z(select id from context where context = ?cSsg|]}|d‘qS)rr.)rwrRr.r.r/r‚6sz2CoverageData.set_query_context.<locals>.<listcomp>N)rnrUrAÚfetchallr()r)rorWrkr.r.r/Úset_query_context(s
zCoverageData.set_query_contextc	Csd| ¡|rZ| ¡>}d dgt|ƒ¡}| d||¡}dd„| ¡Dƒ|_WdQRXnd|_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 cSsg|]}|d‘qS)rr.)rwrRr.r.r/r‚Isz3CoverageData.set_query_contexts.<locals>.<listcomp>N)rnrUrœrcrAr§r()r)r™rWZcontext_clauserkr.r.r/Úset_query_contexts8s
 zCoverageData.set_query_contextsc	Csî| ¡| ¡r@| |¡}|dk	r@tj |¡}tdd„|DƒƒS| ¡œ}| |¡}|dkr`dSd}|g}|j	dk	r¢d 
dt|j	ƒ¡}|d|d7}||j	7}t| ||¡ƒ}	t
ƒ}
x|	D]}|
 t|d	ƒ¡q¾Wt|
ƒSWdQRXdS)
acGet the list of lines executed for a 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.

        NcSsh|]}|dkr|’qS)rr.)rwÚlr.r.r/r¥\sz%CoverageData.lines.<locals>.<setcomp>z/select numbits from line_bits where file_id = ?z, ú?z and context_id in (ú)r)rnr„rÚ	itertoolsÚchainÚ
from_iterablerVrUrlr(rœrcrAr£r–r)r)rirZ	all_linesrWrSr|r`Ú	ids_arrayZbitmapsÚnumsrRr.r.r/rxMs*






zCoverageData.linesc	CsŒ| ¡| ¡r}| |¡}|dkr(dSd}|g}|jdk	rjd dt|jƒ¡}|d|d7}||j7}| ||¡}t|ƒSWdQRXdS)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 = ?z, r«z and context_id in (r¬)rnrUrlr(rœrcrArV)r)rirWrSr|r`r°rr.r.r/ros



zCoverageData.arcsc
	Cs`t t¡}| ¡| ¡:}| |¡}|dkr4|S| ¡rÐd}|g}|jdk	r~d dt	|jƒ¡}|d|d7}||j7}xÒ| 
||¡D]>\}}	}
|
||kr°|| |
¡|
||	krŒ||	 |
¡qŒWn‚d}|g}|jdk	rd dt	|jƒ¡}|d|d7}||j7}x<| 
||¡D],\}}
x t|ƒD]}|| |
¡q4Wq"WWdQRX|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.idz, r«z and arc.context_id in (r¬zaselect 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 ()
ÚcollectionsÚdefaultdictrVrnrUrlr„r(rœrcrAÚappendr)
r)riZlineno_contexts_maprWrSr|r`r°r€rrorÚlinenor.r.r/Úcontexts_by_linenos8	




$zCoverageData.contexts_by_linenoc	Csbtdtƒd.}dd„| d¡Dƒ}dd„| d¡Dƒ}WdQRXd	tjfd
tjfd|fd|fgS)
zaOur information for `Coverage.sys_info`.

        Returns a list of (key, value) pairs.

        z:memory:)r-cSsg|]}|d‘qS)rr.)rwrRr.r.r/r‚Æsz)CoverageData.sys_info.<locals>.<listcomp>zpragma temp_storecSsg|]}|d‘qS)rr.)rwrRr.r.r/r‚Çszpragma compile_optionsNZsqlite3_versionZsqlite3_sqlite_versionZsqlite3_temp_storeZsqlite3_compile_options)r>rrAÚsqlite3r9Zsqlite_version)Úclsr5Z
temp_storeZcompile_optionsr.r.r/Úsys_info¾szCoverageData.sys_info)NNFNN)F)FF)rs)rs)N)F),Ú__name__Ú
__module__Ú__qualname__Ú__doc__r0rr6rJrLrKrUrYÚ__bool__rr_rfrlrprrrtrurvr~rƒr{r‡r‰rˆr–r¢r•r<rnr„r¤r¦r…r¨r©rxrr¶Úclassmethodr¹r.r.r.r/risPM
%

	


 
!


)
" /rc@sdeZdZdZdd„Zdd„Zdd„Zdd	„Zd
d„Zdd
d„Z	ddd„Z
dd„Zdd„Zdd„Z
dS)r>a(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,))

    cCs*| d¡r|nd|_||_d|_d|_dS)NÚsqlr)r;r-riÚnestrW)r)rir-r.r.r/r0ÛszSqliteDb.__init__cCs¢|jdk	rdS|j}tjrHtjrHytj |j¡}Wntk
rFYnX|j	rb|j	 
d |j¡¡tj
|dd|_|j ddt¡| d¡ ¡| d¡ ¡dS)	z2Connect to the db and do universal initialization.NzConnecting to {!r}F)Zcheck_same_threadÚREGEXPézpragma journal_mode=offzpragma synchronous=off)rWrirÚWINDOWSÚPY2rrÚrelpathÚ
ValueErrorr-r<r=r·ÚconnectZcreate_functionÚ_regexprAr4)r)rir.r.r/rUás
zSqliteDb._connectcCs(|jdk	r$|jdkr$|j ¡d|_dS)z If needed, close the connection.Nz:memory:)rWrir4)r)r.r.r/r4s
zSqliteDb.closecCs.|jdkr| ¡|j ¡|jd7_|S)Nrra)rÁrUrWÚ	__enter__)r)r.r.r/rÊs


zSqliteDb.__enter__c
Csv|jd8_|jdkrry|j |||¡| ¡Wn<tk
rp}z|jr^|j d |¡¡‚Wdd}~XYnXdS)NrarzEXCEPTION from __exit__: {})rÁrWÚ__exit__r4rNr-r<r=)r)Úexc_typeÚ	exc_valueÚ	tracebackrQr.r.r/rËs
zSqliteDb.__exit__r.cCs|jr,|rd |¡nd}|j d ||¡¡y2y|j ||¡Stk
rZ|j ||¡SXWn¤tjk
r}z‚t|ƒ}y6t	|j
dƒ }d}| t|ƒ¡|kr¦d}WdQRXWntk
rÆYnX|jrà|j d |¡¡t
d	 |j
|¡ƒ‚Wdd}~XYnXdS)
z2Same as :meth:`python:sqlite3.Connection.execute`.z
 with {!r}rszExecuting {!r}{}Úrbs&!coverage.py: This is a private formatzILooks like a coverage 4.x data file. Are you mixing versions of coverage?NzEXCEPTION from execute: {}zCouldn't use data file {!r}: {})r-r=r<rWrArNr·ÚErrorrDÚopenrir•rcr)r)rÀÚ
parametersÚtailrQÚmsgZbad_fileZcov4_sigr.r.r/rAs(zSqliteDb.executecCsLt| ||¡ƒ}t|ƒdkr dSt|ƒdkr4|dStd |t|ƒ¡ƒ‚dS)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.
        rNraz!Sql {!r} shouldn't return {} rows)rVrArcrr=)r)rÀrÒrXr.r.r/rM<s	zSqliteDb.execute_onecCs4|jr&t|ƒ}|j d |t|ƒ¡¡|j ||¡S)z6Same as :meth:`python:sqlite3.Connection.executemany`.z Executing many {!r} with {} rows)r-rVr<r=rcrWrC)r)rÀr`r.r.r/rCMszSqliteDb.executemanycCs4|jr$|j d t|ƒt|dƒ¡¡|j |¡dS)z8Same as :meth:`python:sqlite3.Connection.executescript`.z"Executing script with {} chars: {}édN)r-r<r=rcr	rWr?)r)rer.r.r/r?Ts
zSqliteDb.executescriptcCsd |j ¡¡S)z9Return a multi-line string, the SQL dump of the database.Ú
)rœrWZiterdump)r)r.r.r/r^\sz
SqliteDb.dumpN)r.)r.)rºr»r¼r½r0rUr4rÊrËrArMrCr?r^r.r.r.r/r>Ñs	$

r>cCst ||¡dk	S)zA regexp function for SQLite.N)ÚreÚsearch)Útextr¡r.r.r/rÉasrÉ)(r½r²rGrr­rr×r·rFr\ZcoveragerZcoverage.backwardrrrrZcoverage.debugrrr	Zcoverage.filesr
Z
coverage.miscrrr
rrZcoverage.numbitsrrrZcoverage.versionrrBr@rr>rÉr.r.r.r/Ú<module>s:Gn