
    h                        S SK r S SKJrJrJrJrJrJrJrJ	r	  S SK
Jr  S SKJrJrJr  S SKJrJrJr  \(       a  S SKJrJr  \" S5      r\" S\S	\4   S
9r " S S5      rS\S	\4   S\4S jr\SS j5       r\" \5       " S S5      5       rg)    N)TYPE_CHECKINGAnyCallableListOptionalTypeVarUnionoverload)implementer)MissingRenderMethodMissingTemplateLoaderUnexposedMethodError)IRenderableIRequestITemplateLoader)FlattenableTagT_Tc.)boundc                       \ rS rSrSrS\S\S\4   S\4S jr\" 5       r	\
S\S	\S\S\4   4S
 j5       r\
S\S	\S\S\\S\4   \4   4S j5       r\	4S\S	\S\S\4S jjrSrg)Expose"   a  
Helper for exposing methods for various uses using a simple decorator-style
callable.

Instances of this class can be called with one or more functions as
positional arguments.  The names of these functions will be added to a list
on the class object of which they are methods.
ffuncObjs.returnc                    [         R                  " U/U5       H.  n[        US/ 5      nUR                  U 5        [	        USU5        M0     U$ )a  
Add one or more functions to the set of exposed functions.

This is a way to declare something about a class definition, similar to
L{zope.interface.implementer}.  Use it like this::

    magic = Expose('perform extra magic')
    class Foo(Bar):
        def twiddle(self, x, y):
            ...
        def frob(self, a, b):
            ...
        magic(twiddle, frob)

Later you can query the object::

    aFoo = Foo()
    magic.get(aFoo, 'twiddle')(x=1, y=2)

The call to C{get} will fail if the name it is given has not been
exposed using C{magic}.

@param funcObjs: One or more function objects which will be exposed to
the client.

@return: The first of C{funcObjs}.
exposedThrough)	itertoolschaingetattrappendsetattr)selfr   r   fObjr   s        [/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/web/_element.py__call__Expose.__call__,   sL    8 OOQC2D+249I2+NN!!$'D*N; 3     instance
methodNamec                     g N )r$   r*   r+   s      r&   get
Expose.getP   s    r)   defaultc                     g r-   r.   )r$   r*   r+   r1   s       r&   r/   r0   T   s     	r)   c                 x    [        XS5      n[        US/ 5      nX;  a  X0R                  L a  [        X5      eU$ U$ )a  
Retrieve an exposed method with the given name from the given instance.

@raise UnexposedMethodError: Raised if C{default} is not specified and
there is no exposed method with the given name.

@return: A callable object for the named method assigned to the given
instance.
Nr   )r!   
_nodefaultr   )r$   r*   r+   r1   methodr   s         r&   r/   r0   Z   sD     t4 )92>%//)*4<<Nr)   r.   N)__name__
__module____qualname____firstlineno____doc__r   r   objectr'   r4   r
   strr   r/   r   r	   __static_attributes__r.   r)   r&   r   r   "   s     #  Xc6k-B  s  D JF  c8J   ,/:;	xS!1$	%  DN,/:@	 r)   r   thunkr   c                 <    [        5       nU R                  Ul        U$ r-   )r   r:   )r>   exposes     r&   exposerrA   o   s    XF]]FNMr)   c                      g)a  
Decorate with L{renderer} to use methods as template render directives.

For example::

    class Foo(Element):
        @renderer
        def twiddle(self, request, tag):
            return tag('Hello, world.')

    <div xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1">
        <span t:render="twiddle" />
    </div>

Will result in this final output::

    <div>
        <span>Hello, world.</span>
    </div>
Nr.   r.   r)   r&   rendererrC   u   s    r)   c                       \ rS rSr% SrSr\\   \S'   SS\\   4S jjr	S\
S\\\   S/S	4   4S
 jrS\\   SS	4S jrSrg)Element   ab  
Base for classes which can render part of a page.

An Element is a renderer that can be embedded in a stan document and can
hook its template (from the loader) up to render methods.

An Element might be used to encapsulate the rendering of a complex piece of
data which is to be displayed in multiple different contexts.  The Element
allows the rendering logic to be easily re-used in different ways.

Element returns render methods which are registered using
L{twisted.web._element.renderer}.  For example::

    class Menu(Element):
        @renderer
        def items(self, request, tag):
            ....

Render methods are invoked with two arguments: first, the
L{twisted.web.http.Request} being served and second, the tag object which
"invoked" the render method.

@ivar loader: The factory which will be used to load documents to
    return from C{render}.
Nloaderc                     Ub  Xl         g g r-   rG   )r$   rG   s     r&   __init__Element.__init__   s     K r)   namer   r   r   c                 N    [         R                  XS5      nUc  [        X5      eU$ )z-
Look up and return the named render method.
N)rC   r/   r   )r$   rL   r5   s      r&   lookupRenderMethodElement.lookupRenderMethod   s)     d$/>%d11r)   requestc                 V    U R                   nUc  [        U 5      eUR                  5       $ )a  
Implement L{IRenderable} to allow one L{Element} to be embedded in
another's template or rendering output.

(This will simply load the template from the C{loader}; when used in a
template, the flattening engine will keep track of this object
separately as the object to lookup renderers on and call
L{Element.renderer} to look them up.  The resulting object from this
method is not directly associated with this L{Element}.)
)rG   r   load)r$   rP   rG   s      r&   renderElement.render   s)     >'--{{}r)   rI   r-   )r6   r7   r8   r9   r:   rG   r   r   __annotations__rJ   r<   r   r   rN   rS   r=   r.   r)   r&   rE   rE      sj    4 )-FH_%,!x8 !			8H%u-}<	=	hx0 ] r)   rE   )r   N)r   typingr   r   r   r   r   r   r	   r
   zope.interfacer   twisted.web.errorr   r   r   twisted.web.iwebr   r   r   twisted.web.templater   r   r   r;   r   r   rA   rC   rE   r.   r)   r&   <module>r[      s   
 	 	 	 ' 
 D C5 CLe8CK01J JZ8CK( V  	 	. [: : :r)   