AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/wadllib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/wadllib/__pycache__/application.cpython-310.pyc
o

R
`��@sdZeZgd�ZddlZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZzddl
mZWneyAddlmZYnwzddlmmZWney_ddlmmZYnwddlmZmZddlmZmZddlmZd	Zd
Z dd�Z!d
d�Z"dd�Z#Gdd�de$�Z%Gdd�de%�Z&Gdd�de%�Z'Gdd�de(�Z)Gdd�d�Z*Gdd�de)�Z+Gdd�de+�Z,Gdd �d e)�Z-Gd!d"�d"e)e*�Z.Gd#d$�d$e*�Z/Gd%d&�d&e+e*�Z0Gd'd(�d(e)�Z1Gd)d*�d*e)�Z2Gd+d,�d,e+�Z3Gd-d.�d.e)�Z4Gd/d0�d0e)�Z5dS)1a�Navigate the resources exposed by a web service.

The wadllib library helps a web client navigate the resources
exposed by a web service. The service defines its resources in a
single WADL file. wadllib parses this file and gives access to the
resources defined inside. The client code can see the capabilities of
a given resource and make the corresponding HTTP requests.

If a request returns a representation of the resource, the client can
bind the string representation to the wadllib Resource object.
)
�Application�Link�Method�NoBoundRepresentationError�	Parameter�RepresentationDefinition�ResponseDefinition�Resource�ResourceType�	WADLError�N)�quote)�	urlencode)�URI�merge)�
_make_unicode�
_string_types)�iso_strptimez	xmlns:mapz http://www.w3.org/2001/XMLSchemacCsd|S)z)Scope a tag name with the WADL namespace.z&{http://research.sun.com/wadl/2006/10}���tag_namerr�5/usr/lib/python3/dist-packages/wadllib/application.py�wadl_tagHsrcCsdt|�S)z#Turn a tag name into an XPath path.z./)rrrrr�
wadl_xpathMsrcGs$i}|D]}|dur|�|�q|S)z<Merge any number of dictionaries, some of which may be None.N)�update)�dicts�final�dictrrr�_merge_dictsRs
�rc@�eZdZdZdS)r
zAAn exception having to do with the state of the WADL application.N��__name__�
__module__�__qualname__�__doc__rrrrr
[sr
c@r)raAAn unbound resource was used where wadllib expected a bound resource.

    To obtain the value of a resource's parameter, you first must bind
    the resource to a representation. Otherwise the resource has no
    idea what the value is and doesn't even know if you've given it a
    parameter name that makes sense.
    Nrrrrrr`�rc@r)�UnsupportedMediaTypeErrorz�A media type was given that's not supported in this context.

    A resource can only be bound to media types it has representations
    of.
    Nrrrrrr%jr$r%c@r)�WADLBasez?A base class for objects that contain WADL-derived information.Nrrrrrr&rr$r&c@s&eZdZdZddd�Z	d	dd�ZdS)
�HasParametersMixinzAA mixin class for objects that have associated Parameter objects.Ncs\�dur|j��durtd��|jdurgS|j�td��}|dur$gS��fdd�|D�S)z6Find subsidiary parameters that have the given styles.Nz&Could not find any particular resource�paramcs&g|]}|j�d��vrt�|��qS)�style)�attrib�getr)�.0�	param_tag��resource�stylesrr�
<listcomp>�s�z-HasParametersMixin.params.<locals>.<listcomp>)r/�
ValueError�tag�findallr)�selfr0r/�
param_tagsrr.r�paramsys
�zHasParametersMixin.paramsTc	Ks
t||�}i}|D]h}|j}|jdur/||vr*|||jkr*td||||jf��|j||<dd�|jD�}t|�dkrU||vrU|||vrUtd|||d�|�f��|rd|jrd||vrdtd|��||vrq||||<||=q	t|�dkr�td	d
�|�����|S)a�Make sure the given valueset is valid.

        A valueset might be invalid because it contradicts a fixed
        value or (if enforce_completeness is True) because it lacks a
        required value.

        :param params: A list of Parameter objects.
        :param param_values: A dictionary of parameter values. May include
           paramters whose names are not valid Python identifiers.
        :param enforce_completeness: If True, this method will raise
           an exception when the given value set lacks a value for a
           required parameter.
        :param kw_param_values: A dictionary of parameter values.
        :return: A dictionary of validated parameter values.
        Nz=Value '%s' for parameter '%s' conflicts with fixed value '%s'cS�g|]}|j�qSr)�value)r,�optionrrrr1��z<HasParametersMixin.validate_param_values.<locals>.<listcomp>rz=Invalid value '%s' for parameter '%s': valid values are: "%s"z", "z$No value for required parameter '%s'zUnrecognized parameter(s): '%s'z', ')	r�name�fixed_valuer2�options�len�join�is_required�keys)	r5r7�param_values�enforce_completeness�kw_param_values�validated_valuesr(r<r>rrr�validate_param_values�sJ

���

���
����z(HasParametersMixin.validate_param_values�N)T)r r!r"r#r7rGrrrrr'vs

