Files
intellecton/venv/lib/python3.12/site-packages/babel/__pycache__/util.cpython-312.pyc
T

125 lines
12 KiB
Plaintext
Raw Normal View History

Ë
gÀj³$ãóB—dZddlmZddlZddlZddlZddlZddlZddlZddl m
Z
m Z ddl m
Z
mZmZddlmZmZe«Zed«Zdd„Zej.d ej0¬
«Zdd „Zej.d «Zddd
„Zdd„ZGd„dej<«Z d dd„Ze Z!Gd„dejD«Z#ejHZ$ejJZ%ejLZ&ejNZ'ejPZ(ejRZ)ejTZ*dd„Z+y)zš
babel.util
~~~~~~~~~~
Various utility classes and functions.
:copyright: (c) 2013-2026 by the Babel Team.
:license: BSD, see LICENSE for more details.
é)Ú annotationsN)Ú GeneratorÚIterable)ÚIOÚAnyÚTypeVar)ÚdatesÚ localtimeÚ_Tc#ótK—t«}t|«D]}||vsŒ|–—|j|«Œy­w)a–Yield all items in an iterable collection that are distinct.
Unlike when using sets for a similar effect, the original ordering of the
items in the collection is preserved by this function.
>>> print(list(distinct([1, 2, 1, 3, 4, 4])))
[1, 2, 3, 4]
>>> print(list(distinct('foobar')))
['f', 'o', 'b', 'a', 'r']
:param iterable: the iterable collection providing the data
N)ÚsetÚiterÚadd)ÚiterableÚseenÚitems úM/home/antigravity/intellecton/venv/lib/python3.12/site-packages/babel/util.pyÚdistinctrs:èø€ô ‹5€DÜ�X“òˆØ �tÒ ØŠJØ �H‰H�T�Nñùs‚8 8s([ \t\f]* \# .* coding[=:][ \t]*([-\w.]+))Úflagscó$—|j«}|jd« |j«}|jtj
«}|r|t
tj
«d}tj|«}|sJ ddl }|j|jd««|j«}tj|«}|rI|r4|jd«jd«}|dk7rtd|›d�«‚ |j|«y|r1|jd«jd«|j|«S |j|«y#tttf$rYŒ§wxYw#|j|«wxYw)a/Deduce the encoding of a source file from magic comment.
It does this in the same way as the `Python interpreter`__
.. __: https://docs.python.org/3.4/reference/lexical_analysis.html#encoding-declarations
The ``fp`` argument should be a seekable file object.
(From Jeff Dairiki)
rNúlatin-1ézutf-8zencoding problem: z with BOM)ÚtellÚseekÚreadlineÚ
startswithÚcodecsÚBOM_UTF8ÚlenÚPYTHON_MAGIC_COMMENT_reÚmatchÚastÚparseÚdecodeÚ ImportErrorÚ SyntaxErrorÚUnicodeEncodeErrorÚgroup)ÚfpÚposÚline1Úhas_bomÚmr"Úline2Úmagic_comment_encodings rÚparse_encodingr08sW€ð
�'‰'‹)€C؇G�GˆA„Jð!Ø— ‘ “
ˆØ×"Ñ"¤6§?¡?Ó3ˆÙ Øœ#œfŸo™oÓ.Ð0Ð1ˆEä #× )Ñ )¨%Ó 0ˆÙð
9Ûà— ‘ ˜%Ÿ,™, yÓ1Ô2🠙 ›
�Ü+×1Ñ1°%Ó8�á ÙØ)*¯©°«×):Ñ):¸9Ó)EÐ&Ø)¨WÒ4Ü%Ð(:Ð;QÐ:RÐR[Ð&\Ó]Ð]Øð �‰�� ñ Ø—7‘7˜1“:×$Ñ$ YÓ/ð �‰�� ðà
�‰�� øô+ ¤Ô.@ÐAò
ñ
ð 
ûð* �‰�� ús7£A$E<Â$E"Â,AE<Ä!E<Å"E9Å6E<Å8E9Å9E<Å<Fz'from\s+__future__\s+import\s+\(*(.+)\)*cóŒ—ddl}|j«}|jd«d} |j«j |«}t j dd|«}t j dd|«}t j dd|«}tj|«D]r}|jd «jd
«D�cgc]!}|j«jd «‘Œ#}}|D]!} t|| d«}
|
sŒ||
jz}Œ#Œt |j|«|Scc}w#|j|«wxYw) zRParse the compiler flags by :mod:`__future__` from the given Python
code.
rNzimport\s*\([\r\n]+zimport (z ,\s*[\r\n]+z, z \\\s*[\r\n]+ú rú,z())Ú
__future__rrÚreadr$ÚreÚsubÚPYTHON_FUTURE_IMPORT_reÚfinditerr(ÚsplitÚstripÚgetattrÚ
compiler_flag) r)Úencodingr4r*rÚbodyr-ÚxÚnamesÚnameÚfeatures rÚparse_future_flagsrDls€óà
�'‰'‹)€C؇G�GˆA„JØ
€EðØ�w‰w‹y×Ñ Ó)ˆô �v‰vÐ+¨Z¸Ó>ˆä�v‰v�n d¨DÓ1ˆä�v‰v�o s¨DÓ1ˆä(×1Ñ1°$Ó7ò 3ˆAØ45·G±G¸A³J×4DÑ4DÀSÓ4IÖJ¨q�Q—W‘W“Y—_‘_ TÕ*ÐJˆEÐJØò
3�Ü! *¨d°DÓ9�ÚØ˜W×2Ñ2Ñ2‘Eñ
3ñ 3ð �‰�Œ Ø €LùòKøð �‰�� ús$©BD0Ã&D+Ã-D0ÄD0Ä+D0Ä0Ecóä—dddddddœ}|jd«r dg}|d d
}n|jd «r dg}|d d
}ng}ttjd
|««D]F\}}|d zr|j ||«Œ |sŒ#|j tj
|««ŒHtj dj|«›d�|jtjd««}|d
uS)aøExtended pathname pattern matching.
This function is similar to what is provided by the ``fnmatch`` module in
the Python standard library, but:
* can match complete (relative or absolute) path names, and not just file
names, and
* also supports a convenience pattern ("**") to match files at any
directory level.
Examples:
>>> pathmatch('**.py', 'bar.py')
True
>>> pathmatch('**.py', 'foo/bar/baz.py')
True
>>> pathmatch('**.py', 'templates/index.html')
False
>>> pathmatch('./foo/**.py', 'foo/bar/baz.py')
True
>>> pathmatch('./foo/**.py', 'bar/baz.py')
False
>>> pathmatch('^foo/**.py', 'foo/bar/baz.py')
True
>>> pathmatch('^foo/**.py', 'bar/baz.py')
False
>>> pathmatch('**/templates/*.html', 'templates/index.html')
True
>>> pathmatch('**/templates/*.html', 'templates/foo/bar.html')
False
:param pattern: the glob pattern
:param filename: the path name of the file to match against
z[^/]z[^/]/z[^/]+z[^/]+/z (?:.+/)*?z(?:.+/)*?[^/]+)ú?z?/Ú*z*/z**/z**ú^rNz./éz ([?*]+/?)Úú$ú/) rÚ enumerater6r:ÚappendÚescaper!ÚjoinÚreplaceÚosÚsep)ÚpatternÚfilenameÚsymbolsÚbufÚidxÚpartr!s rÚ pathmatchrZ�só€ðNØØ
ØØØñ
€Gð×ј#ÔØˆeˆØ˜!˜"�+‰Ø × Ñ ˜DÔ !؈eˆØ˜!˜"�+‰àˆäœrŸx™x¨ °WÓ=Ó>ò(‰ ˆˆTØ �Š7Ø �J‰J�w˜t‘}Õ %Ú
Ø �J‰J”r—y‘y “Õ 'ð (ô
�H‰H˜Ÿ™ › �~ QÐ'¨×)9Ñ)9¼"¿&¹&À#Ó)FÓ G€EØ ˜Ð Ðócóf‡—eZdZejd«Zejd«Zˆfd„ZˆxZS)Ú TextWrapperz((\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))z$(\u2068[^\u2068]+?\u2069(?::-?\d+)?)có.•—d}||vrt‰|�|«Sg}tj|j|«D]C}|j |«r|j
|«Œ&|jt‰|�|««ŒE|D�cgc]}|sŒ|‘Œ c}Scc}w)z|Splits the text into indivisible chunks while ensuring that file names
containing spaces are not broken up.
uâ�¨)ÚsuperÚ_splitr6r:Ú_enclosed_filename_rerrNÚextend)ÚselfÚtextÚenclosed_filename_startÚchunksÚchunkÚcÚ __class__s €rr`zTextWrapper._split×s�ø€ð#+ÐØ "¨$Ñ .ä‘7‘> $Ó'Ð 'àˆÜ—X‘X˜d×8Ñ8¸$Ó?ò 5ˆEØ×ÑÐ 7Ô8Ø—
‘
˜eÕ$à—
‘
œe™g™n¨UÓ3Õ4ð  5ð
"Ö'�a¢Q’Ò'Ð'ùÒ's ÂBÂ B) Ú__name__Ú
__module__Ú __qualname__r6ÚcompileÚ
wordsep_rerar`Ú
__classcell__)ris@rr]r]Îs6ø„Ø�—‘ð /ó€Jð '˜BŸJ™JÐ'NÓOÐ÷(ð(r[r]cóv—tjdtd¬«t|||d¬«j |«S)aSimple wrapper around the ``textwrap.wrap`` function in the standard
library. This version does not wrap lines on hyphens in words. It also
does not wrap PO file locations containing spaces.
:param text: the text to wrap
:param width: the maximum line width
:param initial_indent: string that will be prepended to the first line of
wrapped output
:param subsequent_indent: string that will be prepended to all lines save