
    /h                        S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
Jr  Sq/ qS$S jrS%S jr " S S\5      r\R$                  " S5      rS r\R$                  " S	5      rS
 r\R$                  " S5      rS rS rS rS rS r " S S5      r " S S5      r      S&S jr S'S jr  S'S jr!      S(S jr"      S(S jr#      S)S jr$      S)S jr%S r&S r'S r( " S S 5      r)S*S! jr*S" r+S# r,g)+    N)ElementTreec                     [        SU SS/US/S9qUb1  [        U[        5      (       a  UR	                  5       n[        U5      qgg)a  
Configure nltk's java interface, by letting nltk know where it can
find the Java binary, and what extra options (if any) should be
passed to Java when it is run.

:param bin: The full path to the Java binary.  If not specified,
    then nltk will search the system for a Java binary; and if
    one is not found, it will raise a ``LookupError`` exception.
:type bin: str
:param options: A list of options that should be passed to the
    Java binary when it is called.  A common value is
    ``'-Xmx512m'``, which tells Java binary to increase
    the maximum heap size to 512 megabytes.  If no options are
    specified, then do not modify the options list.
:type options: list(str)
javaJAVAHOME	JAVA_HOMEzjava.exe)env_varsverbosebinary_namesN)find_binary	_java_bin
isinstancestrsplitlist_java_options)binoptionsr	   s      F/var/www/auris/envauris/lib/python3.13/site-packages/nltk/internals.pyconfig_javar      sR    $ k* \I gs##mmoGW     c                    [         R                  [         R                  [         R                  S.nUR	                  X"5      nUR	                  X35      nUR	                  XD5      n[        U [        5      (       a  [        S5      e[        c
  [        5         [        U[        5      (       a  U/nO[        U5      n[        R                  R                  R                  U5      n[        U 5      n SU/U -   n [        /[        -   U -   n [         R                   " XX4S9nU(       d  U$ UR#                  5       u  p4UR$                  S:w  a+  ['        [)        U5      5        [+        S[        U 5      -   5      eX44$ )a  
Execute the given java command, by opening a subprocess that calls
Java.  If java has not yet been configured, it will be configured
by calling ``config_java()`` with no arguments.

:param cmd: The java command that should be called, formatted as
    a list of strings.  Typically, the first string will be the name
    of the java class; and the remaining strings will be arguments
    for that java class.
:type cmd: list(str)

:param classpath: A ``':'`` separated list of directories, JAR
    archives, and ZIP archives to search for class files.
:type classpath: str

:param stdin: Specify the executed program's
    standard input file handles, respectively.  Valid values are ``subprocess.PIPE``,
    an existing file descriptor (a positive integer), an existing
    file object, 'pipe', 'stdout', 'devnull' and None.  ``subprocess.PIPE`` indicates that a
    new pipe to the child should be created.  With None, no
    redirection will occur; the child's file handles will be
    inherited from the parent.  Additionally, stderr can be
    ``subprocess.STDOUT``, which indicates that the stderr data
    from the applications should be captured into the same file
    handle as for stdout.

:param stdout: Specify the executed program's standard output file
    handle. See ``stdin`` for valid values.

:param stderr: Specify the executed program's standard error file
    handle. See ``stdin`` for valid values.


:param blocking: If ``false``, then return immediately after
    spawning the subprocess.  In this case, the return value is
    the ``Popen`` object, and not a ``(stdout, stderr)`` tuple.

:return: If ``blocking=True``, then return a tuple ``(stdout,
    stderr)``, containing the stdout and stderr outputs generated
    by the java command if the ``stdout`` and ``stderr`` parameters
    were set to ``subprocess.PIPE``; or None otherwise.  If
    ``blocking=False``, then return a ``subprocess.Popen`` object.

:raise OSError: If the java command returns a nonzero return code.
)pipestdoutdevnullzcmd should be a list of stringsz-cp)stdinr   stderrr   zJava command failed : )
subprocessPIPESTDOUTDEVNULLgetr   r   	TypeErrorr   r   r   ospathpathsepjoinr   Popencommunicate
returncodeprint_decode_stdoutdataOSError)	cmd	classpathr   r   r   blockingsubprocess_output_dict
classpathsps	            r   r   r   ?   sD   ` ##%% #&&u4E#''7F#''7F#s9::  )S!![
)_
$$Z0I s)C)
s
"C+
%
+C 	&HA}}V 	||q ().S9::r   c                   $    \ rS rSrSrS rS rSrg)	ReadError   z
Exception raised by read_* functions when they fail.
:param position: The index in the input string where an error occurred.
:param expected: What was expected when an error occurred.
c                 H    [         R                  XU5        Xl        X l        g N)
ValueError__init__expectedposition)selfr:   r;   s      r   r9   ReadError.__init__   s    DH5  r   c                 :    SU R                    SU R                   3$ )Nz	Expected z at r:   r;   r<   s    r   __str__ReadError.__str__   s    4==/dmm_==r   r?   N)__name__
__module____qualname____firstlineno____doc__r9   rA   __static_attributes__ r   r   r4   r4      s    !
>r   r4   z[uU]?[rR]?(\"\"\"|\'\'\'|\"|\')c                    [         R                  X5      nU(       d  [        SU5      eUR                  S5      n[        R
                  " SU-  5      nUR                  5       n UR                  X5      nU(       d  [        SU5      eUR                  S5      S:X  a  UR                  5       S-   nOOMP   [        XUR                  5        5      UR                  5       4$ ! [         a  n[        SU5      UeSnAff = f)	aM  
If a Python string literal begins at the specified position in the
given string, then return a tuple ``(val, end_position)``
containing the value of the string literal and the position where
it ends.  Otherwise, raise a ``ReadError``.

:param s: A string that will be checked to see if within which a
    Python string literal exists.
:type s: str

:param start_position: The specified beginning position of the string ``s``
    to begin regex matching.
:type start_position: int

:return: A tuple containing the matched string literal evaluated as a
    string and the end position of the string literal.
:rtype: tuple(str, int)

:raise ReadError: If the ``_STRING_START_RE`` regex doesn't return a
    match in ``s`` at ``start_position``, i.e., open quote. If the
    ``_STRING_END_RE`` regex doesn't return a match in ``s`` at the
    end of the first match, i.e., close quote.
:raise ValueError: If an invalid string (i.e., contains an invalid
    escape sequence) is passed into the ``eval``.

:Example:

>>> from nltk.internals import read_str
>>> read_str('"Hello", World!', 0)
('Hello', 7)

z
open quote   z\\|%szclose quoter   \zvalid escape sequenceN)
_STRING_START_REmatchr4   grouprecompileendsearchevalr8   )sstart_positionm	quotemark_STRING_END_REr;   rN   es           r   read_strr[      s    D 	q1An55
I ZZ9 45NuuwH
%%a2M844;;q>T!yy{QH HAuyy{34eiikAA H/@aGHs   5*C   
C<*C77C<z-?\d+c                     [         R                  X5      nU(       d  [        SU5      e[        UR	                  5       5      UR                  5       4$ )a  
If an integer begins at the specified position in the given
string, then return a tuple ``(val, end_position)`` containing the
value of the integer and the position where it ends.  Otherwise,
raise a ``ReadError``.

:param s: A string that will be checked to see if within which a
    Python integer exists.
:type s: str

:param start_position: The specified beginning position of the string ``s``
    to begin regex matching.
:type start_position: int

:return: A tuple containing the matched integer casted to an int,
    and the end position of the int in ``s``.
:rtype: tuple(int, int)

:raise ReadError: If the ``_READ_INT_RE`` regex doesn't return a
    match in ``s`` at ``start_position``.

:Example:

>>> from nltk.internals import read_int
>>> read_int('42 is the answer', 0)
(42, 2)

integer)_READ_INT_RErN   r4   intrO   rR   rU   rV   rW   s      r   read_intra      s?    : 	1-A	>22qwwy>1557""r   z-?(\d*)([.]?\d*)?c                 z   [         R                  X5      nU(       a,  UR                  S5      (       d"  UR                  S5      (       d  [        SU5      eUR                  S5      (       a)  [	        UR                  5       5      UR                  5       4$ [        UR                  5       5      UR                  5       4$ )a:  
If an integer or float begins at the specified position in the
given string, then return a tuple ``(val, end_position)``
containing the value of the number and the position where it ends.
Otherwise, raise a ``ReadError``.

:param s: A string that will be checked to see if within which a
    Python number exists.
:type s: str

:param start_position: The specified beginning position of the string ``s``
    to begin regex matching.
:type start_position: int

:return: A tuple containing the matched number casted to a ``float``,
    and the end position of the number in ``s``.
:rtype: tuple(float, int)

:raise ReadError: If the ``_READ_NUMBER_VALUE`` regex doesn't return a
    match in ``s`` at ``start_position``.

:Example:

>>> from nltk.internals import read_number
>>> read_number('Pi is 3.14159', 6)
(3.14159, 13)

rK      number)_READ_NUMBER_VALUErN   rO   r4   floatrR   r_   r`   s      r   read_numberrg     s    : 	  3AQWWQZZ1771::.11wwqzzQWWY((1779~quuw&&r   c                 \   [        U [        R                  5      (       a~  U R                  R                  bg  U R
                  n[        U R                  R                  5       Vs/ s H#  nXR                  ;   d  M  UR                  U   PM%     nn[        U5      S:  $ [        S5      es  snf )a  
:return: True if ``method`` overrides some method with the same
    name in a base class.  This is typically used when defining
    abstract base classes or interfaces, to allow subclasses to define
    either of two related methods:

    >>> class EaterI:
    ...     '''Subclass must define eat() or batch_eat().'''
    ...     def eat(self, food):
    ...         if overridden(self.batch_eat):
    ...             return self.batch_eat([food])[0]
    ...         else:
    ...             raise NotImplementedError()
    ...     def batch_eat(self, foods):
    ...         return [self.eat(food) for food in foods]

:type method: instance method
rK   zExpected an instance method.)
r   types
MethodType__self__	__class__rC   _mro__dict__lenr"   )methodnameclsfuncss       r   
overriddenrt   @  s    & &%**++0I0I0U FOO556
6||# CLL6 	 

 5zA~677
s   $B);B)c                     [        U [        5      (       a  U R                  $ U /nU R                   H  nUR	                  [        U5      5        M     U$ )aA  
Return the method resolution order for ``cls`` -- i.e., a list
containing ``cls`` and all its base classes, in the order in which
they would be checked by ``getattr``.  For new-style classes, this
is just cls.__mro__.  For classic classes, this can be obtained by
a depth-first left-to-right traversal of ``__bases__``.
)r   type__mro__	__bases__extendrm   )rr   mrobases      r   rm   rm   _  sE     #t{{eMMDJJtDz" "
r   c                 d   SnU R                   (       ad  U R                   R                  5       S-   U l         [        R                  " SU R                   R	                  5       5      nU(       a  [        U5      nOSU l         U =R                   [        R                  " SU SU 3UUS-   S9-  sl         g)	z4Add an epytext @field to a given object's docstring. 

z(?<=\n)[ ]+(?!\s)@:     initial_indentsubsequent_indentN)rG   rstriprP   findall
expandtabsmintextwrapfill)objfieldmessageindentindentss        r   _add_epytext_fieldr   v  s    F {{kk((*V3**13;;3I3I3KL\F KK8==
E7"WI 6/ Kr   c                    ^  U 4S jnU$ )a  
A decorator used to mark functions as deprecated.  This will cause
a warning to be printed the when the function is used.  Usage:

    >>> from nltk.internals import deprecated
    >>> @deprecated('Use foo() instead')
    ... def bar(x):
    ...     print(x/10)

c                 &  >^ ^ ST R                    ST 3mS[        R                  " TSSS9-   mU U4S jnUR                  R	                  T R                  5        T R                   Ul         T R
                  Ul        SUl        [        UST5        U$ )	Nz	Function z() has been deprecated.  
  r   c                  H   > [         R                  " T[        SS9  T" U 0 UD6$ )Nrc   category
stacklevel)warningswarnDeprecationWarning)argskwargsfuncmsgs     r   newFunc.deprecated.<locals>.decorator.<locals>.newFunc  s$    MM#(:qI(((r   T
deprecated)rC   r   r   rn   updaterG   __deprecated__r   )r   r   r   r   s   ` @r   	decoratordeprecated.<locals>.decorator  s    $--(A'KX]]3ttTT	)
 	.==,,!%7L':r   rI   )r   r   s   ` r   r   r     s    " r   c                       \ rS rSrSrS rSrg)
Deprecatedi  a  
A base class used to mark deprecated classes.  A typical usage is to
alert users that the name of a class has changed:

    >>> from nltk.internals import Deprecated
    >>> class NewClassName:
    ...     pass # All logic goes here.
    ...
    >>> class OldClassName(Deprecated, NewClassName):
    ...     "Use NewClassName instead."

The docstring of the deprecated class will be used in the
deprecation warning message.
c                    S n[        U 5       H  n[        UR                  ;   d  M  Un  O   U(       d   S5       eUR                  =(       d    SR	                  5       n[
        R                  " SSU5      n[
        R                  " SSU5      nSUR                  -  nX:w  a  USU R                  -  -  nU SU 3nS[        R                  " US	S	S
9-   n[        R                  " U[        SS9  [        R                  U 5      $ )Nz-Unable to determine which base is deprecated.r}   z\A\s*@deprecated:z(?m)^\s*zClass %sz (base class for %s)z has been deprecated.  r   r   r   rc   r   )rm   r   rx   rG   striprP   subrC   r   r   r   r   r   object__new__)rr   r   r   dep_clsr{   docrq   r   s           r   r   Deprecated.__new__  s    IDT^^+  GGGw oo+ff)34ff["c*G,,,>*S\\99D-cU3X]]3vQWXXc$61E~~c""r   rI   N)rC   rD   rE   rF   rG   r   rH   rI   r   r   r   r     s    #r   r   c                   (    \ rS rSrSrSS jrS rSrg)Counteri  z=
A counter that auto-increments each time its value is read.
c                     Xl         g r7   _value)r<   initial_values     r   r9   Counter.__init__  s    #r   c                 D    U =R                   S-  sl         U R                   $ NrK   r   r@   s    r   r!   Counter.get  s    q{{r   r   N)r   )rC   rD   rE   rF   rG   r9   r!   rH   rI   r   r   r   r     s    $r   r   c           
   #   	  #    U /U=(       d    / -   n[        U [        5      (       d   e[        U[        5      (       a   e[        U[        5      (       a   e[        U[        5      (       a  UR                  5       nSnU GH  n[        R                  R                  X5      n	[        R                  R                  U	5      (       a  U(       a  [        SU  SU	 S35        SnU	v   [        R                  R                  U5      (       a  U(       a  [        SU  SU S35        SnUv   [        R                  R                  U SU5      n	[        R                  R                  U	5      (       d  M  U(       a  [        SU  SU	 S35        SnU	v   GM     U GH  n
U
[        R                  ;   d  M  U(       a  Sn[        R                  U
   v   [        R                  U
   R                  [        R                  5       GH  n[        R                  R                  U5      (       a  U(       a  [        SU  SU S35        SnUv   U H  n[        R                  R                  X5      n	[        R                  R                  U	5      (       a  U(       a  [        SU  SU	 S35        SnU	v   [        R                  R                  USU5      n	[        R                  R                  U	5      (       d  M  U(       a  [        SU  SU	 S35        SnU	v   M     GM     GM     U HW  nU HN  n[        R                  R                  X5      n	[        R                  R                  U	5      (       d  MH  SnU	v   MP     MY     [        R                  S:X  a  U H  n [        R                  " S	U/[        R                  [        R                  S
9nUR                  5       u  p[        U5      R!                  5       nUR#                  U5      (       aC  [        R                  R%                  U5      (       a  U(       a  [        SU  SU S35        SnUv   M     U(       dl  SU -  nU(       a  USUS   -  -  nUS-  nU(       a   US-  nUSR                  S U 5       5      -  nU(       a  USU  SU S3-  nSn[-        SU SU SU 35      eg! [&        [(        [*        4 a    e f = f! f = f7f)a  
Search for a file to be used by nltk.

:param filename: The name or path of the file.
:param env_vars: A list of environment variable names to check.
:param file_names: A list of alternative file names to check.
:param searchpath: List of directories to search.
:param url: URL presented to user for download help.
:param verbose: Whether or not to print path when a file is found.
F[Found r   ]Tfiler   posixwhich)r   r   zSNLTK was unable to find the %s file!
Use software specific configuration parametersz# or set the %s environment variabler   .

  Searched in:r}   c              3   ,   #    U  H
  nS U-  v   M     g7fz	
    - %sNrI   .0ds     r   	<genexpr>!find_file_iter.<locals>.<genexpr>j       @Z<!+Z   z

  For more information on z, see:
    <>K===========================================================================r~   r   N)r   r   r   r#   r$   r&   isfiler*   environr%   rq   r   r'   r   r(   r+   r   endswithexistsKeyboardInterrupt
SystemExitr,   LookupError)filenamer   
searchpath
file_namesurlr	   finding_diryieldedalternativepath_to_fileenv_varenv_dir	directoryr2   r   r   r$   r   divs                      r   find_file_iterr     s3    & z/R0Jh$$$$*c*****c****(C  >>#G "ww||H:77>>,''zL>;<G77>>+&&zK=:;Gww||HfkB77>>,''zL>;<G' ", bjj jj))::g.44RZZ@77>>'**zG9A>?"G!M#-K#%77<<#ELww~~l33"!GH:R~Q"GH"&**
 $&77<<#LLww~~l33"!GH:R~Q"GH"&**# $. A D  	%K77<<	?Lww~~l++""	 &   
ww'%K$$k*%??%??
 "#)&1779==--"''..2F2FzD6;<"GJ # && ')12 	
 88A;FFCs
''C277@Z@@@C3H:]3%qQQCDRuBse455  &z7;  sF   E*S&0<S&0D?S&3A8S&/'S&B8SA8S&SS!!S##S&c           
      .    [        [        XX#XE5      5      $ r7   nextr   r   r   r   r   r   r	   s         r   	find_filer   q  s     x:3P r   c                 ,    [        [        XX#XESS95      $ )NT)r   r   r   s         r   find_dirr   y  s#     
RV	
 r   c              #   N   #    [        U=(       d    U X#XEU5       Sh  vN   g N7f)a  
Search for a file to be used by nltk.

:param name: The name or path of the file.
:param path_to_bin: The user-supplied binary location (deprecated)
:param env_vars: A list of environment variable names to check.
:param file_names: A list of alternative file names to check.
:param searchpath: List of directories to search.
:param url: URL presented to user for download help.
:param verbose: Whether or not to print path when a file is found.
N)r   rq   path_to_binr   r   r
   r   r	   s          r   find_binary_iterr     s'     ( tX<g  s   %#%c                 0    [        [        XX#XEU5      5      $ r7   )r   r   r   s          r   r   r     s"     x\	
 r   c              #     ^#    [        U [        5      (       d   e[        U[        5      (       a   e[        U[        5      (       a  UR                  5       nSnS/[        U5      -   nUb<  [        R
                  R                  U5      (       a  SnUv   O[        SU  SU 35      eU GHs  nU[        R                  ;   d  M  US:X  Ga<  [        R                  S   n	U	R                  [        R
                  R                  5       GH  n
[        R
                  R                  U
5      n
[        R
                  R                  U
5      (       al  [        R
                  R                  U
5      nU(       a  [        R                  " X5      (       d  U(       d$  X:X  a  U(       a  [        SU  SU
 S	35        SnU
v   [        R
                  R                  U
5      (       d  M  U(       d  [        R
                  R                  [        R
                  R!                  X5      5      (       a?  U(       a  [        SU  SU
 S	35        Sn[        R
                  R!                  X5      v   GM`  GMc  [        R"                  " U
5       H{  n[        R                  " X5      (       d  M   U(       a1  [        SU < S[        R
                  R!                  X5      < S	35        Sn[        R
                  R!                  X5      v   M}     GM     GM]  [        R
                  R                  [        R                  U   5      m[        R
                  R                  T5      (       a   U4S
 j[        R"                  " T5       5       OT4nU H  n[        R
                  R                  U5      (       d  M)  [        R
                  R                  U5      nU(       a  [        R                  " X5      (       d  U(       a  Ms  X:X  d  Mz  U(       a  [        SU  SU S	35        SnUv   M     GMv     U GH  nU(       a  [        R"                  " U5       H  n[        R
                  R!                  X5      n[        R
                  R                  U5      (       a4  [        R                  " X5      (       a  U(       a  [        SU SU S	35        SnUv   M     M  [        R
                  R!                  X5      n[        R
                  R                  U5      (       d  M  U(       a  [        SU  SU S	35        SnUv   GM     U(       d  SU -  nU(       a  USUS   -  -  n[$        R&                  " US-   SSS9nU(       a   US-  nUSR!                  S U 5       5      -  nU(       a  USR)                  U U5      -  nSn[        SU SU SU 35      eg7f)a  
Search for a jar that is used by nltk.

:param name_pattern: The name of the jar file
:param path_to_jar: The user-supplied jar location, or None.
:param env_vars: A list of environment variable names to check
                 in addition to the CLASSPATH variable which is
                 checked by default.
:param searchpath: List of directories to search.
:param is_regex: Whether name is a regular expression.
F	CLASSPATHNTzCould not find z jar file at r   r   r   c              3   d   >#    U  H%  n[         R                  R                  TU5      v   M'     g 7fr7   )r#   r$   r&   )r   path_to_jarjar_envs     r   r    find_jar_iter.<locals>.<genexpr>  s*      +>K Wk::+>s   -0zNLTK was unable to find %s!z  Set the %s environment variabler   r   r   r   r   r}   c              3   ,   #    U  H
  nS U-  v   M     g7fr   rI   r   s     r   r   r   0  r   r   z.

  For more information, on {}, see:
    <{}>r   r~   r   )r   r   r   r   r#   r$   r   r   r   r%   
expanduserbasenamerP   rN   r*   isdirr&   listdirr   r   format)name_patternr   r   r   r   r	   is_regexr   r   r.   cpr   	file_namejar_iterr   r   r   r   s                    @r   find_jar_iterr     su    * lC((((*c****(C  >>#G }tH~-H 77>>+&&G!,}[MJ 
 bjj +%JJ{3	#//"''//:B++B/Bww~~b))#%77#3#3B#7$ " @ @$,1I& %~Rt1&E F&*G"$Hww}}R(('!ww~~bggll2.LMM#*$)GL>B4q*I$J*.&(ggll2&D D	  N .0ZZ^	#%88L#D#D'.(- 1=02R0K-.)* /3G*,'',,r*E$E .</ ;J '',,RZZ-@A ww}}W--	+-::g+>
 "  $,Kww~~k22#%77#3#3K#@$ " @ @$,H1I& %~R}A&N O&*G"-- $,e @  	JJy1 ggll9?77>>+..xx77"!GH:R}A"FG!! 2 '',,y?Kww~~k**GL>K=BC!!!  $ +l:5CCCmmC#IddS''C277@Z@@@CFMM C DRuBse455 s6   B<WDWB<WDW(AW2W9DWB5Wc                 0    [        [        XX#XEU5      5      $ r7   )r   r   )r   r   r   r   r   r	   r   s          r   find_jarr  :  s"     xS8	
 r   c                     [         R                  " U 5       VVVVs/ s HD  u  pn[        R                  " US5        H"  n[         R                  R                  X5      PM$     MF     snnnn$ s  snnnnf )Nz*.jar)r#   walkfnmatchfilterr$   r&   )path_to_jarsrootdirnames	filenamesr   s        r   find_jars_within_pathr
  J  s\     *,)>)>%DIy':H 	T$: 	%)>  s   AA-
c                     [        U [        5      (       d  U $ [        [        R                  S[
        R                  " 5       5      nUc  U R                  5       $ U R                  U5      $ )z/Convert data read from stdout/stderr to unicodeencoding)r   bytesgetattrsys
__stdout__localegetpreferredencodingdecode)
stdoutdatar  s     r   r+   r+   R  sV    j%((s~~z63N3N3PQH  ""X&&r   c                     [         R                  n[         R                   Vs/ s H  o"S;  d  M
  UPM     sn[         l        [        U 5      nU[         l        U$ s  snf )a  
When python is run from within the nltk/ directory tree, the
current directory is included at the beginning of the search path.
Unfortunately, that means that modules within nltk can sometimes
shadow standard library modules.  As an example, the stdlib
'inspect' module will attempt to import the stdlib 'tokenize'
module, but will instead end up importing NLTK's 'tokenize' module
instead (causing the import to fail).
)r}   r   )r  r$   
__import__)moduleold_pathr   rW   s       r   import_from_stdlibr  b  sG     xxH88:8a	'98:CH6ACHH ;s
   	AAc                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rSS jrS rS rS rSrg)ElementWrapperix  a~  
A wrapper around ElementTree Element objects whose main purpose is
to provide nicer __repr__ and __str__ methods.  In addition, any
of the wrapped Element's methods that return other Element objects
are overridden to wrap those values before returning them.

This makes Elements more convenient to work with in
interactive sessions and doctests, at the expense of some
efficiency.
c                 b    [        U[        5      (       a  U$ [        R                  [        5      $ )z
Create and return a wrapper around a given Element object.
If ``etree`` is an ``ElementWrapper``, then ``etree`` is
returned as-is.
)r   r  r   r   )rr   etrees     r   r   ElementWrapper.__new__  s%     e^,,L>>.11r   c                 v    [        U[        5      (       a  [        R                  " U5      nXR                  S'   g)a  
Initialize a new Element wrapper for ``etree``.

If ``etree`` is a string, then it will be converted to an
Element object using ``ElementTree.fromstring()`` first:

    >>> ElementWrapper("<test></test>")
    <Element "<?xml version='1.0' encoding='utf8'?>\n<test />">

_etreeN)r   r   r   
fromstringrn   )r<   r  s     r   r9   ElementWrapper.__init__  s-     eS!!**51E"'hr   c                     U R                   $ )z4
Return the Element object wrapped by this wrapper.
r   r@   s    r   unwrapElementWrapper.unwrap  s     {{r   c                     [         R                  " U R                  SS9R                  S5      n[	        U5      S:  a1  UR                  S5      n[	        U5      U-
  S:  a  SnUS S  SXS   3nSU-  $ )	Nutf8r  <   <   iz...z<Element %r>)r   tostringr   r  ro   rfind)r<   rU   rZ   s      r   __repr__ElementWrapper.__repr__  su      v>EEfMq6B;AA
b Sb6(#aeW%A!!r   c                 z    [         R                  " U R                  SS9R                  S5      R	                  5       $ )z[
:return: the result of applying ``ElementTree.tostring()`` to
the wrapped Element object.
r(  r)  )r   r-  r   r  r   r@   s    r   rA   ElementWrapper.__str__  s1       v>EEfMTTV	
r   c                 .    [        U R                  U5      $ r7   )r  r   )r<   attribs     r   __getattr__ElementWrapper.__getattr__  s    t{{F++r   c                 .    [        U R                  X5      $ r7   )setattrr   )r<   attrvalues      r   __setattr__ElementWrapper.__setattr__  s    t{{D00r   c                 .    [        U R                  U5      $ r7   )delattrr   )r<   r9  s     r   __delattr__ElementWrapper.__delattr__  s    t{{D))r   c                      X R                   U'   g r7   r$  )r<   indexelements      r   __setitem__ElementWrapper.__setitem__  s    $Er   c                     U R                   U	 g r7   r$  r<   rB  s     r   __delitem__ElementWrapper.__delitem__  s    KKr   c                     X0R                   X& g r7   r$  )r<   startstopelementss       r   __setslice__ElementWrapper.__setslice__  s    "*Er   c                      U R                   X2	 g r7   r$  )r<   rK  rL  s      r   __delslice__ElementWrapper.__delslice__  s    KK
#r   c                 ,    [        U R                  5      $ r7   )ro   r   r@   s    r   __len__ElementWrapper.__len__  s    4;;r   c                 2    [        U R                  U   5      $ r7   )r  r   rG  s     r   __getitem__ElementWrapper.__getitem__  s    dkk%011r   c                 \    U R                   X  Vs/ s H  n[        U5      PM     sn$ s  snf r7   r   r  )r<   rK  rL  elts       r   __getslice__ElementWrapper.__getslice__  s*    /3{{5/FG/Fs#/FGGGs   )c                 X    U R                    Vs/ s H  n[        U5      PM     sn$ s  snf r7   rZ  )r<   r[  s     r   getchildrenElementWrapper.getchildren  s#    /3{{;{s#{;;;s   'Nc                 F    S U R                   R                  U5       5       $ )Nc              3   8   #    U  H  n[        U5      v   M     g 7fr7   )r  )r   r[  s     r   r   -ElementWrapper.getiterator.<locals>.<genexpr>  s     L/Ks##/Ks   )r   getiterator)r<   tags     r   rd  ElementWrapper.getiterator  s    Lt{{/F/Fs/KLLr   c                 J    [        U R                  R                  X5      5      $ r7   )r  r   makeelement)r<   re  r4  s      r   rh  ElementWrapper.makeelement  s    dkk55cBCCr   c                 X    U R                   R                  U5      nUc  U$ [        U5      $ r7   )r   findr  r<   r$   r[  s      r   rk  ElementWrapper.find  s+    kkt$;J!#&&r   c                 v    U R                   R                  U5       Vs/ s H  n[        U5      PM     sn$ s  snf r7   )r   r   r  rl  s      r   r   ElementWrapper.findall  s0    /3{{/B/B4/HI/Hs#/HIIIs   6rI   r7   )rC   rD   rE   rF   rG   r   r9   r%  r/  rA   r5  r;  r?  rD  rH  rN  rQ  rT  rW  r\  r_  rd  rh  rk  r   rH   rI   r   r   r  r  x  so    		2("
,1*%+$ 2H<MD'Jr   r  c                 B   UR                   UR                  pCU(       aJ  UR                  nUc  SnUS:  a  [        U [	        XC5      5      u  p4O[        U [	        X45      5      u  p4X4U4$ UR                  S;  a"  [        SU R                  R                  -  5      eUc  SnUc  [        U 5      nUS:  a  [        S[        U 5      U-   5      nUS:  a  [        S[        U 5      U-   5      nUS:  a   XS-
       [        X45      nX44$ ! [         a    [        U 5      n N%f = f)a  
Given a slice, return the corresponding (start, stop) bounds,
taking into account None indices and negative indices.  The
following guarantees are made for the returned start and stop values:

  - 0 <= start <= len(sequence)
  - 0 <= stop <= len(sequence)
  - start <= stop

:raise ValueError: If ``slice_obj.step`` is not None.
:param allow_step: If true, then the slice object may have a
    non-None step.  If it does, then return a tuple
    (start, stop, step).
rK   r   r   z)slices with steps are not supported by %s)rK  rL  stepslice_boundsslicer8   rl   rC   ro   max
IndexErrorr   )sequence	slice_obj
allow_steprK  rL  rq  s         r   rr  rr    s2    ??INN4 ~~<D !8&xt1CDKE4&xu1CDKED   
y	(7(:L:L:U:UU
 	

 }|8} qyAs8}u,-ax1c(md*+
 ax	!AX
 E ;  	!x=D	!s   1D DDc                    [         R                  R                  U 5      (       d  g[        [         S5      (       a  [         R                  " U 5      n[        R
                  " UR                  5      nUS-  (       a  gUR                  [         R                  " 5       :X  a  US-  (       a  gUR                  [         R                  " 5       /[         R                  " 5       -   ;   a  US-  (       a  ggg)NFgetuidrc   T      )r#   r$   r   hasattrstatS_IMODEst_modest_uidrz  st_gidgetgid	getgroups)r$   statdataperms      r   is_writabler  A  s    77>>$ r8774=||H,,-%<__		+oo"))+!??dUl  r   c           
      ~    [        S[        U5      R                  < SU < S[        U5      R                  < S35      e)Nzunorderable types: z()  z())r"   rv   rC   )orderingabs      r   raise_unorderable_typesr  a  s/    
7XtAw'7'7	9 r   )NNF)NNNNT)rI   rI   NNFF)rI   rI   NNF)NrI   rI   NNF)NrI   rI   NFF)F)-r  r  r#   rP   r~  r   r  r   ri   r   	xml.etreer   r   r   r   r   r8   r4   rQ   rM   r[   r^   ra   re   rg   rt   rm   r   r   r   r   r   r   r   r   r   r   r  r
  r+   r  r  rr  r  r  rI   r   r   <module>r     s     	 	   
    ! 	&@W~>
 >  ::@A 8Hv zz(# #F ZZ 45 #'V8>.*@)# )#b
 
( @6H NS NS 6 $ K6`  ' ,zJ zJD?N@r   