�r'c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�WADLResolvableDefinitionz=A base class for objects whose definitions may be references.cCsd|_||_dS)z�Initialize with a WADL application.

        :param application: A WADLDefinition. Relative links are
            assumed to be relative to this object's URL.
        N)�_definition�application)r5rKrrr�__init__��
z!WADLResolvableDefinition.__init__cCs^|jdur|jS|��}|dur||_|S|j�|�}|�|�}|dur*td|��||_|S)a�Return the definition of this object, wherever it is.

        Resource is a good example. A WADL <resource> tag
        may contain a large number of nested tags describing a
        resource, or it may just contain a 'type' attribute that
        references a <resource_type> which contains those same
        tags. Resource.resolve_definition() will return the original
        Resource object in the first case, and a
        ResourceType object in the second case.
        N�No such XML ID: "%s")rJ�_get_definition_urlrK�
lookup_xml_id�_definition_factory�KeyError)r5�
object_url�xml_id�
definitionrrr�resolve_definition�s

z+WADLResolvableDefinition.resolve_definitioncC�t��)zxTransform an XML ID into a wadllib wrapper object.

        Which kind of object it is depends on the subclass.
        ��NotImplementedError�r5�idrrrrQ��z,WADLResolvableDefinition._definition_factorycCrW)zmFind the URL that identifies an external reference.

        How to do this depends on the subclass.
        rX�r5rrrrO�r\z,WADLResolvableDefinition._get_definition_urlN)r r!r"r#rLrVrQrOrrrrrI�s	"rIcs�eZdZdZ			d'�fdd�	Zedd��Zedd	��Zed
d��Z			d(d
d�Z	dd�Z
		d)dd�Zd*dd�Zd*dd�Z
edd��Zd*dd�Zdd�Zdd�Zdd �Zd!d"�Zd*d#d$�Zd%d&�Z�ZS)+rz/A resource, possibly bound to a representation.NTcs�tt|��|�||_t|t�r|j�|�j|_n||_d|_	|dur<|dkr6|r2t
�t|��|_	n
||_	nt
d|��||_|durU|durL||_dS|�|j�|_dSdS)a[
        :param application: A WADLApplication.
        :param url: The URL to this resource.
        :param resource_type: An ElementTree <resource> or <resource_type> tag.
        :param representation: A string representation.
        :param media_type: The media type of the representation.
        :param representation_needs_processing: Set to False if the
            'representation' parameter should be used as
            is. Otherwise, it will be transformed from a string into
            an appropriate Python data structure, depending on its
            media type.
        :param representation_definition: A RepresentationDefinition
            object describing the structure of this
            representation. Used in cases when the representation
            isn't the result of sending a standard GET to the
            resource.
        N�application/jsonz?This resource doesn't define a representation for media type %s)�superrrL�_url�
isinstancerrK�get_resource_typer3�representation�json�loadsrr%�
media_type�representation_definition�get_representation_definition)r5rK�url�
resource_typercrf�representation_needs_processingrg��	__class__rrrL�s2
���

