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

125 lines
12 KiB
Plaintext
Raw Normal View History

Ë
j³$ãóBdZddlmZddlZddlZddlZddlZddlZddlZddl m
Z
m Z ddl m
Z
mZmZddlmZmZe«Zed«ZddZej.d ej0¬
«Zdd Zej.d «Zddd
ZddZGddej<«Z d ddZe Z!GddejD«Z#ejHZ$ejJZ%ejLZ&ejNZ'ejPZ(ejRZ)ejTZ*ddZ+y)
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#ótKt«}t|«D]}||vsŒ||j|«Œy­w)aYield 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“òˆØ  ØŠJØ H‰HTùs8 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)
rlatin-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؇GGˆA„Jð!Ø
ˆØ×"¤6§?¡?Ó3ˆÙ Øœ#œfŸo™oÓ1ˆEä )¨%Ó Ùð
à— ‘ ˜%Ÿ,™, yÓŸ
Ü1°%Ó8á ÙØ)*¯©°«×):Ñ):¸9Ó)EÐ)¨WÒ%Ð(:Ð;QÐ:RÐR[Ð&\Óð  ñ Ø—7‘7˜1“:×$ YÓ  ðà
 øô+ ¤Ô.@Ð
ñ
ð 
ûð*  ú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
«Dcgc]!}|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-ÚnamesÚnameÚfeatures rÚparse_future_flagsrDlsóà
'‰')€C؇GGˆA„JØ
€EðØw‰w‹y×Ñ Óô v‰vÐ+¨Z¸Ó>ˆäv‰vn d¨DÓ1ˆäv‰vo s¨DÓ1ˆä(×1°$Ó 3ˆAØ45·G±G¸A³J×4DÑ4DÀSÓ4IÖJ¨qQ—WW“Y—__ Jˆò
3Ü! *¨d°DÓ9ÚØ˜W×2‘Eñ
 Œ Ø €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)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ðNØØ
ØØØñ
€Gð×ј#ÔØˆeˆØ˜!˜"+‰Ø × Ñ ˜DÔ !؈eˆØ˜!˜"+‰àˆäœrŸx™x¨ °WÓ(‰ ˆˆ Š7Ø J‰Jw˜t‘}Õ
Ø J‰J”r—yy Õ 
H‰H˜Ÿ  ~ ×)9Ñ)9¼"¿&¹&À#Ó)FÓ G€EØ ˜Ð ÐócófeZdZejd«Zejd«ZˆfdZˆxZS)Ú TextWrapperz((\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))z$(\u2068[^\u2068]+?\u2069(?::-?\d+)?)có.d}||vrt||«Sg}tj|j|«D]C}|j |«r|j
|«Œ&|jt||««ŒE|Dcgc]}|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>  ˆÜ—XX˜d×8¸$Ó 5ˆEØ×ÑÐ 7Ô
˜
œe™g™n¨UÓ
'a¢QÒ'ùÒ's ÂBÂ B) Ú__name__Ú
__module__Ú __qualname__r6ÚcompileÚ
wordsep_rerar`Ú
__classcell__)ris@rr]r]Îs6ø„Øð€Jð '˜BŸJ™JÐ'NÓ÷(r[r]cóvtjdtd¬«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