
    =wgH                        d dl mZ d dlZd dlZd dlZd dlmZmZ d dlm	Z	 d dl
mZ dZ eed      rej                  Zn(ej                   dk(  rej"                  Znej                  Zdd	Zdd
Zd Zd Zi Zd Zd Zd Zy)    )with_statementN)insortbisect_leftwraps)xrange$0123456789abcdefghijklmnopqrstuvwxyzperf_counterwin32c                 D    dj                  d t        |       D              S )N c              3   N   K   | ]  }t        j                  t                y wN)randomchoiceIDCHARS.0_s     K/var/www/horilla/myenv/lib/python3.12/site-packages/whoosh/util/__init__.py	<genexpr>zrandom_name.<locals>.<genexpr>1   s     @a6==)@s   #%)joinr   )sizes    r   random_namer   0   s    77@6$<@@@    c                     d t        |       D        }t        j                  d   dk\  rt        |      S t	        d|      j                         S )Nc              3   H   K   | ]  }t        j                  d d        yw)r      N)r   randintr   s     r   r   zrandom_bytes.<locals>.<genexpr>5   s     
8a6>>!S!
8s    "r      B)r   sysversion_infobytesarraytostring)r   gens     r   random_bytesr(   4   sB    
86$<
8C
aSzS#''))r   c           	          t        |      }|st        d      |dk(  r|d   S |dz  } | t        | |d| fi |t        | ||d fi |fi |S )ak  Takes a function/class that takes two positional arguments and a list of
    arguments and returns a binary tree of results/instances.

    >>> make_binary_tree(UnionMatcher, [matcher1, matcher2, matcher3])
    UnionMatcher(matcher1, UnionMatcher(matcher2, matcher3))

    Any keyword arguments given to this function are passed to the class
    initializer.
    z'Called make_binary_tree with empty list   r      N)len
ValueErrormake_binary_tree)fnargskwargscounthalfs        r   r.   r.   <   sw     IEBCC	!AwA:Dr4;9&9r4;9&9E=CE Er   c           	         |st        d      |j                          t        |      dkD  rU|j                  d      }|j                  d      }t	        ||d   |d   z    | |d   |d         f       t        |      dkD  rU|d   d   S )zTakes a function/class that takes two positional arguments and a list of
    (weight, argument) tuples and returns a huffman-like weighted tree of
    results/instances.
    z)Called make_weighted_tree with empty listr*   r   )r-   sortr,   popr   )r/   lsr1   abs        r   make_weighted_treer:   R   s     DEEGGI
b'A+FF1IFF1IrAaD1Q4KAaD!A$01 b'A+ a58Or   c                     | dk  r| S | t         v r	t         |    S t        | dz
        t        | dz
        z   }|t         | <   |S )z5Returns the nth value in the Fibonacci sequence.
    r+   r*   )
_fib_cachefib)nresults     r   r=   r=   h   sI     	AvJ!}QZ#a!e*$FJqMMr   c                 .     t                fd       }|S )zDecorator for storage-access methods, which synchronizes on a threading
    lock. The parent object must have 'is_closed' and '_sync_lock' attributes.
    c                 `    | j                   5   | g|i |cd d d        S # 1 sw Y   y xY wr   )
_sync_lock)selfr0   r1   funcs      r   synchronized_wrapperz*synchronized.<locals>.synchronized_wrapper|   s1    __ 	/.t.v.	/ 	/ 	/s   $-r   )rD   rE   s   ` r   synchronizedrF   w   s#    
 4[/ /  r   c                 .     t                fd       }|S )z5
    Decorator to check if the object is closed.
    c                 J    | j                   rt        d       | g|i |S )NzOperation on a closed object)closedr-   )rC   r0   r1   methods      r   unclosed_wrapperz"unclosed.<locals>.unclosed_wrapper   s+    ;;;<<d,T,V,,r   r   )rJ   rK   s   ` r   unclosedrL      s#    
 6]- - r   )   )
__future__r   r   r"   timebisectr   r   	functoolsr   whoosh.compatr   r   hasattrr
   nowplatformclockr   r(   r.   r:   r<   r=   rF   rL    r   r   <module>rX      s   8 &   &    1 4 


C\\W
**C
))CA*E,& 


 
r   