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

cÞç;éb­ã@sÊdZddlZddlmZddlmZmZdd„Zeddd	„ƒed
dddd
„ƒZeddddd„ƒZ	edddddd„ƒZ
edddddd„ƒZedddddd„ƒZedddddd„ƒZ
dd„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)Úzip_longest)ÚcontractÚnew_contractcCs|S)z?Convert a bytestring into a type SQLite will accept for a blob.©)Úbrrú/build/wlanpi-profiler-7IIg1Q/wlanpi-profiler-1.0.11/debian/wlanpi-profiler/opt/wlanpi-profiler/lib/python3.7/site-packages/coverage/numbits.pyÚ_to_blobsrZblobcCs
t|tƒS)N)Ú
isinstanceÚbytes)ÚvrrrÚ<lambda>ó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ÚnumrrrÚnums_to_numbitss


 rz	list[int])ÚnumbitsrcCsNg}xDt|ƒ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)Ú	enumerateÚrangeÚappend)rrZbyte_iÚbyteZbit_irrrÚnumbits_to_nums2sr)Únumbits1Únumbits2rcCs$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Úb2rrrú	<genexpr>Psz numbits_union.<locals>.<genexpr>)rrr
)rr Ú
byte_pairsrrrÚ
numbits_unionHsr'cCs.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$rrrr%[sz'numbits_intersection.<locals>.<genexpr>ó)rr
rÚrstrip)rr r&Zintersection_bytesrrrÚnumbits_intersectionSsr*ÚboolcCs 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$rrrr%jsz+numbits_any_intersection.<locals>.<genexpr>)rÚany)rr r&rrrÚnumbits_any_intersection_s
r-Úint)rrrcCs2t|dƒ\}}|t|ƒkrdSt||d|>@ƒS)zvDoes the integer `num` appear in `numbits`?

    Returns:
        A bool, True if `num` is a member of `numbits`.
    rFr)ÚdivmodÚlenr+)rrZnbyteZnbitrrrÚnum_in_numbitsmsr1cCsN| 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*r-r1rrcSst t|ƒ¡S)N)ÚjsonÚdumpsr)rrrrrœr
z+register_sqlite_functions.<locals>.<lambda>N)Zcreate_functionr'r*r-r1)Ú
connectionrrrÚregister_sqlite_functionszs
r6)Ú__doc__r3Ú	itertoolsrZ
coverage.miscrrrrrr'r*r-r1r6rrrrÚ<module>s