
    BhW&                        S r SSKrSSKJr  SSKJr  S=rrSr0 r	\R                  " S5      R                  r\R                  " S5      R                  rS	r0 r \R"                  " S
5      r\" \R/                  5       5       HJ  r\R2                  S:X  d  M  \R4                  SS r\\\'   \R7                  S5      S   r\\;  d  ME  \\\'   ML     \ V s0 s H  o R;                  5       U _M     sn rS r " S S5      r  " S S\!5      r" " S S5      r# " S S5      r$g! \ a    \" \5      R*                  S-  r Nf = fs  sn f )zY

Pyphen
======

Pure Python module to hyphenate text, inspired by Ruby's Text::Hyphen.

    N)	resources)Pathz0.17.2)	LANGUAGESPyphenlanguage_fallbackz\^{2}([0-9a-f]{2})z
(\d?)(\D?))%#LEFTHYPHENMINRIGHTHYPHENMINCOMPOUNDLEFTHYPHENMINCOMPOUNDRIGHTHYPHENMINzpyphen.dictionariesdictionariesz.dic   _c                     U R                  SS5      R                  5       R                  S5      nU(       a>  SR                  U5      n U [        ;   a	  [        U    $ UR                  5         U(       a  M=  gg)zGet a fallback language available in our dictionaries.

http://www.unicode.org/reports/tr35/#Locale_Inheritance

We use the normal truncation inheritance. This function needs aliases
including scripts for languages with multiple regions available.

-r   N)replacelowersplitjoinLANGUAGES_LOWERCASEpop)languagepartss     A/var/www/html/env/lib/python3.13/site-packages/pyphen/__init__.pyr   r   /   s^     S#&,,.44S9E
88E?**&x00			 %    c                   $    \ rS rSrSrS rS rSrg)AlternativeParser@   zParser of nonstandard hyphen pattern alternative.

The instance returns a special int with data about the current position in
the pattern when called with an odd value.

