§
    R
`ê»  ã                   óÒ  — d Z eZg d¢ZddlZddlmZ ddlZddlZddl	Z	ddl
Z
ddlZddlZ	 ddlmZ n# e$ r	 ddlmZ Y nw xY w	 ddlmc mZ n# e$ r ddlmc mZ Y nw xY wddlmZmZ ddlmZmZ ddlmZ d	Zd
Z d„ Z!d„ Z"d„ Z# G d„ de$¦  «        Z% G d„ de%¦  «        Z& G d„ de%¦  «        Z' G d„ de(¦  «        Z) G d„ d¦  «        Z* G d„ de)¦  «        Z+ G d„ de+¦  «        Z, G d„ de)¦  «        Z- G d„ de)e*¦  «        Z. G d „ d!e*¦  «        Z/ G d"„ d#e+e*¦  «        Z0 G d$„ d%e)¦  «        Z1 G d&„ d'e)¦  «        Z2 G d(„ d)e+¦  «        Z3 G d*„ d+e)¦  «        Z4 G d,„ d-e)¦  «        Z5dS ).aû  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/XMLSchemac                 ó   — d| z   S )z)Scope a tag name with the WADL namespace.z&{http://research.sun.com/wadl/2006/10}© ©Útag_names    ú5/usr/lib/python3/dist-packages/wadllib/application.pyÚwadl_tagr   H   s   € à3°hÑ>Ð>ó    c                 ó&   — dt          | ¦  «        z   S )z#Turn a tag name into an XPath path.z./)r   r   s    r   Ú
wadl_xpathr   M   s   € à•(˜8Ñ$Ô$Ñ$Ð$r   c                  óB   — i }| D ]}|�|                      |¦  «         Œ|S )z<Merge any number of dictionaries, some of which may be None.)Úupdate)ÚdictsÚfinalÚdicts      r   Ú_merge_dictsr"   R   s4   € à€EØð ð ˆØÐØ�LŠL˜ÑÔÐøØ€Lr   c                   ó   — e Zd ZdZdS )r   zAAn exception having to do with the state of the WADL application.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   [   s   € € € € € ØKÐKØ€Dr   r   c                   ó   — e Zd ZdZdS )r   aA  An 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.
    Nr$   r   r   r   r   r   `   s   € € € € € ðð ð ð r   r   c                   ó   — e Zd ZdZdS )Ú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.
    Nr$   r   r   r   r+   r+   j   s   € € € € € ðð ð ð r   r+   c                   ó   — e Zd ZdZdS )ÚWADLBasez?A base class for objects that contain WADL-derived information.Nr$   r   r   r   r-   r-   r   s   € € € € € ØIÐIÐIÐIr   r-   c                   ó$   — e Zd ZdZdd„Z	 dd„ZdS )ÚHasParametersMixinzAA mixin class for objects that have associated Parameter objects.Nc                 óÀ   ‡‡— ‰€| j         Š‰€t          d¦  «        ‚| j        €g S | j                             t	          d¦  «        ¦  «        }|€g S ˆˆfd„|D ¦   «         S )z6Find subsidiary parameters that have the given styles.Nz&Could not find any particular resourceÚparamc                 óh   •— g | ].}|j                              d ¦  «        ‰v ¯t          ‰|¦  «        ‘Œ/S )Ústyle)ÚattribÚgetr   )Ú.0Ú	param_tagÚresourceÚstyless     €€r   ú
<listcomp>z-HasParametersMixin.params.<locals>.<listcomp>„   sI   ø€ ð <ð <ð <ØØÔ#×'Ò'¨Ñ0Ô0°FÐ:Ð:õ ˜( IÑ.Ô.à:Ð:Ð:r   )r8   Ú
ValueErrorÚtagÚfindallr   )Úselfr9   r8   Ú
param_tagss    `` r   ÚparamszHasParametersMixin.paramsy   s‹   øø€ àÐØ”}ˆHØÐÝÐEÑFÔFÐFØŒ8ÐØˆIØ”X×%Ò%¥j°Ñ&9Ô&9Ñ:Ô:ˆ
ØÐØˆIð<ð <ð <ð <ð <Ø!+ð<ñ <ô <ð 	<r   Tc                 ó”  — t          ||¦  «        }i }|D ]è}|j        }|j        �C||v r5||         |j        k    r$t          d||         ›d|›d|j        ›d�¦  «        ‚|j        ||<   d„ |j        D ¦   «         }t          |¦  «        dk    r@||v r<||         |vr2t          d||         ›d|›d	d
                     |¦  «        ›d�¦  «        ‚|r|j        r||vrt          d|z  ¦  «        ‚||v r||         ||<   ||= Œét          |¦  «        dk    r7t          dd                     |                     ¦   «         ¦  «        z  ¦  «        ‚|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 'z' for parameter 'z' conflicts with fixed value 'ú'c                 ó   — g | ]	}|j         ‘Œ
