tjydZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl 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 l2m3Z3m4Z4m5Z5m6Z6m7Z7dd l8m9Z9e-e Z d Z:d Z;e dedefZddZ?Gdde$Z@dS)zSQLite coverage data.) annotationsN)castAnyCallable CollectionDictIterableIteratorListMappingOptionalSequenceSetTupleTypeVarUnion) NoDebugging AutoReprMixin clipped_repr)CoverageException DataError) PathAliases) file_be_goneisolate_module)numbits_to_nums numbits_unionnums_to_numbits)FilePathTArc TDebugCtlTLineNoTWarnFn) __version__aCREATE 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.)boundmethodreturncHtjdfd }|S) z4A decorator for methods that should hold self._lock.self CoverageDataargsrkwargsr(cn|jdr*|jd|jdj|j5|jdr*|jd|jdj|g|Ri|cdddS#1swxYwYdS)NlockzLocking z for zLocked )_debugshouldwrite_lock__name__)r*r,r-r's /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/coverage/sqldata.py_wrappedz_locked.._wrappedws ;  f % % O K  MMMFOMM N N N Z 1 1{!!&)) S !!"QTZ"Q"Q"Q"QRRR6$000000 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) functoolswraps)r'r6s` r5_lockedr9us=_V111111 OceZdZdZ dWdXdZdYdZdYdZdYdZdYdZdZdZ d[dZ d\dZ d]dZ d^dZ d_d`d"Zdad$Zedbd&ZdYd'Zdcd(Zdcd)Zeddd,Zeded/Zdfdgd2Zedhd5Zdidjd8Zdkdld;Zdmd<Zdkdnd@Zd_dodBZdYdCZdYdDZdYdEZ d\dFZ!dpdHZ"dpdIZ#dqdJZ$drdKZ%dsdNZ&dtdPZ'dudRZ(dvdTZ)e*dwdVZ+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 `. 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. NFbasenameOptional[FilePath]suffixOptional[Union[str, bool]]no_diskboolwarnOptional[TWarnFn]debugOptional[TDebugCtl]r(Nonec||_tj|pd|_||_||_|p t|_| i|_ i|_ tj |_ tj|_d|_d|_d|_d|_d|_d|_dS)aCreate 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_diskospathabspath _basename_suffix_warnrr0_choose_filename _file_map_dbsgetpid_pid threadingRLockr3 _have_used _has_lines _has_arcs_current_context_current_context_id_query_context_ids)r*r<r>r@rBrDs r5__init__zCoverageData.__init__s,  )@[AA  ,{}}  )+)+ IKK _&&  /326 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 _filenamerLfilename_suffixrM)r*r>s r5rOzCoverageData._choose_filenamesY = /'DNNN!^DN$T\22F /#,. / /r:c|js7|jD]}|i|_i|_d|_d|_dS)zReset our attributes.FN)rHrQvaluescloserPrVrZ)r*dbs r5_resetzCoverageData._resets[} i&&((   DI#'   r:c |jdr"|jd|jt |j|j|jt j<|dS)z0Open an existing db file, and read its metadata.dataiozOpening data file N) r0r1r2r`SqliteDbrQrT get_ident_read_dbr*s r5_open_dbzCoverageData._open_dbsp ;  h ' ' G K  E4>EE F F F+3DNDK+P+P )%''( r:c|jtj5} |d}|J |d}|tkr.t d|j|tng#t$rZ}dt|vr| |n)t d|j||Yd}~nd}~wwxYw|d}|4tt|d|_ |j |_|d5}|D]\}}||j|< dddn #1swxYwYddddS#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_oneSCHEMA_VERSIONrformatr` Exceptionstr_init_dbrAintrXrWexecuterP)r*rerowschema_versionexccurfile_idrJs r5rkzCoverageData._read_db!s7 Yy*,, - 3 nn%JKK"%Q!^33#U\\ NNN4   3s3xx??MM"%%%%#T[[ NC &%%%% $..!PQQC!%c#a&kk!2!2&*n"4788 3C%(33MGT+2DN4((3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 37 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s`E<A=AE<= C!ACE<C!!A#E<E$ E<$E( (E<+E( ,E<<FFreric 4|jdr"|jd|j|t |dtfdtfg}|jdrk| dtttddfd tj d fg|d |dS) z+Write the initial contents of the database.rhzIniting data file z0insert into coverage_schema (version) values (?)versionprocesssys_argvargvNwhenz%Y-%m-%d %H:%M:%S5insert or ignore into meta (key, value) values (?, ?))r0r1r2r` executescriptSCHEMA execute_voidrqr#extendrtgetattrsysdatetimenowstrftimeexecutemany_void)r*re meta_datas r5ruzCoverageData._init_dbBs ;  h ' ' G K  E4>EE F F F     J^L]^^^  $  ;  i ( (    Sfd!;!;<<=*..0099:MNNO    SU^_____r:ctj|jvr||jtjS)zGet the SqliteDb object to use.)rTrjrQrmrls r5_connectzCoverageData._connectUs;    1 1 MMOOOy,..//r:ctj|jvr&tj|jsdS |5}|d5}tt|cdddcdddS#1swxYwY ddddS#1swxYwYdS#t$rYdSwxYw)NFzselect * from file limit 1) rTrjrQrIrJexistsr`rrwrAlistr)r*conr{s r5__bool__zCoverageData.__bool__[sk   ! ! 2 227>>$.;Y;Y 25  +C[[!=>>+#S ??+++++++ + + + + + + + ++++++++++ + + + + + + + + + + + + + + + + + +!   55 s`CB:,B! B: C!B% %B:(B% )B:- C:B>>CB>C CCbytescR|jdr"|jd|j|5}|}dt j|dzcdddS#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 zutf-8N) r0r1r2r`rdumpzlibcompressencode)r*rscripts r5dumpszCoverageData.dumpses" ;  h ' ' Q K  OT^OO P P P ]]__ @XXZZF$- g(>(>??? @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @s>BB #B datacL|jdr"|jd|j|dddkr+t d|dddt |d t j|ddd }t|j|jx|j tj <}|5| |dddn #1swxYwY|d |_dS) aDeserialize 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 NrzUnrecognized serialization: (z (head of z bytes)rT)r0r1r2r`rlenr decompressdecoderirQrTrjrrkrV)r*rrres r5loadszCoverageData.loads|s] ;  h ' ' Q K  OT^OO P P P 8t  XtCRCyXXc$iiXXX abb**11'::080U0UU )%''(2  % %   V $ $ $ % % % % % % % % % % % % % % % sC>>DDfilenamertadd Optional[int]c||jvrM|rK|5}|d|f|j|<dddn #1swxYwY|j|S)zGet 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)rPrexecute_for_rowidget)r*rrrs r5_file_idzCoverageData._file_ids 4> ) ) ]]__/2/D/DG! 00DN8, ~!!(+++s A  AAcontextc|J||5}|d|f}|'tt|dcdddS ddddS#1swxYwYdS)zGet the id for a context.N(select id from context where context = ?r) _start_usingrrprrv)r*rrrxs r5 _context_idzCoverageData._context_ids"""  ]]__ //"LwjYYCCQ((                            s4A<.A<<BB Optional[str]c|jdr|jd|||_d|_dS)zSet 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*rs r5 set_contextzCoverageData.set_contextsQ ;  h ' ' ? K  ='== > > > '#'   r:c|jpd}||}| ||_dS|5}|d|f|_ddddS#1swxYwYdS)z4Use the _current_context to set _current_context_id.Nz(insert into context (context) values (?))rYrrZrr)r*r context_idrs r5_set_context_idzCoverageData._set_context_ids'-2%%g..  !'1D $ $ $ C+.+@+@>J,,(                  sA((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_filenamerr: line_data!Mapping[str, Collection[TLineNo]]c H|jdrU|jdt|t d|Dfz||d|sdS|5}| | D]\}}t|}| |d}d}| |||jf5}t|} dddn #1swxYwY| rt!|| d d }|d ||j|f ddddS#1swxYwYdS) zAdd measured line data. `line_data` is a dictionary mapping file names to iterables of ints:: { filename: { line1, line2, ... }, ...} rz&Adding lines: %d files, %d lines totalc3NK|] }tt|V!dSN)rAr).0liness r5 z)CoverageData.add_lines..s0#U#UDU$4$4#U#U#U#U#U#Ur:TrNrzBselect numbits from line_bits where file_id = ? and context_id = ?rzQinsert or replace into line_bits (file_id, context_id, numbits) values (?, ?, ?))r0r1r2rsumrcr_choose_lines_or_arcsrritemsrrrwrZrrr) r*rrrlinenoslinemapr|queryr{existings r5 add_lineszCoverageData.add_liness? ;  h ' '  K  FI#U#U)BRBRBTBT#U#U#U U UJ     """...  F ]]__   " " "%.__%6%6  !')'22--d-;;\[[$2J(KLL)PS#CyyH)))))))))))))))E+GXa[^DDG  Gd6@                   s82A3F%E5 FE FE AFFFarc_dataMapping[str, Collection[TArc]]c zjdrUjdt|t d|Dfzd|sdS5} | D]D\}}|s |dfd|D}| d |E ddddS#1swxYwYdS) zAdd measured arc data. `arc_data` is a dictionary mapping file names to iterables of pairs of ints:: { filename: { (l1,l2), (l1,l2), ... }, ...} rz$Adding arcs: %d files, %d arcs totalc34K|]}t|VdSr)r)rarcss r5rz(CoverageData.add_arcs.. s("K"K3t99"K"K"K"K"K"Kr:TrNrc,g|]\}}j||fS)rZ)rfromnotonor|r*s r5 z)CoverageData.add_arcs..s*ccclfVZ$":FDIcccr:Qinsert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)) r0r1r2rrrcrrrrrrr)r*rrrrrr|s` @r5add_arcszCoverageData.add_arcss ;  h ' '  K  DH s"K"K9J9J"K"K"KKKH     """---  F ]]__   " " ""*.."2"2  $--d-;;ccccc^bccc$$N                   s4A.D00D47D4rrc L|s|sJ|r|rJ|rJ|jrC|jdr|jdt d|rJ|jrC|jdr|jdt d|jsv|jsq||_||_|5}|ddtt|fddddS#1swxYwYdSdSdS) z5Force the data file to choose between lines and arcs.rz: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 datarhas_arcsN) rXr0r1r2rrWrrrtrv)r*rrrs r5rz"CoverageData._choose_lines_or_arcss}#d###  ST^ S{!!(++ ` !!"^___QRR R  SDO S{!!(++ ` !!"^___QRR R~ do #DO!DN C  KSYY0                      s3DDD file_tracersMapping[str, str]c 6|jdr+|jdt|fz|sdS||5}|D]x\}}||d}||}|r+||kr$td |||^|r| d||fy ddddS#1swxYwYdS)zdAdd per-file plugin information. `file_tracers` is { filename: plugin_name, ... } rzAdding file tracers: %d filesNTr3Conflicting file tracer name for '{}': {!r} vs {!r}z2insert into tracer (file_id, tracer) values (?, ?)) r0r1r2rrrrr file_tracerrrrr)r*rrr plugin_namer|existing_plugins r5add_file_tracerszCoverageData.add_file_tracers4s ;  h ' ' V K  =\ARAR@TT U U U  F  ]]__ )5););)=)=  %+--d-;;"&"2"28"<"<" &+55'QXX (/;6 !$$L +.                   s2BDDDrrc4||g|dS)zEnsure 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*rrs r5 touch_filezCoverageData.touch_fileQs" ([11111r: filenamesCollection[str]c|jdr|jd|||5|js|jstd|D]2}||d|r| ||i3 ddddS#1swxYwYdS)zEnsure 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. rz Touching z*Can't touch files in an empty CoverageDataTrN) r0r1r2rrrXrWrrr)r*rrrs r5rzCoverageData.touch_filesYsG ;  h ' ' 9 K  7)77 8 8 8  ]]__ C C> N$/ N LMMM% C C hD 111C))8[*ABBB  C  C C C C C C C C C C C C C C C C C Cs ACCCc|jdr|jd|||5}|jrd}n|jrd}ntd|D]3}||d}|| ||f4 ddddS#1swxYwYdS) zdPurge any existing coverage data for the given `filenames`. .. versionadded:: 7.2 rzPurging data for z%delete from line_bits where file_id=?zdelete from arc where file_id=?z*Can't purge files in an empty CoverageDataFrN) r0r1r2rrrWrXrrr)r*rrsqlrr|s r5 purge_fileszCoverageData.purge_filesls< ;  h ' ' A K  ?)?? @ @ @  ]]__ 2 N= N7 LMMM% 2 2--e-<<?  wj1111  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2s ACC C  other_dataaliasesOptional[PathAliases]c  |jdr<|jdt |dd|jr|jrtd|jr|jrtdp t| | | 5}| d5}fd|Dd d d n #1swxYwY| d 5}d |D}d d d n #1swxYwY| d 5}fd |D}d d d n #1swxYwY| d5}i}|D]/\}} } || f} | |vrt|| | } | || <0 d d d n #1swxYwY| d5}fd|D} d d d n #1swxYwYd d d n #1swxYwY| 5}|jJd|j_| d5}d|D} d d d n #1swxYwY| d5}| fd|Dd d d n #1swxYwY|ddD| d5}d|Dd d d n #1swxYwY|j|dd|D| d5}d|Dd d d n #1swxYwYi}D]^}| |}| |d}|*||kr$td||||||<_fd|D}| d5}|D]<\}} } || f} | |vrt|| | } | || <= d d d n #1swxYwY|r,|d |d!||r`|d"|d#|d$fd%|D|d&fd'|Dd 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. rzUpdating 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|]\}||Srmap)rrJrs r5 z'CoverageData.update..s)DDDWdw{{400DDDr:Nzselect context from contextcg|]\}|Srrrrs r5rz'CoverageData.update..s::: G:::r:zselect 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_idc2g|]\}}}}||||fSrr)rrJrrrfiless r5rz'CoverageData.update..s>5w4['648r:zselect 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|]\}}||Srr)rrJtracerrs r5rz'CoverageData.update..s#III>D&5;IIIr: IMMEDIATEci|]\}|dSrr)rrJs r5rz'CoverageData.update..s:::UTb:::r:cBi|]\}}||Srr)rrJrrs r5rz'CoverageData.update..s;%%%$fKK%%v%%%r:z,insert or ignore into file (path) values (?)c3K|]}|fVdSrr)rfiles r5rz&CoverageData.update..s$44T$444444r:roci|]\}}|| Srr)ridrJs r5rz'CoverageData.update..s999TD"999r:z2insert or ignore into context (context) values (?)c3K|]}|fVdSrrrs r5rz&CoverageData.update..s$44'444444r:zselect id, context from contextci|]\}}|| Srr)rrrs r5rz'CoverageData.update..sBBB{r7wBBBr:rrc3FK|]\}}}}||||fVdSrr)rrrrr context_idsfile_idss r5rz&CoverageData.update..sQ/D'64$W!5vtDr:Trrrzdelete from line_bitszEinsert into line_bits (file_id, context_id, numbits) values (?, ?, ?)c>g|]\\}}}|||fSrr)rrrnumbitsr r s r5rz'CoverageData.update..sA4OT7W"$W)=wGr:z.%s2YY2B(F(8$f-YYYYYYr:)r0r1r2rrrrWrXrrrreadrrwrrisolation_levelupdaterrcrPrrrrrrHrf)r*rrrr{contextsrrrJrrkeytracers this_tracers tracer_map this_tracer other_tracerarc_rowsr r rs ` @@@r5rzCoverageData.updatesD  ;  h ' '  K  <CC K77    ? Ez3 ECDD D > Ej3 ECDD D*[]]    " ") Jc455 EDDDDDDD E E E E E E E E E E E E E E E:;; ;s::c::: ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;D  9<               J ) 68.1))*D'7 ;0Ce||"/c G"D"D!(E#JJ ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )> JIIIISIII  J J J J J J J J J J J J J J JI) J) J) J) J) J) J) J) J) J) J) J) J) J) J) JV]]___ 7&&&&1CG # 455 ;::c:::  ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;> ##%%%%(+%%%                  >44U\\^^444   899 :S99S999 : : : : : : : : : : : : : : : N ! !( + + +  D448444   >?? C3BBcBBB  C C C C C C C C C C C C C C C J  0 0*..t44 &{{444 *{l/J/J#MTT +| $0 4  37H J ) .1))*D'7";;t,,g6Ce||"/c G"D"D!(E#JJ ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ***555$$N  ***666  !8999$$F8=   NYYYYjFVFVFXFXYYY   y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ B}  KKMMM IIKKKKK  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 VJ! !V$J! %V="K+ V+K/ /V2K/ 3A V= M VM VM AV0 O = V O VO BV-AR:. V:R> >VR> CVVVparallelc||jrdS|jdr"|jd|jt |j|rtj |j\}}tj tj ||}tj |dz}tj |D]J}|jdr|jd|t |IdSdS)zErase 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`rrIrJsplitjoinrKglobescape)r*rdata_dirlocallocal_abs_pathpatternrs r5erasezCoverageData.erase-s8 =  F ;  h ' ' G K  E4>EE F F FT^$$$  ' gmmDN;;OHeW\\"'//(*C*CUKKNk.11D8G Ig.. ' ';%%h//RK%%&PH&P&PQQQX&&&& ' ' ' 'r:ctj|jr6|5d|_ddddS#1swxYwYdSdS)z"Start using an existing data file.TN)rIrJrr`rrVrls r5rzCoverageData.readCs 7>>$. ) ) ' ' '"& ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'sAAAcdS)z,Ensure the data is written to the data file.Nrrls r5r2zCoverageData.writeIs r:c|jtjkr@||tj|_|js|d|_dS)z+Call this before using the database at all.TN)rSrIrRrfrOrVr&rls r5rzCoverageData._start_usingMsc 9 # # KKMMM  ! ! # # # DI  JJLLLr:c*t|jS)z4Does the database have arcs (True) or lines (False).)rArXrls r5rzCoverageData.has_arcsXsDN###r:Set[str]c*t|jS)zA 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 r5measured_fileszCoverageData.measured_files\s4>"""r:c||5}|d5}d|D}dddn #1swxYwYdddn #1swxYwY|S)zWA set of all contexts that have been measured. .. versionadded:: 5.0 z%select distinct(context) from contextch|] }|d Srrrrxs r5 z1CoverageData.measured_contexts..ns222sCF222r:N)rrrw)r*rr{rs r5measured_contextszCoverageData.measured_contextses  ]]__ 3DEE 322c222 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 3s4A/ A A/A A/A A//A36A3c2||5}||}| ddddS|d|f}||dpdcdddS ddddS#1swxYwYdS)a Get 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)rrrrp)r*rrr|rxs r5rzCoverageData.file_tracerqs  ]]__ mmH--G        //"ORYQ[\\C1v|                           sB "B >B  BBc,||5}|d|f5}d|D|_dddn #1swxYwYddddS#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 rcg|] }|d Sr1rr2s r5rz2CoverageData.set_query_context..s*L*L*Lc3q6*L*L*Lr:N)rrrwfetchallr[)r*rrr{s r5set_query_contextzCoverageData.set_query_contexts0  ]]__ MG'TT MX[*L*LS\\^^*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 Ms5B $A1% B 1A5 5B 8A5 9B  B B rOptional[Sequence[str]]c||r|5}ddgt|z}|d|z|5}d|D|_dddn #1swxYwYddddS#1swxYwYdSd|_dS)aSet 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 `. 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 cg|] }|d Sr1rr2s r5rz3CoverageData.set_query_contexts..s.P.P.P#s1v.P.P.Pr:N)rrrrrwr8r[)r*rrcontext_clauser{s r5set_query_contextszCoverageData.set_query_contextssl   + QC!'.@-ACMM-Q!R!R[[!@>!QS[\\Q`c.P.P.P.P.PD+QQQQQQQQQQQQQQQ Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q '+D # # #s6AB3+$B B3B B3"B #B33B7:B7Optional[List[TLineNo]]c:||rO||}|8tj|}t d|DS|5}||}| ddddSd}|g}|j ?d dt|j z}|d|zdzz }||j z }| ||5} t | } dddn #1swxYwYt} | D]*} | t| d+t | cdddS#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. Nch|] }|dk| Sr1r)rls r5r3z%CoverageData.lines..s;;;1QUUQUUUr:z/select numbits from line_bits where file_id = ?, ? and context_id in ()r)rrr itertoolschain from_iterablerrrr[rrrwr-rr) r*rr all_linesrr|rr ids_arrayr{bitmapsnumsrxs r5rzCoverageData.liness-  ==?? =99X&&D%O99$?? ;; ;;;<<< ]]__ "mmH--G " " " " " " " " Jy*6 $ #D4K0L0L*L M MI3i?#EEED33D[[--("3iiG(((((((((((((((uu"99CKKA 7 78888Dzz! " " " " " " " " " " " " " " " " " "s> F2A!FD/# F/D3 3F6D3 7A FFFOptional[List[TArc]]c||5}||}| ddddSd}|g}|j?ddt |jz}|d|zdzz }||jz }|||5}t|cdddcdddS#1swxYwY ddddS#1swxYwYdS)aGet 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)rrrr[rrrwr)r*rrr|rrrKr{s r5rzCoverageData.arcss"  ]]__ %mmH--G % % % % % % % % Ry*6 $ #D4K0L0L*L M MI3i?#EEED33D[[--%99%%%%%%% % % % % % % % %%%%%%%%%% % % % % % % % % % % % % % % % % % %s<C1A!C10C? C1C C1C C11C58C5Dict[TLineNo, List[str]]cL||5}||}|icdddStjt }|rd}|g}|j?ddt|jz}|d|zdzz }||jz }| ||5}|D]H\} } } | dkr||  | | dkr||  | I dddn #1swxYwYnd}|g}|j?ddt|jz}|d |zdzz }||jz }| ||5}|D]2\} } t| D]} ||  | 3 dddn #1swxYwYdddn #1swxYwYd | DS) zGet 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 (c4i|]\}}|t|Sr)r)rlinenors r5rz3CoverageData.contexts_by_lineno..s%[[[+;68X[[[r:)rrr collections defaultdictr-rr[rrrwrrr)r*rrr|lineno_contexts_maprrrKr{rrrrrSs r5contexts_by_linenozCoverageData.contexts_by_linenos  ]]__% EmmH--G% E% E% E% E% E% E% E% E #."9#">"> }} EL  y*6 $ #D4K0L0L*L M MI7)CcIIED33D[[--C14CC-g!A::/7;;GDDD!88/599'BBB CCCCCCCCCCCCCCCC&  y*6 $ #D4K0L0L*L M MI5 ACGGED33D[[--E,/EE(&5g&>&>EEF/7;;GDDDDEEEEEEEEEEEEEEEEEE% E% E% E% E% E% E% E% E% E% E% E% E% E% E% EN\[?R?X?X?Z?Z[[[[sbG=BG=A D6* G=6D: :G==D: >A%G=#6G& G=&G* *G=-G* .G==HHList[Tuple[str, Any]]ctdt5}|d5}d|D}dddn #1swxYwY|d5}d|D}dddn #1swxYwYtjd|d }dddn #1swxYwYd t jfd |fd |fgS)zaOur information for `Coverage.sys_info`. Returns a list of (key, value) pairs. r^)rDzpragma temp_storecg|] }|d Sr1rr2s r5rz)CoverageData.sys_info..'s444c!f444r:Nzpragma compile_optionscg|] }|d Sr1rr2s r5rz)CoverageData.sys_info..)s///CQ///r:rCK)widthsqlite3_sqlite_versionsqlite3_temp_storesqlite3_compile_options)rirrwtextwrapwraprsqlite3sqlite_version)clsrer{ temp_storecoptss r5sys_infozCoverageData.sys_infosj 6 6 6 >"/00 5C44444  5 5 5 5 5 5 5 5 5 5 5 5 5 5 5455 0//3/// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0M$))E"2"2"===E  > > > > > > > > > > > > > > >&w'= > !: . & .  sXC A  C A CA C- B: CB C B ,CC  C )NNFNN) r<r=r>r?r@rArBrCrDrEr(rFr(rF)rerir(rFr(ri)r(rA)r(r)rrr(rF)F)rrtrrAr(r)rrtr(r)rrr(rFr(rt)rrr(rF)rrr(rF)FF)rrArrAr(rF)rrr(rFr)rrtrrtr(rFr)rrrrr(rF)rrr(rF)rr+rrr(rF)rrAr(rF)r(r+)rrtr(r)rrtr(rF)rr:r(rF)rrtr(r?)rrtr(rN)rrtr(rP)r(rX),r4 __module__ __qualname____doc__r\rOrfrmrkrurrrrrrr9rrrrrrrrrrrrr&rr2rrr.r4rr9r>rrrW classmethodrhrr:r5r+r+sRRl(,-1"&%) -<-<-<-<-<^////((((3333B````&0000 @@@@.8 , , , , ,      ( ( ( W (      WB  W<*  W822222CCCCC&22220gggggR''''',''''         $$$$####    $MMMM ++++*!"!"!"!"F%%%%@1\1\1\1\f   [   r:r+r>Union[str, bool, None]Union[str, None]c|duretjtjddd}dt jtj|fz}n|durd}|S)zCompute 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. Tri?Bz %s.%s.%06dFN)randomRandomrIurandomrandintsocket gethostnamerR)r>dices r5rara3sk~~ }RZ]]++33Av>>!3!5!5ry{{D II 5 Mr:ceZdZdZd"dZd#d Zd#d Zd$d Zd#d Zd%dZ e j d&d'dZ d&d(dZ d&d)dZd&d*dZd+dZd,dZd-dZd.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,)) rrtrDr r(rFc>||_||_d|_d|_dS)Nr)rDrnestr)r*rrDs r5r\zSqliteDb.__init__Ss"    15r:c|jdS|jdr"|jd|j t j|jd|_n2#t j$r }td|jd||d}~wwxYw|j dd d | d | d dS) z2Connect to the db and do universal initialization.NrzConnecting to F)check_same_threadCouldn't use data file : REGEXPc0tj||duSr)research)txtpats r5z#SqliteDb._connect..jsryc?R?RZ^?^r:zpragma journal_mode=offzpragma synchronous=off) rrDr1r2rrcconnectErrorrcreate_functionr)r*rzs r5rzSqliteDb._connectYs 8  F :  U # # A J  ?dm?? @ @ @ Yt}NNNDHH} Y Y YNdmNNNNOOUX X Y   1.^.^___ 3444 233333s A((B7BBcr|j-|jdkr$|jd|_dSdSdS)z If needed, close the connection.Nr^)rrrdrls r5rdzSqliteDb.closessA 8 DMZ$?$? HNN   DHHH $?$?r:c|jdkr6||jJ|j|xjdz c_|S)Nrr)r}rr __enter__rls r5rzSqliteDb.__enter__ysP 9>> MMOOO8''' H    Q  r:c||xjdzc_|jdkr |jJ|j||||dS#t$rW}|jdr|jd|td|j d||d}~wwxYwdS)NrrrzEXCEPTION from __exit__: zCouldn't end data file r) r}r__exit__rdrsrDr1r2rr)r*exc_type exc_value tracebackrzs r5rzSqliteDb.__exit__s Q 9>> ]x+++!!(IyAAA  ] ] ]:$$U++HJ$$%F%F%FGGG R$- R RS R RSSY\\ ] >s9A B9"AB44B9r parameters Iterable[Any]sqlite3.Cursorc|jdr(|rd|nd}|jd|| |jJ |j||S#t $r|j||cYSwxYw#t j$r}t|} t|j d5}d}| t||krd}dddn #1swxYwYn#t $rYnwxYw|jdr|jd |td |j d ||d}~wwxYw) z2Same as :meth:`python:sqlite3.Connection.execute`.r with rz Executing Nrbs&!coverage.py: This is a private formatzILooks like a coverage 4.x data file. Are you mixing versions of coverage?zEXCEPTION from execute: rr)rDr1r2rrwrsrcrrtopenrrrr)r*rrtailrzmsgbad_filecov4_sigs r5_executezSqliteDb._executes  :  U # # 9.8@*J***bD J  7#777 8 8 8 Y8''' 9x''Z888 9 9 9x''Z88888  9 } Y Y Yc((C $-..(HH}}S]]33x??C    z  '' C   !AC!A!ABBBNdmNNNNOOUX X! Ys BA))%BBBBE2#E-3D +C?3 D ?D D D D  E- DE-DAE--E2rIterator[sqlite3.Cursor]c#K|||} |V|dS#|wxYw)zContext managed :meth:`python:sqlite3.Connection.execute`. Use with a ``with`` statement to auto-close the returned cursor. Nrrd)r*rrr{s r5rwzSqliteDb.executesLmmC,, III IIKKKKKCIIKKKKs 4A cV|||dS)zQSame as :meth:`python:sqlite3.Connection.execute` when you don't need the cursor.Nr)r*rrs r5rzSqliteDb.execute_voids( c:&&,,.....r:rvc|||5}|jJ|j}dddn #1swxYwY|jdr|jd||S)z(Like execute, but returns the lastrowid.NsqldatazRow id result: )rw lastrowidrDr1r2)r*rrr{rowids r5rzSqliteDb.execute_for_rowids \\#z * * 'c=,,,E ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' :  Y ' ' : J  8u88 9 9 9 s 488Optional[Tuple[Any, ...]]cb|||5}t|}dddn #1swxYwYt|dkrdSt|dkr(ttt df|dSt 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)rwrrrrrAssertionError)r*rrr{rowss r5rpzSqliteDb.execute_ones\\#z * * c99D                t99>>4 YY!^^c3ha11 1 !Q!Q!QT!Q!Q!QRR Rs 377r List[Any]c|jdr|jdrdnd}|jd|dt|d||jdr5t |D]%\}}|j|dd |&|jJ |j||S#t$r|j||cYSwxYw) z6Same as :meth:`python:sqlite3.Connection.executemany`.rr:rzExecuting many rr4dr)rDr1r2r enumerater executemanyrs)r*rrfinalirxs r5 _executemanyzSqliteDb._executemanys. :  U # # 9:,,Y77?CCRE J  SsSSCIISSESS T T Tz  ++ 9'oo99FAsJ$$%7%7%7%7%78888x### 38''T22 2 3 3 38''T22 2 2 2  3sC%DDc|t|}|r*|||dSdS)zUSame as :meth:`python:sqlite3.Connection.executemany` when you don't need the cursor.N)rrrd)r*rrs r5rzSqliteDb.executemany_voidsGDzz  1   c4 ( ( . . 0 0 0 0 0 1 1r:rc 6|jdrI|jdt |t |d|jJ|j|dS)z8Same as :meth:`python:sqlite3.Connection.executescript`.rz"Executing script with {} chars: {}dN) rDr1r2rrrrrrrd)r*rs r5rzSqliteDb.executescripts :  U # #  J  AHHF \&#66   x### v&&,,.....r:cl|jJd|jS)z9Return a multi-line string, the SQL dump of the database.N )rriterdumprls r5rz SqliteDb.dumps0x###yy**,,---r:N)rrtrDr r(rFrirj)rrtrrr(r)r)rrtrrr(r)rrtrrr(rF)rrtrrr(rv)rrtrrr(r)rrtrrr(r)rrtrrr(rF)rrtr(rFrk)r4rlrmrnr\rrdrrr contextlibcontextmanagerrwrrrprrrrrr:r5ririIsm6666 44444  ] ] ] ]YYYY@%'     /////SSSSS$3333"1111 ////......r:ri)r'r%r(r%)r>rpr(rq)Arn __future__rrTrrr7r rGrIrtrrxrcrrarTrtypingrrrrrr r r r r rrrrrcoverage.debugrrrcoverage.exceptionsrrcoverage.filesr coverage.miscrrcoverage.numbitsrrrcoverage.typesrrr r!r"coverage.versionr#rqrr%r9r+rarirr:r5rs""""""     DCCCCCCCCC<<<<<<<<&&&&&&66666666LLLLLLLLLLFFFFFFFFFFFFFF((((((^B < | ')8CH#5 6 6 6    n n n n n =n n n b,v.v.v.v.v.}v.v.v.v.v.r: