CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
_main.cpython-310.pyc347 linesDownload Raw Back to __pycache__
1o

2��Yi���@sdZgd�ZdZ		d9dd�Z		d9dd	�Z		d9d3d�Z		d:dd
�Z		d:dd�Z		d:dd�Z		d:dd�Z			d;dd�Z4		d;dd�Z		d9dd�Z		d<dd�Z
d=dd�Zdd�Zd ad>d!d"�Zd?d#d$�Zd@d%d&�Zdd'lmZdd(lmZdd)lmZdd*lmZdd+lTdd,lmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)dd-lm*Z+m,Z-m.Z/m0Z1m2Z3e4j5a6e7d.�Z8t6e_6iZ9e�Z:iZ;iZ<iZ=d/Z>d/Z?d0d1�Z@d2d3�ZAe@d4ddid�ZBeCeB�ZDeCeB�d4��ZE[Be�Fd5�e�Fd6�eZGddlHZId7d8�ZJeI�KeDeJ�dS)Aa�/Support for regular expressions (RE).5 6This module provides regular expression matching operations similar to those7found in Perl. It supports both 8-bit and Unicode strings; both the pattern and8the strings being processed can contain null bytes and characters outside the9US ASCII range.10 11Regular expressions can contain both special and ordinary characters. Most12ordinary characters, like "A", "a", or "0", are the simplest regular13expressions; they simply match themselves. You can concatenate ordinary14characters, so last matches the string 'last'.15 16There are a few differences between the old (legacy) behaviour and the new17(enhanced) behaviour, which are indicated by VERSION0 or VERSION1.18 19The special characters are:20    "."                 Matches any character except a newline.21    "^"                 Matches the start of the string.22    "$"                 Matches the end of the string or just before the23                        newline at the end of the string.24    "*"                 Matches 0 or more (greedy) repetitions of the preceding25                        RE. Greedy means that it will match as many repetitions26                        as possible.27    "+"                 Matches 1 or more (greedy) repetitions of the preceding28                        RE.29    "?"                 Matches 0 or 1 (greedy) of the preceding RE.30    *?,+?,??            Non-greedy versions of the previous three special31                        characters.32    *+,++,?+            Possessive versions of the previous three special33                        characters.34    {m,n}               Matches from m to n repetitions of the preceding RE.35    {m,n}?              Non-greedy version of the above.36    {m,n}+              Possessive version of the above.37    {...}               Fuzzy matching constraints.38    "\\"                Either escapes special characters or signals a special39                        sequence.40    [...]               Indicates a set of characters. A "^" as the first41                        character indicates a complementing set.42    "|"                 A|B, creates an RE that will match either A or B.43    (...)               Matches the RE inside the parentheses. The contents are44                        captured and can be retrieved or matched later in the45                        string.46    (?flags-flags)      VERSION1: Sets/clears the flags for the remainder of47                        the group or pattern; VERSION0: Sets the flags for the48                        entire pattern.49    (?:...)             Non-capturing version of regular parentheses.50    (?>...)             Atomic non-capturing version of regular parentheses.51    (?flags-flags:...)  Non-capturing version of regular parentheses with local52                        flags.53    (?P<name>...)       The substring matched by the group is accessible by54                        name.55    (?<name>...)        The substring matched by the group is accessible by56                        name.57    (?P=name)           Matches the text matched earlier by the group named58                        name.59    (?#...)             A comment; ignored.60    (?=...)             Matches if ... matches next, but doesn't consume the61                        string.62    (?!...)             Matches if ... doesn't match next.63    (?<=...)            Matches if preceded by ....64    (?<!...)            Matches if not preceded by ....65    (?(id)yes|no)       Matches yes pattern if group id matched, the (optional)66                        no pattern otherwise.67    (?(DEFINE)...)      If there's no group called "DEFINE", then ... will be68                        ignored, but any group definitions will be available.69    (?|...|...)         (?|A|B), creates an RE that will match either A or B,70                        but reuses capture group numbers across the71                        alternatives.72    (*FAIL)             Forces matching to fail, which means immediate73                        backtracking.74    (*F)                Abbreviation for (*FAIL).75    (*PRUNE)            Discards the current backtracking information. Its76                        effect doesn't extend outside an atomic group or a77                        lookaround.78    (*SKIP)             Similar to (*PRUNE), except that it also sets where in79                        the text the next attempt at matching the entire80                        pattern will start. Its effect doesn't extend outside81                        an atomic group or a lookaround.82 83The fuzzy matching constraints are: "i" to permit insertions, "d" to permit84deletions, "s" to permit substitutions, "e" to permit any of these. Limits are85optional with "<=" and "<". If any type of error is provided then any type not86provided is not permitted.87 88A cost equation may be provided.89 90Examples:91    (?:fuzzy){i<=2}92    (?:fuzzy){i<=1,s<=2,d<=1,1i+1s+1d<3}93 94VERSION1: Set operators are supported, and a set can include nested sets. The95set operators, in order of increasing precedence, are:96    ||  Set union ("x||y" means "x or y").97    ~~  (double tilde) Symmetric set difference ("x~~y" means "x or y, but not98        both").99    &&  Set intersection ("x&&y" means "x and y").100    --  (double dash) Set difference ("x--y" means "x but not y").101 102Implicit union, ie, simple juxtaposition like in [ab], has the highest103precedence.104 105VERSION0 and VERSION1:106The special sequences consist of "\\" and a character from the list below. If107the ordinary character is not on the list, then the resulting RE will match the108second character.109    \number         Matches the contents of the group of the same number if110                    number is no more than 2 digits, otherwise the character111                    with the 3-digit octal code.112    \a              Matches the bell character.113    \A              Matches only at the start of the string.114    \b              Matches the empty string, but only at the start or end of a115                    word.116    \B              Matches the empty string, but not at the start or end of a117                    word.118    \d              Matches any decimal digit; equivalent to the set [0-9] when119                    matching a bytestring or a Unicode string with the ASCII120                    flag, or the whole range of Unicode digits when matching a121                    Unicode string.122    \D              Matches any non-digit character; equivalent to [^\d].123    \f              Matches the formfeed character.124    \g<name>        Matches the text matched by the group named name.125    \G              Matches the empty string, but only at the position where126                    the search started.127    \h              Matches horizontal whitespace.128    \K              Keeps only what follows for the entire match.129    \L<name>        Named list. The list is provided as a keyword argument.130    \m              Matches the empty string, but only at the start of a word.131    \M              Matches the empty string, but only at the end of a word.132    \n              Matches the newline character.133    \N{name}        Matches the named character.134    \p{name=value}  Matches the character if its property has the specified135                    value.136    \P{name=value}  Matches the character if its property hasn't the specified137                    value.138    \r              Matches the carriage-return character.139    \s              Matches any whitespace character; equivalent to140                    [ \t\n\r\f\v].141    \S              Matches any non-whitespace character; equivalent to [^\s].142    \t              Matches the tab character.143    \uXXXX          Matches the Unicode codepoint with 4-digit hex code XXXX.144    \UXXXXXXXX      Matches the Unicode codepoint with 8-digit hex code145                    XXXXXXXX.146    \v              Matches the vertical tab character.147    \w              Matches any alphanumeric character; equivalent to148                    [a-zA-Z0-9_] when matching a bytestring or a Unicode string149                    with the ASCII flag, or the whole range of Unicode150                    alphanumeric characters (letters plus digits plus151                    underscore) when matching a Unicode string. With LOCALE, it152                    will match the set [0-9_] plus characters defined as153                    letters for the current locale.154    \W              Matches the complement of \w; equivalent to [^\w].155    \xXX            Matches the character with 2-digit hex code XX.156    \X              Matches a grapheme.157    \Z              Matches only at the end of the string.158    \\              Matches a literal backslash.159 160This module exports the following functions:161    match      Match a regular expression pattern at the beginning of a string.162    fullmatch  Match a regular expression pattern against all of a string.163    search     Search a string for the presence of a pattern.164    sub        Substitute occurrences of a pattern found in a string using a165               template string.166    subf       Substitute occurrences of a pattern found in a string using a167               format string.168    subn       Same as sub, but also return the number of substitutions made.169    subfn      Same as subf, but also return the number of substitutions made.170    split      Split a string by the occurrences of a pattern. VERSION1: will171               split at zero-width match; VERSION0: won't split at zero-width172               match.173    splititer  Return an iterator yielding the parts of a split string.174    findall    Find all occurrences of a pattern in a string.175    finditer   Return an iterator yielding a match object for each match.176    compile    Compile a pattern into a Pattern object.177    purge      Clear the regular expression cache.178    escape     Backslash all non-alphanumerics or special characters in a179               string.180 181Most of the functions support a concurrent parameter: if True, the GIL will be182released during matching, allowing other Python threads to run concurrently. If183the string changes during matching, the behaviour is undefined. This parameter184is not needed when working on the builtin (immutable) string classes.185 186Some of the functions in this module take flags as optional parameters. Most of187these flags can also be set within an RE:188    A   a   ASCII         Make \w, \W, \b, \B, \d, and \D match the189                          corresponding ASCII character categories. Default190                          when matching a bytestring.191    B   b   BESTMATCH     Find the best fuzzy match (default is first).192    D       DEBUG         Print the parsed pattern.193    E   e   ENHANCEMATCH  Attempt to improve the fit after finding the first194                          fuzzy match.195    F   f   FULLCASE      Use full case-folding when performing196                          case-insensitive matching in Unicode.197    I   i   IGNORECASE    Perform case-insensitive matching.198    L   L   LOCALE        Make \w, \W, \b, \B, \d, and \D dependent on the199                          current locale. (One byte per character only.)200    M   m   MULTILINE     "^" matches the beginning of lines (after a newline)201                          as well as the string. "$" matches the end of lines202                          (before a newline) as well as the end of the string.203    P   p   POSIX         Perform POSIX-standard matching (leftmost longest).204    R   r   REVERSE       Searches backwards.205    S   s   DOTALL        "." matches any character at all, including the206                          newline.207    U   u   UNICODE       Make \w, \W, \b, \B, \d, and \D dependent on the208                          Unicode locale. Default when matching a Unicode209                          string.210    V0  V0  VERSION0      Turn on the old legacy behaviour.211    V1  V1  VERSION1      Turn on the new enhanced behaviour. This flag212                          includes the FULLCASE flag.213    W   w   WORD          Make \b and \B work with default Unicode word breaks214                          and make ".", "^" and "$" work with Unicode line215                          breaks.216    X   x   VERBOSE       Ignore whitespace and comments for nicer looking REs.217 218This module also defines an exception 'error'.219 220)9�	cache_all�compile�DEFAULT_VERSION�escape�findall�finditer�	fullmatch�match�purge�search�split�	splititer�sub�subf�subfn�subn�template�Scanner�A�ASCII�BZ	BESTMATCH�D�DEBUG�EZENHANCEMATCH�S�DOTALL�FZFULLCASE�I�221IGNORECASE�L�LOCALE�M�	MULTILINE�PZPOSIX�R�REVERSE�T�TEMPLATE�U�UNICODEZV0�VERSION0ZV1�VERSION1�X�VERBOSE�W�WORD�error�Regex�__version__�__doc__�	RegexFlagz	2025.11.3�NFc	K�$t||||	d�}222|223�||||||�S)zqTry to apply the pattern at the start of the string, returning a match224    object, or None if no match was found.T)�_compiler��pattern�string�flags�pos�endpos�partial�225concurrent�timeout�
ignore_unused�kwargs�pat�rC�uE:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\regex/_main.pyr��rc	Kr5)zpTry to apply the pattern against all of the string, returning a match226    object, or None if no match was found.T)r6rr7rCrCrDrrErc	Kr5)zvSearch through string looking for a match to the pattern, returning a227    match object, or None if no match was found.T)r6r228r7rCrCrDr229rEr230c231	K�&t|||	|232d�}|�|||||||�S)atReturn the string obtained by replacing the leftmost (or rightmost with a233    reverse pattern) non-overlapping occurrences of the pattern in string by the234    replacement repl. repl can be either a string or a callable; if a string,235    backslash escapes in it are processed; if a callable, it's passed the match236    object and must return a replacement string to be used.T)r6r
�r8�replr9�countr:r;r<r>r?r@rArBrCrCrDr
�r
c237	KrF)arReturn the string obtained by replacing the leftmost (or rightmost with a238    reverse pattern) non-overlapping occurrences of the pattern in string by the239    replacement format. format can be either a string or a callable; if a string,240    it's treated as a format string; if a callable, it's passed the match object241    and must return a replacement string to be used.T)r6r�r8�formatr9rIr:r;r<r>r?r@rArBrCrCrDrrJrc242	KrF)a�Return a 2-tuple containing (new_string, number). new_string is the string243    obtained by replacing the leftmost (or rightmost with a reverse pattern)244    non-overlapping occurrences of the pattern in the source string by the245    replacement repl. number is the number of substitutions that were made. repl246    can be either a string or a callable; if a string, backslash escapes in it247    are processed; if a callable, it's passed the match object and must return a248    replacement string to be used.T)r6rrGrCrCrDr"�	rc249	KrF)a�Return a 2-tuple containing (new_string, number). new_string is the string250    obtained by replacing the leftmost (or rightmost with a reverse pattern)251    non-overlapping occurrences of the pattern in the source string by the252    replacement format. number is the number of substitutions that were made. format253    can be either a string or a callable; if a string, it's treated as a format254    string; if a callable, it's passed the match object and must return a255    replacement string to be used.T)r6rrKrCrCrDr.rMrc	K� t||||d�}|�||||�S)a�Split the source string by the occurrences of the pattern, returning a256    list containing the resulting substrings.  If capturing parentheses are used257    in pattern, then the text of all groups in the pattern are also returned as258    part of the resulting list.  If maxsplit is nonzero, at most maxsplit splits259    occur, and the remainder of the string is returned as the final element of260    the list.T)r6r�	r8r9�maxsplitr:r>r?r@rArBrCrCrDr:src	KrN)z8Return an iterator yielding the parts of a split string.T)r6rrOrCrCrDrEsrc	Ks$t||||	d�}261|262�||||||�S)a'Return a list of all matches in the string. The matches may be overlapped263    if overlapped is True. If one or more groups are present in the pattern,264    return a list of groups; this will be a list of tuples if the pattern has265    more than one group. Empty matches are included in the result.T)r6r)r8r9r:r;r<�266overlappedr>r?r@rArBrCrCrDrKsrc267	Ks&t|||	|268d�}|�|||||||�S)z�Return an iterator over all matches in the string. The matches may be269    overlapped if overlapped is True. For each match, the iterator returns a270    match object. Empty matches are included in the result.T)r6r)r8r9r:r;r<rQr=r>r?r@rArBrCrCrDrTs�rcKs|durt}t|||||�S)zACompile a regular expression pattern, returning a pattern object.N)�271_cache_allr6)r8r:r@Z
cache_patternrArCrCrDr]srcCst��t��dS)z"Clear the regular expression cacheN)�_cache�clear�_locale_sensitiverCrCrCrDr	csr	TcCs|durtS|adS)z�Sets whether to cache all patterns, even those are compiled explicitly.272    Passing None has no effect, but returns the current setting.N)rR)�valuerCrCrDrksrcCst||tBdid�S)z7Compile a template pattern, returning a pattern object.F)r6r&)r8r:rCrCrDrusrcCs�t|t�r|�d�}n|}g}|r;|D]&}|dkr!|r!|�|�q|tvs)|��r4|�d�|�|�q|�|�qn%|D]"}|dkrK|rK|�|�q=|tvrU|�|�q=|�d�|�|�q=d�|�}t|t�ro|�d�}|S)z�Escape a string for use as a literal in a pattern. If special_only is273    True, escape only special characters, else escape all non-alphanumeric274    characters. If literal_spaces is True, don't escape spaces.zlatin-1� �\�)	�275isinstance�bytes�decode�append�276_METACHARS�isspace�_ALNUM�join�encode)r8Zspecial_onlyZliteral_spaces�p�s�c�rrCrCrDrys0277278�	279280281282r)�_regex_core)�_regex)�RLock)�getpreferredencoding)�*)�
_ALL_VERSIONS�_ALL_ENCODINGS�_FirstSetError�_UnscopedFlagSet�_check_group_features�_compile_firstset�_compile_replacement�
_flatten_code�283_fold_case�_get_required_string�_parse_pattern�
_shrink_cache)�ALNUM�Info�OP�Source�Fuzzyz()[]{}?*+|^$\.-#&~i�c)
s�zddlmaWn	tyYnw|t@dkrd}t|�|f}t�|d�s,|t@dkr0t�}nd}���fdd�}|r�zH|t|�|f}t	|�t284�}	�ro�D]\}285}z
|	�|286t�|287�f�WqOt
yntd�|288���w|�t|	�}	|t|�||	t|f}t|WSt
y�Ynwt|t�r�t}
nt|t�r�t}
nt|t�r�|r�td	��|Std289��tt_|}	d}zt|�}t||j���|
�_t�jt @�|_!t"|��}Wn+t#y��j$}Ynty�}z|}WYd}~nd}~ww|r�t|j%|j&|j'��q�|�(��std||j'���jt)@�pt}|dt*t+fv�r td���jt,@dtttfv�r0td
��t|t��r@�jt@�r@td���jt,@�s[t|t��rT�jtO_n�jtO_t�jt-@�}t|t.�}�j/t|<d}z	|�0||d�Wnt�y�}z|}WYd}~nd}~ww|�r�t|j%|j&|j'��|t@�r�|j1d|d�|�2�|�}|�3��}t4|�j�\}}}i}dgt5�j6�}t290���j6�7�D]/\}}|\}}t�|�}|�r�t�fdd�|D��} n|} |||<| ||<��||f��q�|�t8�|�|�9|�}!d||f}�j:�|�}"|"du�r%t;j<|"fg|!t;j=fg}!|!t;j>fg7}!�j?D]\}#}$}%|!|#�9|$|%�7}!�q/t@|!�}!|�A��sdztB�|�C|��}&t@|&�}&|&|!}!Wn291tD�ycYnwtEdd��jF�7�D��}'tG�9|�j|B|!�jF|'|||||�jH�}(t5t�tIk�r�tJ�tKtt	ttI�Wd�n	1�s�wY|�rȈjt@dk�r�d}t���|t|�|�t|f}|(t|<�t	|<|(S)z1Compiles a regular expression to a PatternObject.r4)rFTNcs@�rdSt��dd��D�}|rtt|��}td�|���dS)NcSsh|]\}}|�qSrCrC)�.0�k�vrCrCrD�	<setcomp>�sz9_compile.<locals>.complain_unused_args.<locals>.<setcomp>zunused keyword argument {!a})�set�next�iter�292ValueErrorrL)Z
unused_kwargsZany_one)�args_neededr@rArCrD�complain_unused_args�s�z&_compile.<locals>.complain_unused_argszmissing named list: {!r}z5cannot process flags argument with a compiled patternz3first argument must be a string or compiled patternzunbalanced parenthesisz5VERSION0 and VERSION1 flags are mutually incompatiblez9ASCII, LOCALE and UNICODE flags are mutually incompatiblez,cannot use UNICODE flag with a bytes pattern)�indent�reversec3s�|]}t�|�VqdS�N)rt)r}r)�inforCrD�	<genexpr>Ys�z_compile.<locals>.<genexpr>css�|]	\}}||fVqdSr�rC)r}�nrrCrCrDr��s�)L�regexr�ImportErrorr�typerU�getr�_getpreferredencoding�_named_argsr��add�	frozenset�KeyErrorr/rLrSrZ�strr(r[r�Patternr��	TypeErrorrg�_Source�_InfoZ	char_type�guess_encoding�boolr:r,Zignore_spacervro�global_flags�msgr8r;Zat_endrlr)r*rmr$�_FuzzyZ
inline_localeZ293fix_groups�dumpZoptimiseZpack_charactersru�lenZnamed_lists_used�itemsrprZ	call_refs�_OPZCALL_REF�END�SUCCESSZadditional_groupsrsZhas_simple_startrqZget_firstsetrn�dictZgroup_indexrhZgroup_count�	_MAXCACHE�_cache_lockrw))r8r:r@rAZcache_itZ294locale_keyZpattern_localer�Zargs_keyZ
args_suppliedr~rZpattern_keyr�r�Zcaught_exception�source�parsed�e�versionr�ZfuzzyZ295req_offsetZ	req_charsZ	req_flagsZnamed_listsZnamed_list_indexes�key�index�nameZ296case_flags�valuesr��code�ref�group�revZfuzZfs_code�index_groupZcompiled_patternrC)r�r@r�rArDr6�s$�297��298�299300301302303��304��305306307��308�309310311312313314315�316317���r6cCs�|j|j|f}t�|�}|dur|Stt�tkrt��t|t�}t	|�}|r,dd�}ndd�}g}g}	|��}|s<n-|dkrat318|||�\}	}319|	r[|rU|�||��g}|�|320�n
|�|321�n|�t
|��q5|rr|�||��|t|<|S)z Compiles a replacement template.NcSsd�dd�|D��S)NrYcss�|]}t|�VqdSr�)�chr)r}rerCrCrDr��s�zC_compile_replacement_helper.<locals>.make_string.<locals>.<genexpr>)ra�Z322char_codesrCrCrD�make_string�sz0_compile_replacement_helper.<locals>.make_stringcSst|�Sr�)r[r�rCrCrDr��sTrX)r8r:�_replacement_cacher�r��_MAXREPCACHErTrZr�r�rrr]�extend�ord)r8rr��compiledZ323is_unicoder�r��literal�ch�is_groupr�rCrCrD�_compile_replacement_helper�s>324325326�r�rYr��MatchcCstj|jfSr�)rhrZ
_pickled_data)r8rCrCrD�_pickle�sr�)r4NNFNNF)r4r4NNNNF)r4r4NNF)r4NNFFNNF)r4FN)T)r4)TF)Lr2�__all__r1rrr327r
rrrrrrrrr	rRrrrr�rgrh�	threadingri�_RLock�localerjr�Zregex._regex_corerlrmrnrorprqrrrsrtrurvrwrxr`ryr�rzr�r{r�r|r�r3r)rr�r^rSr�r�r�rUr�r�r6r�Z_patr�r�r�r]r0�copyregZ	_copy_regr��picklerCrCrCrD�<module>s�\	328�329�330�331�332333�334335�336�337�338�339�	340341	342343 344 345(8b5346347
Aluode/PerceptionLabPortable · CoolFace