S r   )Úvalue)r6   Úoptions     r   r:   z<HasParametersMixin.validate_param_values.<locals>.<listcomp>¥   s   € Ð@Ð@Ð@¨�v”|Ð@Ð@Ð@r   r   zInvalid value 'z': valid values are: "z", "ú"z$No value for required parameter '%s'zUnrecognized parameter(s): '%s'z', ')	r"   ÚnameÚfixed_valuer;   ÚoptionsÚlenÚjoinÚis_requiredÚkeys)	r>   r@   Úparam_valuesÚenforce_completenessÚkw_param_valuesÚvalidated_valuesr1   rG   rI   s	            r   Úvalidate_param_valuesz(HasParametersMixin.validate_param_valuesˆ   sÕ  € õ" $ L°/ÑBÔBˆØÐØð 	'ð 	'ˆEØ”:ˆDØÔ Ð,Ø˜LÐ(Ð(Ø$ TÔ*¨eÔ.?Ò?Ð?Ý$˜*à(4°TÔ(:Ð(:Ð(:¸D¸D¸DØ(-Ô(9Ð(9Ð(9ð&;ñ <ô <ð <ð &+Ô%6�˜TÑ"Ø@Ð@°%´-Ð@Ñ@Ô@ˆGÝ�G‘”˜qÒ Ð  T¨\Ð%9Ð%9Ø  Ô&¨gÐ5Ð5Ý �jà$ TÔ*Ð*Ð*¨D¨D¨D°&·+²+¸gÑ2FÔ2FÐ2FÐ2Fð"Hñ Iô Ið Ið %ð )¨Ô):ð )Ø Ð,Ð,Ý Ð!GØ#'ñ"(ñ )ô )ð )à�|Ð#Ð#Ø)5°dÔ);Ð  Ñ&Ø  Ð&øÝˆ|ÑÔ˜qÒ Ð ÝÐ>Ø%Ÿ{š{¨<×+<Ò+<Ñ+>Ô+>Ñ?Ô?ñ@ñ Aô Að AàÐr   ©N)T)r%   r&   r'   r(   r@   rR   r   r   r   r/   r/   v   sG   € € € € € ØKÐKð<ð <ð <ð <ð  48ð- ð - ð - ð - ð - ð - r   r/   c                   ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )ÚWADLResolvableDefinitionz=A base class for objects whose definitions may be references.c                 ó"   — d| _         || _        dS )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)r>   rX   s     r   Ú__init__z!WADLResolvableDefinition.__init__»   s   € ð  ˆÔØ&ˆÔÐÐr   c                 óô   — | j         �| j         S |                      ¦   «         }|€	| | _         | S | j                             |¦  «        }|                      |¦  «        }|€t          d|z  ¦  «        ‚|| _         |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")rW   Ú_get_definition_urlrX   Úlookup_xml_idÚ_definition_factoryÚKeyError)r>   Ú
object_urlÚxml_idÚ
definitions       r   Úresolve_definitionz+WADLResolvableDefinition.resolve_definitionÄ   s‘   € ð ÔÐ'ØÔ#Ð#Ø×-Ò-Ñ/Ô/ˆ
ØÐð  $ˆDÔØˆKð Ô!×/Ò/°
Ñ;Ô;ˆØ×-Ò-¨fÑ5Ô5ˆ
ØÐõ Ð1°JÑ>Ñ?Ô?Ð?Ø%ˆÔØÐr   c                 ó   — t          ¦   «         ‚)zxTransform an XML ID into a wadllib wrapper object.

        Which kind of object it is depends on the subclass.
        ©ÚNotImplementedError©r>   Úids     r   r^   z,WADLResolvableDefinition._definition_factoryæ   ó   € õ
 "Ñ#Ô#Ð#r   c                 ó   — t          ¦   «         ‚)zmFind the URL that identifies an external reference.

        How to do this depends on the subclass.
        re   ©r>   s    r   r\   z,WADLResolvableDefinition._get_definition_urlí   ri   r   N)r%   r&   r'   r(   rY   rc   r^   r\   r   r   r   rU   rU   ¸   sW   € € € € € ØGÐGð'ð 'ð 'ð ð  ð  ðD$ð $ð $ð$ð $ð $ð $ð $r   rU   c                   óà   ‡ — e Zd ZdZ	 	 	 dˆ fd„	Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	 	 	 dd	„Z	d
„ Z
	 	 dd„Zdd„Zdd„Zed„ ¦   «         Zdd„Zd„ Zd„ Zd„ Zd„ Zdd„Zd„ Zˆ xZS )r	   z/A resource, possibly bound to a representation.NTc                 óö  •— t          t          | ¦  «                             |¦  «         || _        t	          |t
          ¦  «        r%| j                             |¦  «        j        | _        n|| _        d| _	        |�I|dk    r1|r't          j        t          |¦  «        ¦  «        | _	        n|| _	        nt          d|z  ¦  «        ‚|| _        |�,|�	|| _        dS |                      | j        ¦  «        | _        dS dS )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)Úsuperr	   rY   Ú_urlÚ
isinstancer   rX   Úget_resource_typer<   ÚrepresentationÚjsonÚloadsr   r+   Ú
media_typeÚrepresentation_definitionÚget_representation_definition)	r>   rX   ÚurlÚresource_typers   rv   Úrepresentation_needs_processingrw   Ú	__class__s	           €r   rY   zResource.__init__ø   s"  ø€ õ* 	�h˜ÑÔ×&Ò& {Ñ3Ô3Ð3ØˆŒ	Ý�m¥]Ñ3Ô3ð 	%ð Ô'×9Ò9¸-ÑHÔHÔLˆDŒHˆHð %ˆDŒHà"ˆÔØÐ%ØÐ/Ò/Ð/Ø2ð 9Ý*.¬*Ý% nÑ5Ô5ñ+7ô +7�DÔ'Ð'ð +9�DÔ'Ð'å/ð$Ø&0ñ1ñ2ô 2ð 2ð %ˆŒØÐ%Ø(Ð4Ø1J�Ô.Ð.Ð.ð ×6Ò6°t´ÑGÔGð Ô.Ð.Ð.ð	 &Ð%r   c                 ó   — | j         S )z Return the URL to this resource.)rp   rk   s    r   ry   zResource.url,  s   € ð ŒyÐr   c                 ó   — | j         €dS | j         j                             d¦  «        }|�|S | j         j                             d¦  «        }|�@t          | j        j        ¦  «                             ¦   «         }t          |¦  «        dz   |z   S dS )z@Return the URL to the type definition for this resource, if any.NÚtyperh   ú#)r<   r4   r5   r   rX   Ú
markup_urlÚensureSlashÚstr)r>   ry   Útype_idÚbases       r   Útype_urlzResource.type_url1  sŠ   € ð Œ8ÐØ�4ØŒhŒo×!Ò! &Ñ)Ô)ˆØˆ?àˆJØ”(”/×%Ò% dÑ+Ô+ˆØÐå�tÔ'Ô2Ñ3Ô3×?Ò?ÑAÔAˆDÝ�t‘9”9˜s‘? WÑ,Ð,ð ˆtr   c                 ó&   — | j         j        d         S )zReturn the ID of this resource.rh   )r<   r4   rk   s    r   rh   zResource.idC  s   € ð ŒxŒ˜tÔ$Ð$r   rn   c           	      óJ   — t          | 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.
        )r	   rX   ry   r<   )r>   rs   rv   r{   rw   s        r   ÚbindzResource.bindH  s.   € õ" ˜Ô(¨$¬(°D´HØ&¨
Ø7Ø1ñ3ô 3ð 	3r   c                 óÚ   — |                       d¦  «        j        }|D ]=}|                     ¦   «         j        }|j                             d¦  «        |k    r|c S Œ>t          d|z  ¦  «        ‚)z<Get a description of one of this resource's representations.ÚGETÚ	mediaTypez4No definition for representation with media type %s.)Ú
get_methodÚresponserc   r<   r4   r5   r+   )r>   rv   Údefault_get_responsers   Úrepresentation_tags        r   rx   z&Resource.get_representation_definition^  sŒ   € à#Ÿš¨uÑ5Ô5Ô>ÐØ2ð 	&ð 	&ˆNØ!/×!BÒ!BÑ!DÔ!DÔ!HÐØ!Ô(×,Ò,¨[Ñ9Ô9¸ZÒGÐGØ%Ð%Ð%Ð%ð Hå'ð )>Ø@Jñ)Kñ Lô Lð 	Lr   c                 ó  — |                       ¦   «         D ]t}|j                             dd¦  «                             ¦   «         }|�||                     ¦   «         k    r+t	          | |¦  «        }|                     |||¦  «        r|c S ŒudS )a   Look 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.
        rG   Ú N)Ú_method_tag_iterr4   r5   Úlowerr   Úis_described_by)r>   Úhttp_methodrv   Úquery_paramsÚrepresentation_paramsÚ
method_tagrG   Úmethods           r   r�   zResource.get_methodh  sž   € ð0 ×/Ò/Ñ1Ô1ð 	"ð 	"ˆJØÔ$×(Ò(¨°Ñ4Ô4×:Ò:Ñ<Ô<ˆDØÐ" d¨k×.?Ò.?Ñ.AÔ.AÒ&AÐ&AÝ  jÑ1Ô1�Ø×)Ò)¨*°lØ*?ñAô Að "à!�M�M�MøØˆtr   c                 óR   — |                       |¦  «                             | ¦  «        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_definitionr@   ©r>   rv   s     r   Ú
parameterszResource.parameters‰  s*   € ð ×3Ò3Øñô ßš˜t™œð	%r   c                 óR   — |                       |¦  «                             | ¦  «        S )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�   s     r   r    zResource.parameter_names–  s,   € ð ×3Ò3Øñô ß'š¨Ñ-Ô-ð	.r   c              #   ó\   K  — |                       ¦   «         D ]}t          | |¦  «        V — ŒdS )z6An iterator over the methods defined on this resource.N)r“   r   )r>   r™   s     r   Úmethod_iterzResource.method_iter£  sF   è è € ð ×/Ò/Ñ1Ô1ð 	+ð 	+ˆJÝ˜˜zÑ*Ô*Ð*Ð*Ð*Ð*ð	+ð 	+r   c                 óè   — |                       |¦  «        }|j        }|                     t          d¦  «        ¦  «        D ]2}|j                             d¦  «        |k    rt          | |¦  «        c S Œ3dS )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.
        r1   rG   N)rœ   r<   r=   r   r4   r5   r   )r>   Ú