c                     UR                  S5      nUS   U l        [        US   5      U l        [        US   5      U l        UR                  S5      (       a  U =R                  S-  sl        g g )N,r         .)r   changeintindexcut
startswith)selfpatternalternatives      r   __init__AlternativeParser.__init__G   s`    !'',!!nQ(
{1~&c""JJ!OJ #r   c                     U =R                   S-  sl         [        U5      nUS-  (       a,  [        XR                  U R                   U R                  45      $ U$ )Nr#   )r(   r'   DataIntr&   r)   )r+   values     r   __call__AlternativeParser.__call__O   sB    

a
E
195;;

DHH"EFFLr   )r&   r)   r(   N)__name__
__module____qualname____firstlineno____doc__r.   r3   __static_attributes__ r   r   r   r   @   s    r   r   c                   "    \ rS rSrSrSS jrSrg)r1   X   zE``int`` with some other data can be stuck to in a ``data`` attribute.Nc                     [         R                  X5      nU(       a(  [        U[        5      (       a  UR                  Ul        U$ X$l        U$ )zmCreate a new ``DataInt``.

Call with ``reference=dataint_object`` to use the data from another
``DataInt``.

)r'   __new__
isinstancer1   data)clsr2   rA   	referenceobjs        r   r?   DataInt.__new__Z   s?     kk#%Iw77 ~~CH 
 H
r   r;   )NN)r5   r6   r7   r8   r9   r?   r:   r;   r   r   r1   r1   X   s
    Or   r1   c                   $    \ rS rSrSrS rS rSrg)HyphDicti   zHyphenation patterns.c                    0 U l         UR                  S5       nUR                  5       R                  5       nSSS5        WR	                  5       S:X  a  SnUR                  U5      R                  S5      SS  GH$  nUR                  5       nU(       a  UR                  [        5      (       a  M7  [        S U5      nSU;   a&  S	U;   a   UR                  SS5      u  pE[        XE5      nO[        n[        [        U5       VVs/ s H  u  pxX" U=(       d    S
5      4PM     snn6 u  p[        U
5      S:X  a  M  S[!        U
5      pX   (       d  US-  nX   (       d  M  XS-
     (       d  US-  nXS-
     (       d  M  XX 4U R                   SR#                  U	5      '   GM'     0 U l        [        S U R                    5       5      U l        g! , (       d  f       GN= fs  snnf )zXRead a ``hyph_*.dic`` and parse its patterns.

:param path: Path of hyph_*.dic to read

rbNzmicrosoft-cp1251cp1251
r#   c                 J    [        [        U R                  S5      S5      5      $ )Nr#      )chrr'   group)matchs    r   <lambda>#HyphDict.__init__.<locals>.<lambda>   s    c#ekk!nb"9:r   /=0r    c              3   8   #    U  H  n[        U5      v   M     g 7f)N)len).0keys     r   	<genexpr>$HyphDict.__init__.<locals>.<genexpr>   s     <ms#c((ms   )patternsopenreadlinedecoder   	read_textr   stripr*   ignored	parse_hexr   r'   zipparsemaxrY   r   cachemaxlen)r+   pathfdencodingr,   r-   factoryistringtagsvaluesstartends                r   r.   HyphDict.__init__l   s     YYt_{{}++-H >>11H~~h/55d;AB?GmmoGg0099  :GEG g~#.'.}}S!'<$+GA=B7^!M=K	c*+^!M NLD 6{a CK3m
 mm1Woq 1Woo ,12C+CDMM"''$-(= @@ 
<dmm<<M _*!Ms   GG
Gc           	         UR                  5       nU R                  R                  U5      nUGc  SU S3nS/[        U5      S-   -  n[	        [        U5      S-
  5       H  n[        XPR                  -   [        U5      5      S-   n[	        US-   U5       H^  nU R                  R                  X5U 5      nU(       d  M)  Uu  p[        XY-   XY-   [        U
5      -   5      n[        [        XU   5      XK'   M`     M     [        U5       VVs/ s H  u  p\US-  (       d  M  [        US-
  US9PM      snn=U R                  U'   nU$ s  snnf )a~  Get a list of positions where the word can be hyphenated.

:param word: unicode string of the word to hyphenate

E.g. for the dutch word 'lettergrepen' this method returns ``[3, 6,
9]``.

Each position is a ``DataInt`` with a data attribute.

If the data attribute is not ``None``, it contains a tuple with
information about nonstandard hyphenation at that point: ``(change,
index, cut)``.

change
  a string like ``'ff=f'``, that describes how hyphenation should
  take place.

index
  where to substitute the change, counting from the current point

cut
  how many characters to remove while substituting the nonstandard
  hyphenation

r%   r   r#   r$   )rC   )r   ri   getrY   rangeminrj   r^   slicemaprh   	enumerater1   )r+   wordpointspointed_word
referencesro   stopjr,   offsetrr   slice_rC   s                r   	positionsHyphDict.positions   s?   4 zz|%>tfA;LL 1A 56J3|,q011{{?C,=>Bq1ud+A"mm//q0ABG" %,NF"1:qzCK/GHF),S&V:L)MJ& , 2 %.j$9)L$9LAY] 4A3$9)L LDJJtv )Ls   	EE)ri   rj   r^   N)r5   r6   r7   r8   r9   r.   r   r:   r;   r   r   rG   rG   i   s    /=b-r   rG   c                   F    \ rS rSrSrS
S jrS rS rSS jrSS jr	\r
S	rg)r      zEHyphenation class, with methods to hyphenate strings in various ways.Nc                     X4sU l         U l        U(       a  [        U5      O[        [	        U5         nU(       a
  U[
        ;  a  [        U5      [
        U'   [
        U   U l        g)a  Create an hyphenation instance for given lang or filename.

:param filename: filename or Path of hyph_*.dic to read
:param lang: lang of the included dict to use if no filename is given
:param left: minimum number of characters of the first syllabe
:param right: minimum number of characters of the last syllabe
:param cache: if ``True``, use cached copy of the hyphenation patterns

N)leftrightr   r   r   hdcacherG   hd)r+   filenamelangr   r   ri   rk   s          r   r.   Pyphen.__init__   sL     !%	4:!)tH~y9J49P/QG+$TNGDM$-r   c                     [        U5      U R                  -
  nU R                  R                  U5       Vs/ s H!  o0R                  Us=::  a  U::  d  M  O  M  UPM#     sn$ s  snf )zGet a list of positions where the word can be hyphenated.

:param word: unicode string of the word to hyphenate

See also ``HyphDict.positions``. The points that are too far to the
left or right are removed.

)rY   r   r   r   r   )r+   r}   r   ro   s       r   r   Pyphen.positions   sR     D	DJJ&77,,T2N2aii16M6M6M2NNNs   A!A!A!c              #   F  #    [        U R                  U5      5       H  nUR                  (       a`  UR                  u  p4nXB-  nUR                  5       (       a  UR	                  5       nUR                  S5      u  pgUSU U-   XqXE-   S -   4v   Mt  USU XS 4v   M     g7f)zvIterate over all hyphenation possibilities, the longest first.

:param word: unicode string of the word to hyphenate

rU   N)reversedr   rA   isupperupperr   )r+   r}   positionr&   r(   r)   c1c2s           r   iteratePyphen.iterate   s      !!56H}}%-]]"s!<<>>#\\^Fc*6ElR'5;<.@)@@@9HotI66 7s   BB!c                     U[        U5      -  nU R                  U5       H  u  pE[        U5      U::  d  M  XC-   U4s  $    g)a|  Get the longest possible first part and the last part of a word.