��zResource.__init__cCs|jS)z Return the URL to this resource.)r`r]rrrri,szResource.urlcCsb|jdurdS|jj�d�}|dur|S|jj�d�}|dur/t|jj���}t|�d|SdS)z@Return the URL to the type definition for this resource, if any.N�typer[�#)r3r*r+rrK�
markup_url�ensureSlash�str)r5ri�type_id�baserrr�type_url1s
zResource.type_urlcCs|jjdS)zReturn the ID of this resource.r[)r3r*r]rrrr[C�zResource.idr^cCst|j|j|j||||�S)a�Bind the resource to a representation of that resource.

        :param representation: A string representation
        :param media_type: The media type of the representation.
        :param representation_needs_processing: Set to False if the
            'representation' parameter should be used as
            is.
        :param representation_definition: A RepresentationDefinition
            object describing the structure of this
            representation. Used in cases when the representation
            isn't the result of sending a standard GET to the
            resource.
        :return: A Resource bound to a particular representation.
        )rrKrir3)r5rcrfrkrgrrr�bindHs
�z
Resource.bindcCsD|�d�j}|D]}|��j}|j�d�|kr|Sqtd|��)z<Get a description of one of this resource's representations.�GET�	mediaTypez4No definition for representation with media type %s.)�
get_method�responserVr3r*r+r%)r5rf�default_get_responserc�representation_tagrrrrh^s
��z&Resource.get_representation_definitioncCsX|��D]%}|j�dd���}|dus||��kr)t||�}|�|||�r)|SqdS)aLook up one of this resource's methods by HTTP method.

        :param http_method: The HTTP method used to invoke the desired
                            method. Case-insensitive and optional.

        :param media_type: The media type of the representation
                           accepted by the method. Optional.

        :param query_params: The names and values of any fixed query
                             parameters used to distinguish between
                             two methods that use the same HTTP
                             method. Optional.

        :param representation_params: The names and values of any
                             fixed representation parameters used to
                             distinguish between two methods that use
                             the same HTTP method and have the same
                             media type. Optional.

        :return: A MethodDefinition, or None if there's no definition
                  that fits the given constraints.
        r<�N)�_method_tag_iterr*r+�lowerr�is_described_by)r5�http_methodrf�query_params�representation_params�
method_tagr<�methodrrrrzhs
��zResource.get_methodcC�|�|��|�S)a~A list of this resource's parameters.

        :param media_type: Media type of the representation definition
            whose parameters are being named. Must be present unless
            this resource is bound to a representation.

        :raise NoBoundRepresentationError: If this resource is not
            bound to a representation and media_type was not provided.
        )�_find_representation_definitionr7�r5rfrrr�
parameters��

��zResource.parameterscCr�)a�A list naming this resource's parameters.

        :param media_type: Media type of the representation definition
            whose parameters are being named. Must be present unless
            this resource is bound to a representation.

        :raise NoBoundRepresentationError: If this resource is not
            bound to a representation and media_type was not provided.
        )r��parameter_namesr�rrrr��r�zResource.parameter_namesccs �|��D]}t||�VqdS)z6An iterator over the methods defined on this resource.N)rr)r5r�rrr�method_iter�s��zResource.method_itercCsF|�|�}|j}|�td��D]}|j�d�|kr t||�SqdS)a�Find a parameter within a representation definition.

        :param param_name: Name of the parameter to find.

        :param media_type: Media type of the representation definition
            whose parameters are being named. Must be present unless
            this resource is bound to a representation.

        :raise NoBoundRepresentationError: If this resource is not
            bound to a representation and media_type was not provided.
        r(r<N)r�r3r4rr*r+r)r5�
param_namerfrUr}r-rrr�
get_parameter�s
�zResource.get_parametercCs�|jdur	td��|jdkrd|jdkrtd|j��|j|j}|durb|�|j|j�\}}|t	krb|dvrbzt
|�}W|Styaztjt
�|d�dd	��}WY|Sty`t|��ww|Std
|j��)z�Find the value of a parameter, given the Parameter object.

        :raise ValueError: If the parameter value can't be converted into
        its defined type.
        Nz,Resource is not bound to any representation.r^�plain�8Don't know how to find value for a parameter of type %s.)�dateTime�datez%Y-%m-%dr�zEPath traversal not implemented for a representation of media type %s.)rcrrfr)rYr<�_dereference_namespacer3rn�XML_SCHEMA_NS_URIrr2�datetime�time�strptime)r5�	parameterr9�
namespace_url�	data_typerrr�get_parameter_value�sH
�

����
�����
�zResource.get_parameter_valuecCsD|durd|vr|�dd�\}}nd}|�t�}|�|d�}||fS)z�Splits a value into namespace URI and value.

        :param tag: A tag to use as context when mapping namespace
        names to URIs.
        N�:�r~)�splitr+�NS_MAP)r5r3r9�	namespace�ns_mapr�rrrr��s
zResource._dereference_namespacecC�|jj�|�S)z-Given an ID, find a ResourceType for that ID.)rK�resource_typesr+rZrrrrQ��zResource._definition_factorycC�|jj�d�S)z�Return the URL that shows where a resource is 'really' defined.

        If a resource's capabilities are defined by reference, the
        <resource> tag's 'type' attribute will contain the URL to the
        <resource_type> that defines them.
        rn�r3r*r+r]rrrrO��zResource._get_definition_urlcCs>|jdur|j��}|��S|dur|�|�}|��Std��)a3Get the most appropriate representation definition.

        If media_type is provided, the most appropriate definition is
        the definition of the representation of that media type.

        If this resource is bound to a representation, the most
        appropriate definition is the definition of that
        representation. Otherwise, the most appropriate definition is
        the definition of the representation served in response to a
        standard GET.

        :param media_type: Media type of the definition to find. Must
            be present unless the resource is bound to a
            representation.

        :raise NoBoundRepresentationError: If this resource is not
            bound to a representation and media_type was not provided.

        :return: A RepresentationDefinition
        NzSResource is not bound to any representation, and no media media type was specified.)rcrgrVrhr)r5rfrUrrrr�s

�
��z(Resource._find_representation_definitionccs*�|��j}|�td��D]}|Vq
dS)z+Iterate over this resource's <method> tags.r�N)rVr3r4r)r5rUr�rrrr*s
�
�zResource._method_tag_iter)NNTN)r^TN)NNNNrH)r r!r"r#rL�propertyrirur[rwrhrzr�r�r�r�r�r�rQrOr�r�
__classcell__rrrlrr�s>�4



�

�
!



0
	#rc@sneZdZdZdd�Zedd��Zedd��Zedd	��Zed
d��Z	dd
d�Z
		ddd�Z		ddd�ZdS)rz*A wrapper around an XML <method> tag.
    cCs||_|jj|_||_dS)zaInitialize with a <method> tag.

        :param method_tag: An ElementTree <method> tag.
        N)r/rKr3)r5r/r�rrrrL4s

zMethod.__init__cCst||j�td���S)z@Return the definition of a request that invokes the WADL method.�request)�RequestDefinitionr3�findrr]rrrr�=szMethod.requestcCst|j|j�td���S)z9Return the definition of the response to the WADL method.r{)rr/r3r�rr]rrrr{Bs�zMethod.responsecCr�)z)The XML ID of the WADL method definition.r[r�r]rrrr[H�z	Method.idcCs|jj�d���S)z�The name of the WADL method definition.

        This is also the name of the HTTP method (GET, POST, etc.)
        that should be used to invoke the WADL method.
        r<�r3r*r+r�r]rrrr<MszMethod.nameNcKs|jj|fi|��S)�4Return the request URL to use to invoke this method.)r��	build_url)r5rCrErrr�build_request_urlV�zMethod.build_request_urlcKs|jj||fi|��S)z�Build a representation to be sent when invoking this method.

        :return: A 2-tuple of (media_type, representation).
        )r�rc)r5rfrCrErrr�build_representationZs
��zMethod.build_representationc	Cs�d}|dur|j�|�}|durdS|dur:t|�dkr:|j}|dur%dSz
|�|j|d�Wn
ty9YdSw|dusDt|�dkrFdS|durO|�|�S|jjD]}z|�|�|j	�|d�WdStymYqSwdS)aReturns true if this method fits the given constraints.

        :param media_type: The method must accept this media type as a
                           representation.

        :param query_values: These key-value pairs must be acceptable
                           as values for this method's query
                           parameters. This need not be a complete set
                           of parameters acceptable to the method.

        :param representation_values: These key-value pairs must be
                           acceptable as values for this method's
                           representation parameters. Again, this need
                           not be a complete set of parameters
                           acceptable to the method.
        NFrT)
r�rhr?rGr�r2r��representationsr7r/)r5rf�query_values�representation_valuesrcr�rrrr�csJ���
��
��zMethod.is_described_byrH�NN)NNN)
r r!r"r#rLr�r�r{r[r<r�r�r�rrrrr1s$	





�	�rc@sNeZdZdZdd�Zedd��Zedd��Zdd	d
�Zddd�Z	dd
d�Z
dS)r�zBA wrapper around the description of the request invoking a method.cCs$||_|jj|_|jj|_||_dS)z�Initialize with a <request> tag.

        :param resource: The resource to which this request can be sent.
        :param request_tag: An ElementTree <request> tag.
        N)r�r/rKr3)r5r��request_tagrrrrL�s


zRequestDefinition.__init__cCs|�dg�S)z,Return the query parameters for this method.�query�r7r]rrrr��rvzRequestDefinition.query_paramsccs.�|j�td��D]}t|j|j|�Vq	dS)Nrc)r3r4rrrKr/)r5rUrrrr��s�
��z!RequestDefinition.representationsNcCs*|jD]}|dus|j|kr|SqdS)z1Return the appropriate representation definition.N)r�rf�r5rfrcrrrrh�s

�z/RequestDefinition.get_representation_definitioncKs0|�|�}|durtd|��|j|fi|��S)z�Build a representation to be sent along with this request.

        :return: A 2-tuple of (media_type, representation).
        Nz,Cannot build representation of media type %s)rh�	TypeErrorrw)r5rfrCrErUrrrrc�s
�z RequestDefinition.representationcKsX|j|j|fi|��}|jj}t|�dkr*d|vrd}nd}||tt|����7}|S)r�r�?�&)rGr�r/rir?r
�sorted�items)r5rCrErFri�appendrrrr��s��zRequestDefinition.build_urlrHr�)r r!r"r#rLr�r�r�rhrcr�rrrrr��s



r�c@sBeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)rz;A wrapper around the description of a response to a method.NcCs|j|_||_||_||_dS)zgInitialize with a <response> tag.

        :param response_tag: An ElementTree <response> tag.
        N)rKr/r3�headers)r5r/�response_tagr�rrrrL�s
zResponseDefinition.__init__ccs4�td�}|j�|�D]}t|jj|j|�VqdS)z�Get an iterator over the representation definitions.

        These are the representations returned in response to an
        invocation of this method.
        rcN)rr3r4rr/rK)r5�pathr}rrr�__iter__�s���zResponseDefinition.__iter__cCst|j|j|�S)z�Bind the response to a set of HTTP headers.

        A WADL response can have associated header parameters, but no
        other kind.
        )rr/r3)r5r�rrrrw�szResponseDefinition.bindcCsH|j�td��D]}|j�d�|kr!|j�d�dkr!t||�SqdS)z,Find a header parameter within the response.r(r<r)�headerN)r3r4rr*r+r)r5r�r-rrrr��s��z ResponseDefinition.get_parametercCs8|jdur	td��|jdkrtd|j��|j�|j�S)z:Find the value of a parameter, given the Parameter object.Nz,Response object is not bound to any headers.r�r�)r�rr)rYr+r<)r5r�rrrr�s
�
��z&ResponseDefinition.get_parameter_valuecCs.|jdurdS|D]}|j|kr|Sq	dS)z8Get one of the possible representations of the response.N)r3rfr�rrrrhs

�z0ResponseDefinition.get_representation_definitionrH)
r r!r"r#rLr�rwr�r�rhrrrrr�s

rcszeZdZdZ�fdd�Z�fdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
ddd�Zdd�Zdd�Z
dd�Zdd�Z�ZS)rz2A definition of the structure of a representation.cs tt|��|�||_||_dSrH)r_rrLr/r3)r5rKr/r}rlrrrLs
z!RepresentationDefinition.__init__cstt|��ddg|�S)Nr�r�)r_rr7�r5r/rlrrr7s
�zRepresentationDefinition.paramscCsdd�|�|�D�S)z#Return the names of all parameters.cSr8r)r<)r,r(rrrr1$r;z<RepresentationDefinition.parameter_names.<locals>.<listcomp>r�r�rrrr�"r�z(RepresentationDefinition.parameter_namescCs|��jjdS)z4The media type of the representation described here.ry)rVr3r*r]rrrrf&sz#RepresentationDefinition.media_typec	Cs�tttjd��}d|}t�tj�}d||d}|dur!|S|}d}	dt�|�d	�d
�}tj	||tj
d�s>	|S|dt|�}|d7}q&)
z;Make a random boundary that does not appear in `all_parts`.r�z%%0%ddz===============z==NrTz^--z(--)?$�ascii)�flags�.)r?�repr�sys�maxsize�random�	randrange�re�escape�encode�search�	MULTILINErr)	r5�	all_parts�_width�_fmt�token�boundary�b�counter�patternrrr�_make_boundary+s ��z'RepresentationDefinition._make_boundarycCsP|D]\}}|�|�d��|�d�|�|�d��|�d�q|�d�dS)z$Write MIME headers to a file object.�UTF-8s: �
N��writer�)r5�bufr��keyr9rrr�_write_headers=s
z'RepresentationDefinition._write_headersFcCs6|�d�|�|�d��|r|�d�|�d�dS)z,Write a multipart boundary to a file object.s--r�r�Nr�)r5r�r��closingrrr�_write_boundaryFs


z(RepresentationDefinition._write_boundaryc
Cs�g}|D]|\}}}t��}|rd}dt|�t|�f}nd}dt|�}|�|dd|fd|fg�|rFt|t�s@tdt|���|�|�n3t|t	�sStd	t|���t
�d
|�}	|	dd�D]}
|�|
�d
��|�d�q_|�|	d�d
��|�
|���q|�d�|��}t��}dt|�}|�|dd|fg�|D]}|�||�|�|�|�d�q�|j||dd�||��fS)aVGenerate a multipart/form-data message.

        This is very loosely based on the email module in the Python standard
        library.  However, that module doesn't really support directly embedding
        binary data in a form: various versions of Python have mangled line
        separators in different ways, and none of them get it quite right.
        Since we only need a tiny subset of MIME here, it's easier to implement
        it ourselves.

        :return: a tuple of two elements: the Content-Type of the message, and
            the entire encoded message as a byte string.
        zapplication/octet-streamz#form-data; name="%s"; filename="%s"ztext/plain; charset="utf-8"zform-data; name="%s")zMIME-Versionz1.0zContent-TypezContent-Dispositionzbytes payload expected: %szstring payload expected: %sz
\r\n|\r|\nN���r�r�z"multipart/form-data; boundary="%s"T)r�)�io�BytesIOrr�ra�bytesr�rnr�rr�r�r�r��getvaluer�r@r�)
r5�parts�
encoded_parts�	is_binaryr<r9r��ctype�cdisp�lines�liner��encoded_partrrr�_generate_multipart_formNsT��


��
z1RepresentationDefinition._generate_multipart_formcKs�|��}|�|j�}|j||fi|��}|j}|dkr'tt|����}||fS|dkrWg}t�}	|D]}
|�	|
j
|	�}||	urK|�|
jdk|
j
|f�q2|�
|�\}}||fS|dkrdt�|�}||fStd|��)zzBind the definition to parameter values, creating a document.

        :return: A 2-tuple (media_type, document).
        z!application/x-www-form-urlencodedzmultipart/form-data�binaryr^zUnsupported media type: '%s')rVr7r/rGrfr
r�r��objectr+r<r�rnr�rd�dumpsr2)r5rCrErUr7rFrf�docr��missingr(r9rrrrw�s2��
���
�zRepresentationDefinition.bindcCr�)z9Turn a representation ID into a RepresentationDefinition.)rK�representation_definitionsr+rZrrrrQ�r�z,RepresentationDefinition._definition_factorycCr�)aFind the URL containing the representation's 'real' definition.

        If a representation's structure is defined by reference, the
        <representation> tag's 'href' attribute will contain the URL
        to the <representation> that defines the structure.
        �hrefr�r]rrrrO�r�z,RepresentationDefinition._get_definition_url)F)r r!r"r#rLr7r�r�rfr�r�r�r�rwrQrOr�rrrlrrs

	Arc@s�eZdZdZdd�Zedd��Zedd��Zedd	��Zed