param_namerv   rb   r�   r7   s         r   Úget_parameterzResource.get_parameter©  s€   € ð ×9Ò9¸*ÑEÔEˆ
Ø'œ^ÐØ+×3Ò3µJ¸wÑ4GÔ4GÑHÔHð 	2ð 	2ˆIØÔ×#Ò# FÑ+Ô+¨zÒ9Ð9Ý   yÑ1Ô1Ð1Ð1Ð1ð :àˆtr   c                 ó  — | j         €t          d¦  «        ‚| j        dk    rÓ|j        dk    rt	          d|j        z  ¦  «        ‚| j         |j                 }|�›|                      |j        |j        ¦  «        \  }}|t          k    rm|dv ri	 t          |¦  «        }nX# t          $ rK 	 t          j        t          j        |d¦  «        dd	…         Ž }n# t          $ r t          |¦  «        ‚w xY wY nw xY w|S t	          d
| j        z  ¦  «        ‚)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.rn   Ú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.)rs   r   rv   r3   rf   rG   Ú_dereference_namespacer<   r   ÚXML_SCHEMA_NS_URIr   r;   ÚdatetimeÚtimeÚstrptime)r>   Ú	parameterrD   Únamespace_urlÚ	data_types        r   Úget_parameter_valuezResource.get_parameter_value¼  sl  € ð ÔÐ&Ý,Ø>ñ@ô @ð @àŒ?Ð0Ò0Ð0ð Œ 'Ò)Ð)Ý)ðØ!*¤ñ1ñ2ô 2ð 2ð Ô'¨	¬Ô7ˆEØÐ Ø+/×+FÒ+FØ”M 9¤>ñ,3ô ,3Ñ(�˜yà!Õ%6Ò6Ð6Ø!Ð%9Ð9Ð9ð4å ,¨UÑ 3Ô 3˜˜øÝ%ð 	4ð 	4ð 	4ð4Ý$,Ô$5Ý"&¤-°°zÑ"BÔ"BÀ1ÀQÀ3Ô"Gð%J˜E˜Eøå)ð 4ð 4ð 4õ #-¨UÑ"3Ô"3Ð3ð	4øøøð "˜Eð	4øøøð ˆLå!ð #Gà$(¤Oñ#4ñ 5ô 5ð 	5s*   ÂB Â
C0Â&)CÃC0ÃC*Ã*C0Ã/C0c                 ó®   — |�d|v r|                      dd¦  «        \  }}nd}|                     t          ¦  «        }|                     |d¦  «        }||fS )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’   )Úsplitr5   ÚNS_MAP)r>   r<   rD   Ú	namespaceÚns_mapr²   s         r   r¬   zResource._dereference_namespaceì  s^   € ð Ð ¨  Ø$Ÿ{š{¨3°Ñ2Ô2ÑˆI�u�uàˆIØ—’�‘”ˆØŸ
š
 9¨dÑ3Ô3ˆØ˜eÐ#Ð#r   c                 ó@   — | j         j                             |¦  «        S )z-Given an ID, find a ResourceType for that ID.)rX   Úresource_typesr5   rg   s     r   r^   zResource._definition_factoryú  s   € àÔÔ.×2Ò2°2Ñ6Ô6Ð6r   c                 ó@   — | j         j                             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.
        r   ©r<   r4   r5   rk   s    r   r\   zResource._get_definition_urlþ  ó   € ð ŒxŒ×"Ò" 6Ñ*Ô*Ð*r   c                 óº   — | j         �| j                             ¦   «         }n'|�|                      |¦  «        }nt	          d¦  «        ‚|                     ¦   «         S )a3  Get 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.)rs   rw   rc   rx   r   )r>   rv   rb   s      r   rœ   z(Resource._find_representation_definition  sk   € ð* ÔÐ*ð Ô7×JÒJÑLÔLˆJˆJØÐ#Ø×;Ò;¸JÑGÔGˆJˆJå,ð,ñ-ô -ð -ð ×,Ò,Ñ.Ô.Ð.r   c              #   óŽ   K  — |                       ¦   «         j        }|                     t          d¦  «        ¦  «        D ]}|V — ŒdS )z+Iterate over this resource's <method> tags.rš   N)rc   r<   r=   r   )r>   rb   r™   s      r   r“   zResource._method_tag_iter*  sX   è è € à×,Ò,Ñ.Ô.Ô2ˆ
Ø$×,Ò,­Z¸Ñ-AÔ-AÑBÔBð 	ð 	ˆJØÐÐÐÐð	ð 	r   )NNTN)rn   TN)NNNNrS   )r%   r&   r'   r(   rY   Úpropertyry   r†   rh   r‰   rx   r�   rž   r    r¢   r¥   r´   r¬   r^   r\   rœ   r“   Ú__classcell__©r|   s   @r   r	   r	   õ   s¯  ø€ € € € € Ø9Ð9ð 26Ø15Ø+/ð2Ið 2Ið 2Ið 2Ið 2Ið 2Iðh ðð ñ „Xðð ðð ñ „Xðð" ð%ð %ñ „Xð%ð /AØ-1Ø'+ð3ð 3ð 3ð 3ð,Lð Lð Lð JNØ)-ðð ð ð ðB%ð %ð %ð %ð.ð .ð .ð .ð ð+ð +ñ „Xð+ð
ð ð ð ð&-5ð -5ð -5ð`$ð $ð $ð7ð 7ð 7ð+ð +ð +ð /ð  /ð  /ð  /ðFð ð ð ð ð ð r   r	   c                   ó�   — e Zd ZdZd„ Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	dd„Z
	 	 dd	„Z	 	 dd
„ZdS )r   z*A wrapper around an XML <method> tag.
    c                 óD   — || _         | j         j        | _        || _        dS )zaInitialize with a <method> tag.

        :param method_tag: An ElementTree <method> tag.
        N)r8   rX   r<   )r>   r8   r™   s      r   rY   zMethod.__init__4  s#   € ð
 !ˆŒØœ=Ô4ˆÔØˆŒˆˆr   c                 ól   — t          | | j                             t          d¦  «        ¦  «        ¦  «        S )z@Return the definition of a request that invokes the WADL method.Úrequest)ÚRequestDefinitionr<   Úfindr   rk   s    r   rÉ   zMethod.request=  s*   € õ !  t¤x§}¢}µZÀ	Ñ5JÔ5JÑ'KÔ'KÑLÔLÐLr   c                 óv   — t          | j        | j                             t	          d¦  «        ¦  «        ¦  «        S )z9Return the definition of the response to the WADL method.rŽ   )r   r8   r<   rË   r   rk   s    r   rŽ   zMethod.responseB  s6   € õ " $¤-Ø"&¤(§-¢-µ
¸:Ñ0FÔ0FÑ"GÔ"GñIô Ið 	Ir   c                 ó@   — | j         j                             d¦  «        S )z)The XML ID of the WADL method definition.rh   r¿   rk   s    r   rh   z	Method.idH  s   € ð ŒxŒ×"Ò" 4Ñ(Ô(Ð(r   c                 ód   — | j         j                             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.
        rG   ©r<   r4   r5   r”   rk   s    r   rG   zMethod.nameM  s(   € ð ŒxŒ×"Ò" 6Ñ*Ô*×0Ò0Ñ2Ô2Ð2r   Nc                 ó(   —  | j         j        |fi |¤ŽS )ú4Return the request URL to use to invoke this method.)rÉ   Ú	build_url)r>   rN   rP   s      r   Úbuild_request_urlzMethod.build_request_urlV  s   € à%ˆtŒ|Ô% lÐFÐF°oÐFÐFÐFr   c                 ó*   —  | j         j        ||fi |¤ŽS )z‚Build a representation to be sent when invoking this method.

        :return: A 2-tuple of (media_type, representation).
        )rÉ   rs   )r>   rv   rN   rP   s       r   Úbuild_representationzMethod.build_representationZ  s/   € ð +ˆtŒ|Ô*Ø˜ð9ð 9Ø(7ð9ð 9ð 	9r   c                 óæ  — d}|�| j                              |¦  «        }|€dS |�Mt          |¦  «        dk    r:| j         }|€dS 	 |                     |j        |d¦  «         n# t
          $ r Y dS w xY w|�t          |¦  «        dk    rdS |�|                     |¦  «        S | j         j        D ]D}	 |                     |                     | j	        ¦  «        |d¦  «          dS # t
          $ r Y ŒAw xY wdS )a  Returns 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.
        NFr   T)
rÉ   rx   rJ   rR   r—   r;   r•   Úrepresentationsr@   r8   )r>   rv   Úquery_valuesÚrepresentation_valuesrs   rÉ   s         r   r•   zMethod.is_described_byc  sf  € ð$ ˆØÐ!Ø!œ\×GÒGØñô ˆNàÐ%Ø�uàÐ#­¨LÑ(9Ô(9¸AÒ(=Ð(=Ø”lˆGØˆð �uðØ×-Ò-ØÔ(¨,¸ñ?ô ?ð ?ð ?øåð ð ð Ø�u�uðøøøð "Ð)ÝÐ(Ñ)Ô)¨QÒ.Ð.Ø�4àÐ%Ø!×1Ò1Ø%ñ'ô 'ð 'à"œlÔ:ð 	ð 	ˆNðØ×4Ò4Ø"×)Ò)¨$¬-Ñ8Ô8Ø)¨5ñ2ô 2ð 2ð �t�tøÝð ð ð Ø�ðøøøàˆus$   ÁA! Á!
A/Á.A/Â//C!Ã!
C.Ã-C.rS   ©NN)NNN)r%   r&   r'   r(   rY   rÃ   rÉ   rŽ   rh   rG   rÓ   rÕ   r•   r   r   r   r   r   1  sð   € € € € € ðð ðð ð ð ðMð Mñ „XðMð ðIð Iñ „XðIð
 ð)ð )ñ „Xð)ð ð3ð 3ñ „Xð3ðGð Gð Gð Gð /3Ø*.ð9ð 9ð 9ð 9ð =AØ.2ð5ð 5ð 5ð 5ð 5ð 5r   r   c                   ó\   — e Zd ZdZd„ Zed„ ¦   «         Zed„ ¦   «         Zd	d„Zd
d„Z	d	d„Z
dS )rÊ   zBA wrapper around the description of the request invoking a method.c                 óf   — || _         | j         j        | _        | j        j        | _        || _        dS )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š   r8   rX   r<   )r>   rš   Úrequest_tags      r   rY   zRequestDefinition.__init__�  s/   € ð ˆŒØœÔ,ˆŒØœ=Ô4ˆÔØˆŒˆˆr   c                 ó.   — |                       dg¦  «        S )z,Return the query parameters for this method.Úquery©r@   rk   s    r   r—   zRequestDefinition.query_params¨  s   € ð �{Š{˜G˜9Ñ%Ô%Ð%r   c              #   ó˜   K  — | j                              t          d¦  «        ¦  «        D ]}t          | j        | j        |¦  «        V — Œ d S )Nrs   )r<   r=   r   r   rX   r8   )r>   rb   s     r   r×   z!RequestDefinition.representations­  se   è è € àœ(×*Ò*­:Ð6FÑ+GÔ+GÑHÔHð 	=ð 	=ˆJÝ*ØÔ  $¤-°ñ=ô =ð =ð =ð =ð =ð	=ð 	=r   Nc                 ó<   — | j         D ]}|�|j        |k    r|c S ŒdS )z1Return the appropriate representation definition.N)r×   rv   ©r>   rv   rs   s      r   rx   z/RequestDefinition.get_representation_definition³  s>   € à"Ô2ð 	&ð 	&ˆNØÐ! ^Ô%>À*Ò%LÐ%LØ%Ð%Ð%Ð%ð &Màˆtr   c                 óp   — |                       |¦  «        }|€t          d|z  ¦  «        ‚ |j        |fi |¤Ž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)rx   Ú	TypeErrorr‰   )r>   rv   rN   rP   rb   s        r   rs   z RequestDefinition.representationº  sT   € ð ×7Ò7¸
ÑCÔCˆ
ØÐÝÐJØ(ñ)ñ *ô *ð *àˆzŒ˜|Ð?Ð?¨Ð?Ð?Ð?r   c                 óæ   —  | j         | j        |fi |¤Ž}| j        j        }t	          |¦  «        dk    r=d|v rd}nd}||t          t          |                     ¦   «         ¦  «        ¦  «        z   z  }|S )rÑ   r   ú?ú&)rR   r—   r8   ry   rJ   r   ÚsortedÚitems)r>   rN   rP   rQ   ry   Úappends         r   rÒ   zRequestDefinition.build_urlÆ  s”   € à5˜4Ô5ØÔ˜|ð@ð @Ø/>ð@ð @ÐàŒmÔˆÝÐÑ Ô  1Ò$Ð$Ø�cˆzˆzØ��à�Ø�6�I¥fÐ-=×-CÒ-CÑ-EÔ-EÑ&FÔ&FÑGÔGÑGÑGˆCØˆ
r   rS   rÚ   )r%   r&   r'   r(   rY   rÃ   r—   r×   rx   rs   rÒ   r   r   r   rÊ   rÊ   ›  sŸ   € € € € € ØLÐLð	ð 	ð 	ð ð&ð &ñ „Xð&ð ð=ð =ñ „Xð=ð
ð ð ð ð
@ð 
@ð 
@ð 
@ðð ð ð ð ð r   rÊ   c                   ó8   — e Zd ZdZd	d„Zd„ Zd„ Zd„ Zd„ Zd„ Z	dS )
r   z;A wrapper around the description of a response to a method.Nc                 óH   — |j         | _         || _        || _        || _        dS )zgInitialize with a <response> tag.

        :param response_tag: An ElementTree <response> tag.
        N)rX   r8   r<   Úheaders)r>   r8   Úresponse_tagrî   s       r   rY   zResponseDefinition.__init__Ü  s(   € ð
 $Ô/ˆÔØ ˆŒØˆŒØˆŒˆˆr   c              #   ó¦   K  — t          d¦  «        }| j                             |¦  «        D ]$}t          | j        j        | j        |¦  «        V — Œ%dS )z¢Get an iterator over the representation definitions.

        These are the representations returned in response to an
        invocation of this method.
        rs   N)r   r<   r=   r   r8   rX   )r>   Úpathr�   s      r   Ú__iter__zResponseDefinition.__iter__æ  sz   è è € õ Ð*Ñ+Ô+ˆØ"&¤(×"2Ò"2°4Ñ"8Ô"8ð 	Nð 	NÐÝ*Ø”Ô)¨4¬=Ð:LñNô Nð Nð Nð Nð Nð	Nð 	Nr   c                 ó8   — t          | 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.
        )r   r8   r<   )r>   rî   s     r   r‰   zResponseDefinition.bindñ  s   € õ " $¤-°´¸7ÑCÔCÐCr   c                 óö   — | j                              t          d¦  «        ¦  «        D ]P}|j                             d¦  «        |k    r0|j                             d¦  «        dk    rt          | |¦  «        c S ŒQdS )z,Find a header parameter within the response.r1   rG   r3   ÚheaderN)r<   r=   r   r4   r5   r   )r>   r¤   r7   s      r   r¥   z ResponseDefinition.get_parameterù  s}   € àœ×)Ò)­*°WÑ*=Ô*=Ñ>Ô>ð 	2ð 	2ˆIØÔ ×$Ò$ VÑ,Ô,°
Ò:Ð:ØÔ$×(Ò(¨Ñ1Ô1°XÒ=Ð=Ý   yÑ1Ô1Ð1Ð1Ð1øØˆtr   c                 ó°   — | j         €t          d¦  «        ‚|j        dk    rt          d|j        z  ¦  «        ‚| 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î   r   r3   rf   r5   rG   )r>   r±   s     r   r´   z&ResponseDefinition.get_parameter_value  sj   € àŒ<ÐÝ,Ø>ñ@ô @ð @àŒ?˜hÒ&Ð&Ý%ðØ&œ_ñ-ñ.ô .ð .ð Œ|×Ò 	¤Ñ/Ô/Ð/r   c                 ó@   — | j         €dS | D ]}|j        |k    r|c S ŒdS )z8Get one of the possible representations of the response.N)r<   rv   rã   s      r   rx   z0ResponseDefinition.get_representation_definition  sB   € àŒ8ÐØ�4Ø"ð 	&ð 	&ˆNØÔ(¨JÒ6Ð6Ø%Ð%Ð%Ð%ð 7àˆtr   rS   )
r%   r&   r'   r(   rY   rò   r‰   r¥   r´   rx   r   r   r   r   r   Ô  s   € € € € € ØEÐEðð ð ð ð	Nð 	Nð 	NðDð Dð Dðð ð ð	0ð 	0ð 	0ðð ð ð ð r   r   c                   ót   ‡ — e Zd ZdZˆ fd„Zˆ fd„Zd„ Zed„ ¦   «         Zd„ Z	d„ Z
dd	„Zd
„ Zd„ Zd„ Zd„ Zˆ xZS )r   z2A definition of the structure of a representation.c                 ót   •— t          t          | ¦  «                             |¦  «         || _        || _        d S rS   )ro   r   rY   r8   r<   )r>   rX   r8   r�   r|   s       €r   rY   z!RepresentationDefinition.__init__  s4   ø€ ÝÕ&¨Ñ-Ô-×6Ò6°{ÑCÔCÐCØ ˆŒØ%ˆŒˆˆr   c                 óZ   •— t          t          | ¦  «                             ddg|¦  «        S )Nrß   r§   )ro   r   r@   )r>   r8   r|   s     €r   r@   zRepresentationDefinition.params  s0   ø€ ÝÕ-¨tÑ4Ô4×;Ò;Ø�gÐ ñ*ô *ð 	*r   c                 ó@   — d„ |                       |¦  «        D ¦   «         S )z#Return the names of all parameters.c                 ó   — g | ]	}|j         ‘Œ
S r   )rG   )r6   r1   s     r   r:   z<RepresentationDefinition.parameter_names.<locals>.<listcomp>$  s   € Ð>Ð>Ð>˜u�”
Ð>Ð>Ð>r   rà   )r>   r8   s     r   r    z(RepresentationDefinition.parameter_names"  s"   € à>Ð>¨¯ª°HÑ(=Ô(=Ð>Ñ>Ô>Ð>r   c                 óJ   — |                       ¦   «         j        j        d         S )z4The media type of the representation described here.rŒ   )rc   r<   r4   rk   s    r   rv   z#RepresentationDefinition.media_type&  s!   € ð ×&Ò&Ñ(Ô(Ô,Ô3°KÔ@Ð@r   c                 óš  — t          t          t          j        dz
  ¦  «        ¦  «        }d|z  }t	          j        t          j        ¦  «        }d||z  z   dz   }|€|S |}d}	 dt          j        |¦  «        z   d	z                        d
¦  «        }t          j	        ||t          j
        ¬¦  «        sn|dz   t          |¦  «        z   }|dz  }Œj|S )z;Make a random boundary that does not appear in `all_parts`.r·   z%%0%ddz===============z==Nr   Tz^--z(--)?$Úascii)Úflagsú.)rJ   ÚreprÚsysÚmaxsizeÚrandomÚ	randrangeÚreÚescapeÚencodeÚsearchÚ	MULTILINErƒ   )	r>   Ú	all_partsÚ_widthÚ_fmtÚtokenÚboundaryÚbÚcounterÚpatterns	            r   Ú_make_boundaryz'RepresentationDefinition._make_boundary+  sÒ   € å•T�#œ+¨™/Ñ*Ô*Ñ+Ô+ˆØ˜&Ñ ˆÝÔ ¥¤Ñ-Ô-ˆØ ¨¡Ñ.°Ñ5ˆØÐØˆOØˆØˆð	Ø�rœy¨™|œ|Ñ+¨hÑ6×>Ò>¸wÑGÔGˆGÝ”9˜W iµr´|ÐDÑDÔDð ØØ˜3‘¥ W¡¤Ñ-ˆAØ�q‰LˆGð	ð ˆr   c                 ó4  — |D ]\  }}|                      |                     d¦  «        ¦  «         |                      d¦  «         |                      |                     d¦  «        ¦  «         |                      d¦  «         Œ€|                      d¦  «         dS )z$Write MIME headers to a file object.úUTF-8s   : ó   
N©Úwriter	  )r>   Úbufrî   ÚkeyrD   s        r   Ú_write_headersz'RepresentationDefinition._write_headers=  s�   € à!ð 	ð 	‰JˆC�Ø�IŠI�c—j’j Ñ)Ô)Ñ*Ô*Ð*Ø�IŠI�eÑÔÐØ�IŠI�e—l’l 7Ñ+Ô+Ñ,Ô,Ð,Ø�IŠI�gÑÔÐÐØ�	Š	�'ÑÔÐÐÐr   Fc                 óØ   — |                      d¦  «         |                      |                     d¦  «        ¦  «         |r|                      d¦  «         |                      d¦  «         dS )z,Write a multipart boundary to a file object.s   --r  r  Nr  )r>   r  r  Úclosings       r   Ú_write_boundaryz(RepresentationDefinition._write_boundaryF  sd   € à�	Š	�%ÑÔÐØ�	Š	�(—/’/ 'Ñ*Ô*Ñ+Ô+Ð+Øð 	Ø�IŠI�eÑÔÐØ�	Š	�'ÑÔÐÐÐr   c                 ó  — g }|D �]§\  }}}t          j        ¦   «         }|r&d}dt          |¦  «        ›dt          |¦  «        ›d�}nd}dt          |¦  «        z  }|                      |dd|fd	|fg¦  «         |rJt	          |t
          ¦  «        st          d
t          |¦  «        z  ¦  «        ‚|                     |¦  «         nÁt	          |t          ¦  «        st          dt          |¦  «        z  ¦  «        ‚t          j        d|¦  «        }	|	dd…         D ]?}
|                     |
                     d¦  «        ¦  «         |                     d¦  «         Œ@|                     |	d                              d¦  «        ¦  «         |                     |                     ¦   «         ¦  «         �Œ©|                      d                     |¦  «        ¦  «        }t          j        ¦   «         }dt          |¦  «        z  }|                      |dd|fg¦  «         |D ]B}|                      ||¦  «         |                     |¦  «         |                     d¦  «         ŒC|                      ||d¬¦  «         ||                     ¦   «         fS )aV  Generate 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.
        zapplication/octet-streamzform-data; name="z"; filename="rF   ztext/plain; charset="utf-8"zform-data; name="%s")zMIME-Versionz1.0zContent-TypezContent-Dispositionzbytes payload expected: %szstring payload expected: %sz
\r\n|\r|\nNéÿÿÿÿr  r  z"multipart/form-data; boundary="%s"T)r  )ÚioÚBytesIOr   r  rq   Úbytesrå   r   r  r   r  r¸   r	  rë   Úgetvaluer  rK   r  )r>   ÚpartsÚencoded_partsÚ	is_binaryrG   rD   r  ÚctypeÚcdispÚlinesÚliner  Úencoded_parts                r   Ú_generate_multipart_formz1RepresentationDefinition._generate_multipart_formN  sª  € ð ˆØ&+ð 	1ñ 	1Ñ"ˆI�t˜UÝ”*‘,”,ˆCØð 	=Ø2��õ
 ˜$‘K”K�K�K¥ t¡¤  ð.��ð 6�Ø.µ°t±´Ñ<�Ø×Ò Ø'Ø Ð'Ø&¨Ð.ð&ñ ô ð ð
 ð 5Ý! %­Ñ/Ô/ð PÝ#Ð$@Å4ÈÁ;Ä;Ñ$NÑOÔOÐOØ—	’	˜%Ñ Ô Ð Ð å! %­Ñ7Ô7ð EÝ#Ø5½¸U¹¼ÑCñEô Eð Eåœ °Ñ6Ô6�Ø! # 2 #œJð 'ð '�DØ—I’I˜dŸkšk¨'Ñ2Ô2Ñ3Ô3Ð3Ø—I’I˜gÑ&Ô&Ð&Ð&Ø—	’	˜% œ)×*Ò*¨7Ñ3Ô3Ñ4Ô4Ð4Ø× Ò  §¢¡¤Ñ0Ô0Ð0Ñ0ð ×&Ò& w§|¢|°MÑ'BÔ'BÑCÔCˆõ Œj‰lŒlˆØ4µu¸X±´ÑFˆØ×Ò˜CØ#Ø˜UÐ#ð"ñ 	ô 	ð 	ð *ð 	ð 	ˆLØ× Ò   hÑ/Ô/Ð/Ø�IŠI�lÑ#Ô#Ð#Ø�IŠI�gÑÔÐÐØ×Ò˜S (°DÐÑ9Ô9Ð9à�c—l’l‘n”nÐ$Ð$r   c                 óH  — |                       ¦   «         }|                     | j        ¦  «        } | j        ||fi |¤Ž}| j        }|dk    r/t          t          |                     ¦   «         ¦  «        ¦  «        }n¦|dk    rsg }t          ¦   «         }	|D ]G}
| 	                    |
j
        |	¦  «        }||	ur&|                     |
j        dk    |
j
        |f¦  «         ŒH|                      |¦  «        \  }}n-|dk    rt          j        |¦  «        }nt!          d|z  ¦  «        ‚||fS )zzBind the definition to parameter values, creating a document.

        :return: A 2-tuple (media_type, document).
        z!application/x-www-form-urlencodedzmultipart/form-dataÚbinaryrn   zUnsupported media type: '%s')rc   r@   r8   rR   rv   r   ré   rê   Úobjectr5   rG   rë   r   r.  rt   Údumpsr;   )r>   rN   rP   rb   r@   rQ   rv   Údocr&  Úmissingr1   rD   s               r   r‰   zRepresentationDefinition.bind�  sM  € ð
 ×,Ò,Ñ.Ô.ˆ
Ø×"Ò" 4¤=Ñ1Ô1ˆØ5˜4Ô5Ø�Lð5ð 5Ø$3ð5ð 5Ðà”_ˆ
ØÐ<Ò<Ð<Ý�FÐ#3×#9Ò#9Ñ#;Ô#;Ñ<Ô<Ñ=Ô=ˆCˆCØÐ0Ò0Ð0ØˆEÝ‘h”hˆGØð Nð N�Ø(×,Ò,¨U¬Z¸ÑAÔA�Ø Ð'Ð'Ø—L’L %¤*°Ò"8¸%¼*ÀeÐ!LÑMÔMÐMøØ"×;Ò;¸EÑBÔB‰OˆJ˜˜ØÐ-Ò-Ð-Ý”*Ð-Ñ.Ô.ˆCˆCåÐ;¸jÑHÑIÔIÐIØ˜3ˆÐr   c                 ó@   — | j         j                             |¦  «        S )z9Turn a representation ID into a RepresentationDefinition.)rX   Úrepresentation_definitionsr5   rg   s     r   r^   z,RepresentationDefinition._definition_factory©  s   € àÔÔ:×>Ò>¸rÑBÔBÐBr   c                 ó@   — | j         j                             d¦  «        S )a  Find 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¿   rk   s    r   r\   z,RepresentationDefinition._get_definition_url­  rÀ   r   )F)r%   r&   r'   r(   rY   r@   r    rÃ   rv   r  r  r  r.  r‰   r^   r\   rÄ   rÅ   s   @r   r   r     sö   ø€ € € € € Ø<Ð<ð&ð &ð &ð &ð &ð
*ð *ð *ð *ð *ð?ð ?ð ?ð ðAð Añ „XðAðð ð ð$ð ð ðð ð ð ð?%ð ?%ð ?%ðBð ð ð4Cð Cð Cð+ð +ð +ð +ð +ð +ð +r   r   c                   óÎ   — e Zd ZdZd„ Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	ed„ ¦   «         Z
d„ Zed	„ ¦   «         Zed
„ ¦   «         Zed„ ¦   «         ZdS )r   z5One of the parameters of a representation definition.c                 ó:   — |j         | _         || _        || _        dS )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)rX   Úvalue_containerr<   )r>   r;  r<   s      r   rY   zParameter.__init__º  s"   € ð +Ô6ˆÔØ.ˆÔØˆŒˆˆr   c                 ó@   — | j         j                             d¦  «        S )zThe name of this parameter.rG   r¿   rk   s    r   rG   zParameter.nameÈ  ó   € ð ŒxŒ×"Ò" 6Ñ*Ô*Ð*r   c                 ó@   — | j         j                             d¦  «        S )zThe style of this parameter.r3   r¿   rk   s    r   r3   zParameter.styleÍ  s   € ð ŒxŒ×"Ò" 7Ñ+Ô+Ð+r   c                 ó@   — | j         j                             d¦  «        S )zThe XSD type of this parameter.r   r¿   rk   s    r   r   zParameter.typeÒ  r=  r   c                 ó@   — | j         j                             d¦  «        S )a9  The 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¿   rk   s    r   rH   zParameter.fixed_value×  s   € ð ŒxŒ×"Ò" 7Ñ+Ô+Ð+r   c                 ój   — | j         j                             dd¦  «                             ¦   «         dv S )z6Whether or not a value for this parameter is required.ÚrequiredÚfalse)Ú1ÚtruerÏ   rk   s    r   rL   zParameter.is_requiredâ  s4   € ð ””×#Ò# J°Ñ8Ô8×>Ò>Ñ@Ô@Ø ð!ð 	"r   c                 ó6   — | 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´   rk   s    r   Ú	get_valuezParameter.get_valueè  s   € ð Ô#×7Ò7¸Ñ=Ô=Ð=r   c                 ój   ‡ — ˆ fd„‰ j                              t          d¦  «        ¦  «        D ¦   «         S )z7Return the set of acceptable values for this parameter.c                 ó0   •— g | ]}t          ‰|¦  «        ‘ŒS r   )ÚOption)r6   Ú
option_tagr>   s     €r   r:   z%Parameter.options.<locals>.<listcomp>ô  s9   ø€ ð Kð Kð KØõ �t˜ZÑ(Ô(ð Kð Kð Kr   rE   )r<   r=   r   rk   s   `r   rI   zParameter.optionsñ  sN   ø€ ðKð Kð Kð KØ#'¤8×#3Ò#3µJ¸xÑ4HÔ4HÑ#IÔ#IðKñ Kô Kð 	Kr   c                 óx   — | j                              t          d¦  «        ¦  «        }|€dS t          | |¦  «        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)r<   rË   r   r   )r>   Úlink_tags     r   rN  zParameter.link÷  s:   € ð ”8—=’=¥¨FÑ!3Ô!3Ñ4Ô4ˆØÐØ�4Ý�D˜(Ñ#Ô#Ð#r   c                 ó@   — | j         }|€t          d¦  «        ‚|j        S )a  Follow 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.)rN  r;   Úfollow)r>   rN  s     r   Úlinked_resourcezParameter.linked_resource  s'   € ð ŒyˆØˆ<ÝÐGÑHÔHÐHØŒ{Ðr   N)r%   r&   r'   r(   rY   rÃ   rG   r3   r   rH   rL   rH  rI   rN  rR  r   r   r   r   r   ·  s  € € € € € Ø?Ð?ðð ð ð ð+ð +ñ „Xð+ð ð,ð ,ñ „Xð,ð ð+ð +ñ „Xð+ð ð,ð ,ñ „Xð,ð ð"ð "ñ „Xð"ð
>ð >ð >ð ðKð Kñ „XðKð
 ð$ð $ñ „Xð$ð ðð ñ „Xðð ð r   r   c                   ó.   — e Zd ZdZd„ Zed„ ¦   «         ZdS )rK  z0One of a set of possible values for a parameter.c                 ó"   — || _         || _        dS )z}Initialize the option.

        :param parameter: A Parameter.
        :param link_tag: An ElementTree <option> tag.
        N)r±   r<   )r>   r±   rL  s      r   rY   zOption.__init__  s   € ð #ˆŒØˆŒˆˆr   c                 ó@   — | j         j                             d¦  «        S )NrD   r¿   rk   s    r   rD   zOption.value   s   € àŒxŒ×"Ò" 7Ñ+Ô+Ð+r   N)r%   r&   r'   r(   rY   rÃ   rD   r   r   r   rK  rK    sD   € € € € € Ø:Ð:ðð ð ð ð,ð ,ñ „Xð,ð ,ð ,r   rK  c                   óZ   ‡ — e Zd ZdZˆ fd„Zed„ ¦   «         Zed„ ¦   «         Zd„ Zd„ Z	ˆ xZ
S )r   zµ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'.
    c                 ó~   •— t          t          | ¦  «                             |j        ¦  «         || _        || _        dS )zyInitialize the link.

        :param parameter: A Parameter.
        :param link_tag: An ElementTree <link> tag.
        N)ro   r   rY   rX   r±   r<   )r>   r±   rO  r|   s      €r   rY   zLink.__init__,  s8   ø€ õ 	�d�DÑÔ×"Ò" 9Ô#8Ñ9Ô9Ð9Ø"ˆŒØˆŒˆˆr   c                 óV   — | j         st          d¦  «        ‚|                      ¦   «         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   rc   rk   s    r   rQ  zLink.follow6  s9   € ð Œð 	/Ýð .ñ /ô /ð /ð ×&Ò&Ñ(Ô(Ð(r   c                 óT   — 	 |                       ¦   «         }n# t          $ r Y dS w xY wdS )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)r\   r   )r>   Údefinition_urls     r   rY  zLink.can_follow?  sA   € ð	Ø!×5Ò5Ñ7Ô7ˆNˆNøÝð 	ð 	ð 	Ø�5�5ð	øøøàˆts   ‚ —
%¤%c                 ó    — t          | j        | j                             ¦   «         | j        j                             |¦  «        j        ¦  «        S )z,Turn a resource type ID into a ResourceType.)r	   rX   r±   rH  r½   r5   r<   rg   s     r   r^   zLink._definition_factoryL  sD   € åØÔ˜dœn×6Ò6Ñ8Ô8ØÔÔ+×/Ò/°Ñ3Ô3Ô7ñ9ô 9ð 	9r   c                 óf   — | j         j                             d¦  «        }|€t          d¦  «        ‚|S )z(Find the URL containing the definition .rz   NzIParameter is a link, but not to a resource with a known WADL description.)r<   r4   r5   r   )r>   r   s     r   r\   zLink._get_definition_urlR  s:   € àŒxŒ×"Ò" ?Ñ3Ô3ˆØˆ<Ýð =ñ >ô >ð >àˆr   )r%   r&   r'   r(   rY   rÃ   rQ  rY  r^   r\   rÄ   rÅ   s   @r   r   r   %  s–   ø€ € € € € ðð ðð ð ð ð ð ð)ð )ñ „Xð)ð ð
ð 
ñ „Xð
ð9ð 9ð 9ðð ð ð ð ð ð r   r   c                   ó   — e Zd ZdZd„ ZdS )r
   z,A wrapper around an XML <resource_type> tag.c                 ó   — || _         dS )zvInitialize with a <resource_type> tag.

        :param resource_type_tag: An ElementTree <resource_type> tag.
        N)r<   )r>   Úresource_type_tags     r   rY   zResourceType.__init__^  s   € ð
 %ˆŒˆˆr   N)r%   r&   r'   r(   rY   r   r   r   r
   r
   [  s)   € € € € € Ø6Ð6ð%ð %ð %ð %ð %r   r
   c                   ó6   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	dS )	r   z1A WADL document made programmatically accessible.c                 ó¸  — || _         t          |d¦  «        r|                      |¦  «        | _        n|                      |¦  «        | _        | j                             t          d¦  «        ¦  «        | _        | j        j         	                    d¦  «        | _
        i | _        i | _        | j                             t          d¦  «        ¦  «        D ]9}|j         	                    d¦  «        }|�t          | d|¦  «        }|| j        |<   Œ:| j                             t          d¦  «        ¦  «        D ]&}|j        d         }t          |¦  «        | j        |<   Œ'dS )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Ú	resourcesr…   rs   rh   Nrz   )r�   ÚhasattrÚ_from_streamr3  Ú_from_stringrË   r   rd  r4   r5   Úresource_baser6  r½   r=   r   r
   )r>   r�   Úmarkuprs   rh   rb   rz   s          r   rY   zApplication.__init__i  sT  € ð %ˆŒÝ�6˜6Ñ"Ô"ð 	1Ø×(Ò(¨Ñ0Ô0ˆDŒHˆHà×(Ò(¨Ñ0Ô0ˆDŒHØœŸš¥z°+Ñ'>Ô'>Ñ?Ô?ˆŒØ!œ^Ô2×6Ò6°vÑ>Ô>ˆÔØ*,ˆÔ'Ø ˆÔØ"œh×.Ò.­zÐ:JÑ/KÔ/KÑLÔLð 	Að 	AˆNØÔ&×*Ò*¨4Ñ0Ô0ˆBØˆ~Ý5Ø˜$ ñ0ô 0�
à6@�Ô/°Ñ3øØ!œX×-Ò-­j¸Ñ.IÔ.IÑJÔJð 	Bð 	BˆMØÔ% dÔ+ˆBÝ&2°=Ñ&AÔ&AˆDÔ Ñ#Ð#ð	Bð 	Br   c                 ó>  — d}d}g }t          j        ||¦  «        D ]n\  }}|dk    r|                     |¦  «         Œ!|dk    r|                     ¦   «          Œ<|dk    r,|€|}|                     t
          t          |¦  «        ¦  «         Œot          j        |¦  «        S )zrTurns markup into a document.

        Just a wrapper around ElementTree which keeps track of namespaces.
        )Ústartústart-nsúend-nsNrl  rm  rk  )ÚETÚ	iterparserë   ÚpopÚsetr¹   r!   ÚElementTree)r>   ÚstreamÚeventsÚrootr»   ÚeventÚelems          r   rf  zApplication._from_stream‚  s¬   € ð
 /ˆØˆØˆåœ<¨°Ñ7Ô7ð 	/ð 	/‰KˆE�4Ø˜
Ò"Ð"Ø—’˜dÑ#Ô#Ð#Ð#Ø˜(Ò"Ð"Ø—
’
‘”��Ø˜'Ò!Ð!Ø�<Ø�DØ—’�¥ f¡¤Ñ.Ô.Ð.øÝŒ~˜dÑ#Ô#Ð#r   c                 ó¤   — t          |t          ¦  «        s|                     d¦  «        }|                      t	          j        |¦  «        ¦  «        S )zTurns markup into a document.r  )rq   r$  r	  rf  r"  r#  )r>   ri  s     r   rg  zApplication._from_string–  sC   € å˜&¥%Ñ(Ô(ð 	,Ø—]’] 7Ñ+Ô+ˆFØ× Ò ¥¤¨FÑ!3Ô!3Ñ4Ô4Ð4r   c                 óŒ   — |                       |¦  «        }| j                             |¦  «        }|€t          d|z  ¦  «        ‚|S )z7Retrieve a resource type by the URL of its description.Nr[   )r]   r½   r5   r_   )r>   Úresource_type_urlra   rz   s       r   rr   zApplication.get_resource_typeœ  sM   € à×#Ò#Ð$5Ñ6Ô6ˆØÔ+×/Ò/°Ñ7Ô7ˆØÐ ÝÐ1Ð4EÑEÑFÔFÐFØÐr   c                 óD  — t          | j        ¦  «                             ¦   «         }d|_        |                     d¦  «        r"t          |¦  «                             ¦   «         }n|                     |¦  «        }|j        }d|_        ||k    r|S t          d|z  ¦  «        ‚)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))r   r�   ÚensureNoSlashÚfragmentÚ
startswithÚresolverf   )r>   ry   Ú
markup_uriÚthis_uriÚpossible_xml_ids        r   r]   zApplication.lookup_xml_id¤  s­   € õ ˜œÑ)Ô)×7Ò7Ñ9Ô9ˆ
Ø"ˆ
Ôà�>Š>˜&Ñ!Ô!ð 	/å˜3‘x”x×-Ò-Ñ/Ô/ˆHˆHð "×)Ò)¨#Ñ.Ô.ˆHØ"Ô+ˆØ ˆÔà�zÒ!Ð!ð #Ð"õ "ð #-Ø/2ñ#3ñ 4ô 4ð 	4r   c                 óô   ‡— ˆfd„| j         D ¦   «         }t          |¦  «        dk     rdS t          |¦  «        dk    rt          d‰z  ¦  «        ‚t          | t	          | j        ‰d¦  «        |d         ¦  «        S )zpLocate one of the resources described by this document.

        :param path: The path to the resource.
        c                 ó6   •— g | ]}|j         d          ‰k    ¯|‘ŒS )rñ   )r4   )r6   r8   rñ   s     €r   r:   z4Application.get_resource_by_path.<locals>.<listcomp>Ì  s4   ø€ ð 8ð 8ð 8 Ø” vÔ.°$Ò6Ð6ð Ø6Ð6Ð6r   r·   Nz+More than one resource defined with path %sTr   )rd  rJ   r   r	   r   rh  )r>   rñ   Úmatchings    ` r   Úget_resource_by_pathz Application.get_resource_by_pathÄ  sŸ   ø€ ð8ð 8ð 8ð 8¨T¬^ð 8ñ 8ô 8ˆåˆx‰=Œ=˜1ÒÐØ�4Ýˆx‰=Œ=˜1ÒÐÝÐIØ"ñ#ñ $ô $ð $åØ•%˜Ô*¨D°$Ñ7Ô7¸À!¼ñFô Fð 	Fr   N)
r%   r&   r'   r(   rY   rf  rg  rr   r]   r‡  r   r   r   r   r   f  s}   € € € € € Ø;Ð;ðBð Bð Bð2$ð $ð $ð(5ð 5ð 5ðð ð ð4ð 4ð 4ð@Fð Fð Fð Fð Fr   r   )6r(   r   Ú__metaclass__Ú__all__r®   Úemail.utilsr   r"  rt   r  r  r  r¯   Úurllib.parser   ÚImportErrorÚurllibÚxml.etree.cElementTreeÚetreeÚcElementTreern  Úxml.etree.ElementTreerr  Úlazr.urir   r   Úwadllibr   r   Úwadllib.iso_strptimer   r¹   r­   r   r   r"   Ú	Exceptionr   r   r+   r1  r-   r/   rU   r	   r   rÊ   r   r   r   rK  r   r
   r   r   r   r   ú<module>r–     s«  ðð"
ð 
ð €ðð ð €ð €€€Ø Ð Ð Ð Ð Ð Ø 	€	€	€	Ø €€€Ø €€€Ø 	€	€	€	Ø 
€
€
€
Ø €€€ð!Ø&Ð&Ð&Ð&Ð&Ð&Ð&øØð !ð !ð !Ø Ð Ð Ð Ð Ð Ð Ð ð!øøøð'Ø'Ð'Ð'Ð'Ð'Ð'Ð'Ð'Ð'Ð'øØð 'ð 'ð 'Ø&Ð&Ð&Ð&Ð&Ð&Ð&Ð&Ð&Ð&Ð&ð'øøøð  Ð Ð Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð .Ð -Ð -Ð -Ð -Ð -à	€Ø6Ð ð?ð ?ð ?ð
%ð %ð %ð
ð ð ð	ð 	ð 	ð 	ð 	�	ñ 	ô 	ð 	ð
ð ð ð ð  ñ ô ð ðð ð ð ð  	ñ ô ð ðJð Jð Jð Jð Jˆvñ Jô Jð Jð? ð ? ð ? ð ? ð ? ñ ? ô ? ð ? ðD:$ð :$ð :$ð :$ð :$˜xñ :$ô :$ð :$ðzyð yð yð yð yÐ'ñ yô yð yðx	gð gð gð gð gˆXñ gô gð gðT6ð 6ð 6ð 6ð 6˜Ð"4ñ 6ô 6ð 6ðr?ð ?ð ?ð ?ð ?Ð+ñ ?ô ?ð ?ðD^+ð ^+ð ^+ð ^+ð ^+Ð7Ð9Kñ ^+ô ^+ð ^+ðB[ð [ð [ð [ð [�ñ [ô [ð [ðz,ð ,ð ,ð ,ð ,ˆXñ ,ô ,ð ,ð"3ð 3ð 3ð 3ð 3Ð#ñ 3ô 3ð 3ðl%ð %ð %ð %ð %�8ñ %ô %ð %ðnFð nFð nFð nFð nF�(ñ nFô nFð nFð nFð nFs!   ¬3 ³AÁ AÁ	A ÁA ÁA 