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

Ò÷ií¿\sÆã@sdZddlZddlmZddlmZmZmZmZddl	m
Z
mZejr^dd„Z
edd	d
„ƒndd„Z
eddd
„ƒe
d
dddd„ƒZe
ddddd„ƒZe
dddddd„ƒZe
dddddd„ƒZe
dddddd„ƒZe
dddddd „ƒZd!d"„ZdS)#aÒ
Functions to manipulate packed binary representations of number sets.

To save space, coverage stores sets of line numbers in SQLite using a packed
binary representation called a numbits.  A numbits is a set of positive
integers.

A numbits is stored as a blob in the database.  The exact meaning of the bytes
in the blobs should be considered an implementation detail that might change in
the future.  Use these functions to work with those binary blobs of data.

éN)Úenv)Úbyte_to_intÚ
bytes_to_intsÚbinary_bytesÚzip_longest)ÚcontractÚnew_contractcCs|S)z?Convert a bytestring into a type SQLite will accept for a blob.©)Úbr	r	úŽ/build/wlanpi-profiler-MIf3Xw/wlanpi-profiler-1.0.8/debian/wlanpi-profiler/opt/wlanpi-profiler/lib/python3.7/site-packages/coverage/numbits.pyÚ_to_blobsrZblobcCs
t|tƒS)N)Ú
isinstanceÚbytes)Úvr	r	rÚ<lambda>órcCst|ƒS)z?Convert a bytestring into a type SQLite will accept for a blob.)Úbuffer)r
r	r	rrscCs
t|tƒS)N)r
r)rr	r	rr!rÚIterable)ÚnumsÚreturnscCslyt|ƒdd}Wntk
r,tdƒSXt|ƒ}x(|D] }||dd|d>O<q<Wtt|ƒƒS)z¢Convert `nums` into a numbits.

    Arguments:
        nums: a reusable iterable of integers, the line numbers to store.

    Returns:
        A binary blob.
    éér)ÚmaxÚ
ValueErrorrÚ	bytearrayr)rÚnbytesr
Únumr	r	rÚnums_to_numbits$s


 rz	list[int])ÚnumbitsrcCsRg}xHtt|ƒƒD]8\}}x.tdƒD]"}|d|>@r$| |d|¡q$WqW|S)a$Convert a numbits into a list of numbers.

    Arguments:
        numbits: a binary blob, the packed number set.

    Returns:
        A list of ints.

    When registered as a SQLite function by :func:`register_sqlite_functions`,
    this returns a string, a JSON-encoded list of ints.

    rr)Ú	enumeraterÚrangeÚappend)rrZbyte_iÚbyteZbit_ir	r	rÚnumbits_to_nums9sr#)Únumbits1Únumbits2rcCs,tt|ƒt|ƒdd}ttdd„|DƒƒƒS)zsCompute the union of two numbits.

    Returns:
        A new numbits, the union of `numbits1` and `numbits2`.
    r)Ú	fillvaluecss|]\}}||BVqdS)Nr	)Ú.0Úb1Úb2r	r	rú	<genexpr>Wsz numbits_union.<locals>.<genexpr>)rrrr)r$r%Ú
byte_pairsr	r	rÚ
numbits_unionOsr,cCs6tt|ƒt|ƒdd}tdd„|Dƒƒ}t| d¡ƒS)z~Compute the intersection of two numbits.

    Returns:
        A new numbits, the intersection `numbits1` and `numbits2`.
    r)r&css|]\}}||@VqdS)Nr	)r'r(r)r	r	rr*bsz'numbits_intersection.<locals>.<genexpr>ó)rrrrÚrstrip)r$r%r+Zintersection_bytesr	r	rÚnumbits_intersectionZsr/ÚboolcCs(tt|ƒt|ƒdd}tdd„|DƒƒS)a
Is there any number that appears in both numbits?

    Determine whether two number sets have a non-empty intersection. This is
    faster than computing the intersection.

    Returns:
        A bool, True if there is any number in both `numbits1` and `numbits2`.
    r)r&css|]\}}||@VqdS)Nr	)r'r(r)r	r	rr*qsz+numbits_any_intersection.<locals>.<genexpr>)rrÚany)r$r%r+r	r	rÚnumbits_any_intersectionfs
r2Úint)rrrcCs6t|dƒ\}}|t|ƒkrdStt||ƒd|>@ƒS)zvDoes the integer `num` appear in `numbits`?

    Returns:
        A bool, True if `num` is a member of `numbits`.
    rFr)ÚdivmodÚlenr0r)rrZnbyteZnbitr	r	rÚnum_in_numbitstsr6cCsN| ddt¡| ddt¡| ddt¡| ddt¡| dddd	„¡d
S)aÒ
    Define numbits functions in a SQLite connection.

    This defines these functions for use in SQLite statements:

    * :func:`numbits_union`
    * :func:`numbits_intersection`
    * :func:`numbits_any_intersection`
    * :func:`num_in_numbits`
    * :func:`numbits_to_nums`

    `connection` is a :class:`sqlite3.Connection <python:sqlite3.Connection>`
    object.  After creating the connection, pass it to this function to
    register the numbits functions.  Then you can use numbits functions in your
    queries::

        import sqlite3
        from coverage.numbits import register_sqlite_functions

        conn = sqlite3.connect('example.db')
        register_sqlite_functions(conn)
        c = conn.cursor()
        # Kind of a nonsense query: find all the files and contexts that
        # executed line 47 in any file:
        c.execute(
            "select file_id, context_id from line_bits where num_in_numbits(?, numbits)",
            (47,)
        )
    r,ér/r2r6r#rcSst t|ƒ¡S)N)ÚjsonÚdumpsr#)r
r	r	rr£rz+register_sqlite_functions.<locals>.<lambda>N)Zcreate_functionr,r/r2r6)Ú
connectionr	r	rÚregister_sqlite_functionss
r;)Ú__doc__r8ZcoveragerZcoverage.backwardrrrrZ
coverage.miscrrÚPY3rrr#r,r/r2r6r;r	r	r	rÚ<module>s