d��Z	edd
��Z
dd�Zedd��Zedd��Z
edd��ZdS)rz5One of the parameters of a representation definition.cCs|j|_||_||_dS)a�Initialize with respect to a value container.

        :param value_container: Usually the resource whose representation
            has this parameter. If the resource is bound to a representation,
            you'll be able to find the value of this parameter in the
            representation. This may also be a server response whose headers
            define a value for this parameter.
        :tag: The ElementTree <param> tag for this parameter.
        N)rK�value_containerr3)r5r�r3rrrrL�s

zParameter.__init__cCr�)zThe name of this parameter.r<r�r]rrrr<�r�zParameter.namecCr�)zThe style of this parameter.r)r�r]rrrr)�r�zParameter.stylecCr�)zThe XSD type of this parameter.rnr�r]rrrrn�r�zParameter.typecCr�)a9The value to which this parameter is fixed, if any.

        A fixed parameter must be present in invocations of a WADL
        method, and it must have a particular value. This is commonly
        used to designate one parameter as containing the name of the
        server-side operation to be invoked.
        �fixedr�r]rrrr=�s	zParameter.fixed_valuecCs|jj�dd���dvS)z6Whether or not a value for this parameter is required.�required�false)�1�truer�r]rrrrA�s�zParameter.is_requiredcCs|j�|�S)z�The value of this parameter in the bound representation/headers.

        :raise NoBoundRepresentationError: If this parameter's value
               container is not bound to a representation or a set of
               headers.
        )r�r�r]rrr�	get_value�szParameter.get_valuecs�fdd��j�td��D�S)z7Return the set of acceptable values for this parameter.csg|]}t�|��qSr)�Option)r,�
option_tagr]rrr1�s�z%Parameter.options.<locals>.<listcomp>r:)r3r4rr]rr]rr>�s
�zParameter.optionscCs&|j�td��}|durdSt||�S)z�Get the link to another resource.

        The link may be examined and, if its type is of a known WADL
        description, it may be followed.

        :return: A Link object, or None.
        �linkN)r3r�rr)r5�link_tagrrrr�s	
zParameter.linkcCs|j}|durtd��|jS)aFollow a link from this parameter to a new resource.

        This only works for parameters whose WADL definition includes a
        <link> tag that points to a known WADL description.

        :return: A Resource object for the resource at the other end
        of the link.
        Nz(This parameter isn't a link to anything.)rr2�follow)r5rrrr�linked_resources
zParameter.linked_resourceN)r r!r"r#rLr�r<r)rnr=rArr>rr
rrrrr�s(





	


rc@s$eZdZdZdd�Zedd��ZdS)rz0One of a set of possible values for a parameter.cCs||_||_dS)z}Initialize the option.

        :param parameter: A Parameter.
        :param link_tag: An ElementTree <option> tag.
        N)r�r3)r5r�rrrrrLrMzOption.__init__cCr�)Nr9r�r]rrrr9 r�zOption.valueN)r r!r"r#rLr�r9rrrrrs
	rcsHeZdZdZ�fdd�Zedd��Zedd��Zdd	�Zd
d�Z	�Z
S)rz�A link from one resource to another.

    Calling resolve_definition() on a Link will give you a Resource for the
    type of resource linked to. An alias for this is 'follow'.
    cs"tt|��|j�||_||_dS)zyInitialize the link.

        :param parameter: A Parameter.
        :param link_tag: An ElementTree <link> tag.
        N)r_rrLrKr�r3)r5r�rrlrrrL,s
z
Link.__init__cCs|jstd��|��S)z$Follow the link to another Resource.zfCannot follow a link when the target has no WADL description. Try using a general HTTP client instead.)�
can_followr
rVr]rrrr	6szLink.followcCs$z|��}WdStyYdSw)z�Can this link be followed within wadllib?

        wadllib can follow a link if it points to a resource that has
        a WADL definition.
        FT)rOr
)r5�definition_urlrrrr?s
��zLink.can_followcCs t|j|j��|jj�|�j�S)z,Turn a resource type ID into a ResourceType.)rrKr�rr�r+r3rZrrrrQLs�zLink._definition_factorycCs"|jj�d�}|durtd��|S)z(Find the URL containing the definition .rjNzIParameter is a link, but not to a resource with a known WADL description.)r3r*r+r
)r5rnrrrrORszLink._get_definition_url)r r!r"r#rLr�r	rrQrOr�rrrlrr%s


rc@seZdZdZdd�ZdS)r	z,A wrapper around an XML <resource_type> tag.cCs
||_dS)zvInitialize with a <resource_type> tag.

        :param resource_type_tag: An ElementTree <resource_type> tag.
        N)r3)r5�resource_type_tagrrrrL^s
zResourceType.__init__N)r r!r"r#rLrrrrr	[sr	c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)rz1A WADL document made programmatically accessible.cCs�||_t|d�r|�|�|_n|�|�|_|j�td��|_|jj�	d�|_
i|_i|_|j�
td��D]}|j�	d�}|durKt|d|�}||j|<q4|j�
td��D]}|jd}t|�|j|<qTdS)z�Parse WADL and find the most important parts of the document.

        :param markup_url: The URL from which this document was obtained.
        :param markup: The WADL markup itself, or an open filehandle to it.
        �read�	resourcesrtrcr[Nrj)rp�hasattr�_from_streamr��_from_stringr�rrr*r+�
resource_baser�r�r4rr	)r5rp�markuprcr[rUrjrrrrLis(
�
�
�zApplication.__init__cCsvd}d}g}t�||�D])\}}|dkr|�|�q|dkr#|��q|dkr5|dur-|}|�tt|��qt�|�S)zrTurns markup into a document.

        Just a wrapper around ElementTree which keeps track of namespaces.
        )�start�start-ns�end-nsNrrr)�ET�	iterparser��pop�setr�r�ElementTree)r5�stream�events�rootr��event�elemrrrr�s
�
zApplication._from_streamcCs$t|t�s
|�d�}|�t�|��S)zTurns markup into a document.r�)rar�r�rr�r�)r5rrrrr�s

zApplication._from_stringcCs.|�|�}|j�|�}|durtd|��|S)z7Retrieve a resource type by the URL of its description.NrN)rPr�r+rR)r5�resource_type_urlrTrjrrrrb�s

zApplication.get_resource_typecCsZt|j���}d|_|�d�rt|���}n|�|�}|j}d|_||kr'|Std|��)z�A helper method for locating a part of a WADL document.

        :param url: The URL (with anchor) of the desired part of the
        WADL document.
        :return: The XML ID corresponding to the anchor.
        N�httpz,Can't look up definition in another url (%s))rrp�
ensureNoSlash�fragment�
startswith�resolverY)r5ri�
markup_uri�this_uri�possible_xml_idrrrrP�s

�zApplication.lookup_xml_idcsV�fdd�|jD�}t|�dkrdSt|�dkrtd���t|t|j�d�|d�S)zpLocate one of the resources described by this document.

        :param path: The path to the resource.
        csg|]}|jd�kr|�qS�r�)r*)r,r/r+rrr1�s
�z4Application.get_resource_by_path.<locals>.<listcomp>r�Nz+More than one resource defined with path %sTr)rr?r
rrr)r5r��matchingrr+r�get_resource_by_path�s��z Application.get_resource_by_pathN)
r r!r"r#rLrrrbrPr-rrrrrfs r)6r#rn�
__metaclass__�__all__r��email.utilsrr�rdr�r�r�r��urllib.parser
�ImportError�urllib�xml.etree.cElementTree�etree�cElementTreer�xml.etree.ElementTreer�lazr.urirr�wadllibrr�wadllib.iso_strptimerr�r�rrr�	Exceptionr
rr%r�r&r'rIrrr�rrrrrr	rrrrr�<module>s`
��	
B=>j9B"]6

Anon7 - 2022
AnonSec Team