:param word: unicode string of the word to hyphenate
:param width: maximum length of the first part
:param hyphen: unicode string used as hyphen character

The first part has the hyphen already attached.

Returns ``None`` if there is no hyphenation point before ``width``, or
if the word could not be hyphenated.

N)rY   r   )r+   r}   widthhyphenw1w2s         r   wrapPyphen.wrap   s?     	Vll4(FB2w%{B& )r   c                 `   [        U5      n[        U R                  U5      5       Hu  nUR                  (       aP  UR                  u  pVnXd-  nUR	                  5       (       a  UR                  5       nUR                  SU5      X6Xg-   & Md  UR                  XB5        Mw     SR                  U5      $ )as  Get the word as a string with all the possible hyphens inserted.

:param word: unicode string of the word to hyphenate
:param hyphen: unicode string used as hyphen character

E.g. for the dutch word ``'lettergrepen'``, this method returns the
unicode string ``'let-ter-gre-pen'``. The hyphen string to use can be
given as the second parameter, that defaults to ``'-'``.

rU   rW   )	listr   r   rA   r   r   r   insertr   )r+   r}   r   lettersr   r&   r(   r)   s           r   insertedPyphen.inserted  s     t* !56H}}%-]]"s!<<>>#\\^F-3^^C-Hek*x0 7 wwwr   )r   r   r   )NNr$   r$   T)r   )r5   r6   r7   r8   r9   r.   r   r   r   r   r3   r:   r;   r   r   r   r      s&    O  
O7$'$ 2 Hr   r   )%r9   re	importlibr   pathlibr   VERSION__version____all__r   compilesubre   findallrg   rd   r   filesr   	TypeError__file__parentsortediterdirrk   suffixnamer   
short_namer   r   r   r   r'   r1   rG   r   )r   s   0r   <module>r      sZ   
     +
6  JJ,-11	


=!))7
 	:??#89L <'')*D{{fyy2	$ZZ_Q'
Y&$(Ij! + 7@@idzz|T)i@ " 0c "a aH\ \Y  :>((>9L: As   D D=D:9D: