Ë
    R
`ê»  ã                   ól  — 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 	 ddlmc mZ 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)«      Z5y# e$ r	 ddlmZ Y Œìw xY w# e$ r ddlmc mZ Y Œöw xY w).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                  ó@   — i }| D ]  }|€Œ|j                  |«       Œ |S )z<Merge any number of dictionaries, some of which may be None.)Úupdate)ÚdictsÚfinalÚdicts      r   Ú_merge_dictsr"   R   s/   € à€EØò ˆØÑØ�L‰L˜Õðð €Lr   c                   ó   — e Zd ZdZy)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Ør   r   c                   ó   — e Zd ZdZy)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y)Ú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y)ÚWADLBasez?A base class for objects that contain WADL-derived information.Nr$   r   r   r   r-   r-   r   s   „ ÚIr   r-   c                   ó"   — e Zd ZdZdd„Z	 dd„Zy)ÚHasParametersMixinzAA mixin class for objects that have associated Parameter objects.Nc                 ó  — |€| j                   }|€t        d«      ‚| j                  €g S | j                  j                  t	        d«      «      }|€g S |D �cg c]+  }|j
                  j                  d«      |v rt        ||«      ‘Œ- c}S c c}w )z6Find subsidiary parameters that have the given styles.z&Could not find any particular resourceÚparamÚstyle)ÚresourceÚ
ValueErrorÚtagÚfindallr   ÚattribÚgetr   )ÚselfÚstylesr3   Ú
param_tagsÚ	param_tags        r   ÚparamszHasParametersMixin.paramsy   s–   € àÐØ—}‘}ˆHØÐÜÐEÓFÐFØ�8‰8ÐØˆIØ—X‘X×%Ñ%¤j°Ó&9Ó:ˆ
ØÐØˆIà!+ö<ØØ×#Ñ#×'Ñ'¨Ó0°FÑ:ô ˜( IÕ.ò <ð 	<ùò <s   Á0B	c                 ó�  — t        ||«      }i }|D ]ô  }|j                  }|j                  �G||v r4||   |j                  k7  r"t        d||   ›d|›d|j                  ›d�«      ‚|j                  ||<   |j                  D �cg c]  }|j
                  ‘Œ }	}t        |	«      dkD  r2||v r.||   |	vr't        d||   ›d|›ddj                  |	«      ›d	�«      ‚|r|j                  r||vrt        d
|z  «      ‚||v sŒê||   ||<   ||= Œö t        |«      dkD  r+t        ddj                  |j                  «       «      z  «      ‚|S c c}w )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.
        zValue 'z' for parameter 'z' conflicts with fixed value 'ú'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_valuer4   ÚoptionsÚvalueÚlenÚjoinÚis_requiredÚkeys)
r9   r=   Úparam_valuesÚenforce_completenessÚkw_param_valuesÚvalidated_valuesr1   rA   ÚoptionrC   s
             r   Úvalidate_param_valuesz(HasParametersMixin.validate_param_valuesˆ   s†  € ô" $ L°/ÓBˆØÐØò 	'ˆEØ—:‘:ˆDØ× Ñ Ð,Ø˜LÑ(Ø$ TÑ*¨e×.?Ñ.?Ò?Ý$à(4°TÓ(:ºDØ(-×(9Ó(9ð&;ó <ð <ð &+×%6Ñ%6�˜TÑ"Ø27·-±-Ö@¨�v—|“|Ð@ˆGÐ@Ü�G“˜qÒ  T¨\Ñ%9Ø  Ñ&¨gÑ5Ý à$ TÓ*ªD°&·+±+¸gÕ2Fð"Hó Ið Iñ %¨×):Ò):Ø Ñ,Ü Ð!GØ#'ñ"(ó )ð )à�|Ò#Ø)5°dÑ);Ð  Ñ&Ø  Ñ&ð-	'ô. ˆ|Ó˜qÒ ÜÐ>Ø%Ÿ{™{¨<×+<Ñ+<Ó+>Ó?ñ@ó Að AàÐùò! As   ÂE©N)T)r%   r&   r'   r(   r=   rN   r   r   r   r/   r/   v   s   „ ÙKó<ð  48ô- r   r/   c                   ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)ÚWADLResolvableDefinitionz=A base class for objects whose definitions may be references.c                 ó    — d| _         || _        y)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)r9   rT   s     r   Ú__init__z!WADLResolvableDefinition.__init__»   s   € ð  ˆÔØ&ˆÕr   c                 óò   — | j                   �| j                   S | j                  «       }|€	| | _         | S | j                  j                  |«      }| 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.
        úNo such XML ID: "%s")rS   Ú_get_definition_urlrT   Úlookup_xml_idÚ_definition_factoryÚKeyError)r9   Ú
object_urlÚxml_idÚ
definitions       r   Úresolve_definitionz+WADLResolvableDefinition.resolve_definitionÄ   sŽ   € ð ×ÑÐ'Ø×#Ñ#Ð#Ø×-Ñ-Ó/ˆ
ØÐð  $ˆDÔØˆKð ×!Ñ!×/Ñ/°
Ó;ˆØ×-Ñ-¨fÓ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©r9   Úids     r   rZ   z,WADLResolvableDefinition._definition_factoryæ   ó   € ô
 "Ó#Ð#r   c                 ó   — t        «       ‚)zmFind the URL that identifies an external reference.

        How to do this depends on the subclass.
        ra   ©r9   s    r   rX   z,WADLResolvableDefinition._get_definition_urlí   re   r   N)r%   r&   r'   r(   rU   r_   rZ   rX   r   r   r   rQ   rQ   ¸   s   „ ÙGò'ò òD$ó$r   rQ   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.c                 óº  •— t         t        | �  |«       || _        t	        |t
        «      r+| j                  j                  |«      j                  | _        n|| _        d| _	        |�A|dk(  r.|r$t        j                  t        |«      «      | _	        n|| _	        nt        d|z  «      ‚|| _        |�+|�|| _        y| j!                  | j                  «      | _        yy)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	   rU   Ú_urlÚ
isinstancer   rT   Úget_resource_typer5   ÚrepresentationÚjsonÚloadsr   r+   Ú
media_typeÚrepresentation_definitionÚget_representation_definition)	r9   rT   ÚurlÚresource_typero   rr   Úrepresentation_needs_processingrs   Ú	__class__s	           €r   rU   zResource.__init__ø   sã   ø€ ô* 	Œh˜Ñ& {Ô3ØˆŒ	Ü�m¤]Ô3ð ×'Ñ'×9Ñ9¸-ÓH×LÑLˆD�Hð %ˆDŒHà"ˆÔØÐ%ØÐ/Ò/Ù2Ü*.¯*©*Ü% nÓ5ó+7�DÕ'ð +9�DÕ'ä/ð$Ø&0ñ1ó2ð 2ð %ˆŒØÐ%Ø(Ð4Ø1J�Õ.ð ×6Ñ6°t·±ÓGð Õ.ð	 &r   c                 ó   — | j                   S )z Return the URL to this resource.)rl   rg   s    r   ru   zResource.url,  s   € ð �y‰yÐr   c                 ó:  — | j                   €y| j                   j                  j                  d«      }|�|S | j                   j                  j                  d«      }|�>t        | j                  j
                  «      j                  «       }t        |«      dz   |z   S y)z@Return the URL to the type definition for this resource, if any.NÚtyperd   ú#)r5   r7   r8   r   rT   Ú
markup_urlÚensureSlashÚstr)r9   ru   Útype_idÚbases       r   Útype_urlzResource.type_url1  sˆ   € ð �8‰8ÐØØ�h‰h�o‰o×!Ñ! &Ó)ˆØˆ?àˆJØ—(‘(—/‘/×%Ñ% dÓ+ˆØÐä�t×'Ñ'×2Ñ2Ó3×?Ñ?ÓAˆDÜ�t“9˜s‘? WÑ,Ð,ð r   c                 ó4   — | j                   j                  d   S )zReturn the ID of this resource.rd   )r5   r7   rg   s    r   rd   zResource.idC  s   € ð �x‰x�‰˜tÑ$Ð$r   c           	      ó`   — 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	   rT   ru   r5   )r9   ro   rr   rw   rs   s        r   ÚbindzResource.bindH  s0   € ô" ˜×(Ñ(¨$¯(©(°D·H±HØ&¨
Ø7Ø1ó3ð 	3r   c                 óÚ   — | j                  d«      j                  }|D ]>  }|j                  «       j                  }|j                  j                  d«      |k(  sŒ<|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Úresponser_   r5   r7   r8   r+   )r9   rr   Údefault_get_responsero   Úrepresentation_tags        r   rt   z&Resource.get_representation_definition^  sy   € à#Ÿ™¨uÓ5×>Ñ>ÐØ2ò 	&ˆNØ!/×!BÑ!BÓ!D×!HÑ!HÐØ!×(Ñ(×,Ñ,¨[Ó9¸ZÓGØ%Ò%ð	&ô (ð )>Ø@Jñ)Kó Lð 	Lr   c                 óô   — | j                  «       D ]e  }|j                  j                  dd«      j                  «       }|�||j                  «       k(  sŒCt	        | |«      }|j                  |||«      sŒc|c S  y)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.
        rA   Ú N)Ú_method_tag_iterr7   r8   Úlowerr   Úis_described_by)r9   Úhttp_methodrr   Úquery_paramsÚrepresentation_paramsÚ
method_tagrA   Úmethods           r   r‰   zResource.get_methodh  s   € ð0 ×/Ñ/Ó1ò 	"ˆJØ×$Ñ$×(Ñ(¨°Ó4×:Ñ:Ó<ˆDØÐ" d¨k×.?Ñ.?Ó.AÓ&AÜ  jÓ1�Ø×)Ñ)¨*°lØ*?õAà!’Mð	"ð r   c                 óB   — | j                  |«      j                  | «      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=   ©r9   rr   s     r   Ú
parameterszResource.parameters‰  s#   € ð ×3Ñ3Øóß™˜t›ð	%r   c                 óB   — | j                  |«      j                  | «      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              #   óR   K  — | j                  «       D ]  }t        | |«      –— Œ y­w)z6An iterator over the methods defined on this resource.N)r�   r   )r9   r•   s     r   Úmethod_iterzResource.method_iter£  s-   è ø€ ð ×/Ñ/Ó1ò 	+ˆJÜ˜˜zÓ*Ó*ñ	+ùs   ‚%'c                 óÔ   — | j                  |«      }|j                  }|j                  t        d«      «      D ].  }|j                  j                  d«      |k(  sŒ"t        | |«      c S  y)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   rA   N)r˜   r5   r6   r   r7   r8   r   )r9   Ú
param_namerr   r^   rŒ   r<   s         r   Úget_parameterzResource.get_parameter©  sh   € ð ×9Ñ9¸*ÓEˆ
Ø'Ÿ^™^ÐØ+×3Ñ3´J¸wÓ4GÓHò 	2ˆIØ×Ñ×#Ñ# FÓ+¨zÓ9Ü   yÓ1Ò1ð	2ð r   c                 ó2  — | j                   €t        d«      ‚| j                  dk(  rˆ|j                  dk7  rt	        d|j                  z  «      ‚| j                   |j
                     }|�D| j                  |j                  |j                  «      \  }}|t        k(  r|dv r	 t        |«      }|S |S t	        d	| j                  z  «      ‚# t        $ rF 	 t        j                  t        j                  |d«      dd Ž }Y |S # t        $ r t        |«      ‚w xY ww xY w)
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.
        z,Resource is not bound to any representation.rj   Ú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.)ro   r   rr   r2   rb   rA   Ú_dereference_namespacer5   r{   ÚXML_SCHEMA_NS_URIr   r4   ÚdatetimeÚtimeÚstrptime)r9   Ú	parameterrD   Únamespace_urlÚ	data_types        r   Úget_parameter_valuezResource.get_parameter_value¼  sE  € ð ×ÑÐ&Ü,Ø>ó@ð @à�?‰?Ð0Ò0ð �‰ 'Ò)Ü)ðØ!*§¡ñ1ó2ð 2ð ×'Ñ'¨	¯©Ñ7ˆEØÐ Ø+/×+FÑ+FØ—M‘M 9§>¡>ó,3Ñ(�˜yà!Ô%6Ò6Ø!Ð%9Ñ9ð4ä ,¨UÓ 3˜ð ˆL�5ˆLä!ð #Gà$(§O¡Oñ#4ó 5ð 	5øô &ò 	4ð4Ü$,×$5Ñ$5Ü"&§-¡-°°zÓ"BÀ1ÀQÐ"Gð%J™Eð ˆLøô  *ò 4ô #-¨UÓ"3Ð3ð	4úð	4ús   Â C Ã	DÃ)C=Ã=DÄDc                 ó”   — |�d|v r|j                  dd«      \  }}nd}|j                  t        «      }|j                  |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Ž   )Úsplitr8   ÚNS_MAP)r9   r5   rD   Ú	namespaceÚns_mapr®   s         r   r¨   zResource._dereference_namespaceì  sR   € ð Ð ¨¡Ø$Ÿ{™{¨3°Ó2ÑˆI‘uàˆIØ—‘œ“ˆØŸ
™
 9¨dÓ3ˆØ˜eÐ#Ð#r   c                 óL   — | j                   j                  j                  |«      S )z-Given an ID, find a ResourceType for that ID.)rT   Úresource_typesr8   rc   s     r   rZ   zResource._definition_factoryú  s   € à×Ñ×.Ñ.×2Ñ2°2Ó6Ð6r   c                 óL   — | j                   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{   ©r5   r7   r8   rg   s    r   rX   zResource._get_definition_urlþ  ó   € ð �x‰x�‰×"Ñ" 6Ó*Ð*r   c                 óÊ   — | j                   �*| j                  j                  «       }|j                  «       S |�!| j                  |«      }|j                  «       S t	        d«      ‚)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
        zSResource is not bound to any representation, and no media media type was specified.)ro   rs   r_   rt   r   )r9   rr   r^   s      r   r˜   z(Resource._find_representation_definition  st   € ð* ×ÑÐ*ð ×7Ñ7×JÑJÓLˆJð ×,Ñ,Ó.Ð.ð Ð#Ø×;Ñ;¸JÓGˆJð
 ×,Ñ,Ó.Ð.ô -ð,ó-ð -r   c              #   ó†   K  — | j                  «       j                  }|j                  t        d«      «      D ]  }|–— Œ y­w)z+Iterate over this resource's <method> tags.r–   N)r_   r5   r6   r   )r9   r^   r•   s      r   r�   zResource._method_tag_iter*  s?   è ø€ à×,Ñ,Ó.×2Ñ2ˆ
Ø$×,Ñ,¬Z¸Ó-AÓBò 	ˆJØÓñ	ùs   ‚?A)NNTN)rj   TN)NNNNrO   )r%   r&   r'   r(   rU   Úpropertyru   r‚   rd   r…   rt   r‰   rš   rœ   rž   r¡   r°   r¨   rZ   rX   r˜   r�   Ú__classcell__©rx   s   @r   r	   r	   õ   s¾   ø„ Ù9ð 26Ø15Ø+/õ2Iðh ñó ðð ñó ðð" ñ%ó ð%ð /AØ-1Ø'+ó3ò,Lð JNØ)-óóB%ó.ð ñ+ó ð+ó
ò&-5ò`$ò7ò+ó /öFr   r	   c                   óv   — 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y)r   z*A wrapper around an XML <method> tag.
    c                 óV   — || _         | j                   j                  | _        || _        y)zaInitialize with a <method> tag.

        :param method_tag: An ElementTree <method> tag.
        N)r3   rT   r5   )r9   r3   r•   s      r   rU   zMethod.__init__4  s$   € ð
 !ˆŒØŸ=™=×4Ñ4ˆÔØˆ�r   c                 ó^   — t        | | j                  j                  t        d«      «      «      S )z@Return the definition of a request that invokes the WADL method.Úrequest)ÚRequestDefinitionr5   Úfindr   rg   s    r   rÅ   zMethod.request=  s#   € ô !  t§x¡x§}¡}´ZÀ	Ó5JÓ'KÓLÐLr   c                 ór   — t        | j                  | j                  j                  t	        d«      «      «      S )z9Return the definition of the response to the WADL method.rŠ   )r   r3   r5   rÇ   r   rg   s    r   rŠ   zMethod.responseB  s.   € ô " $§-¡-Ø"&§(¡(§-¡-´
¸:Ó0FÓ"GóIð 	Ir   c                 óL   — | j                   j                  j                  d«      S )z)The XML ID of the WADL method definition.rd   r»   rg   s    r   rd   z	Method.idH  s   € ð �x‰x�‰×"Ñ" 4Ó(Ð(r   c                 óh   — | j                   j                  j                  d«      j                  «       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.
        rA   ©r5   r7   r8   r�   rg   s    r   rA   zMethod.nameM  s&   € ð �x‰x�‰×"Ñ" 6Ó*×0Ñ0Ó2Ð2r   Nc                 ó<   —  | j                   j                  |fi |¤ŽS )ú4Return the request URL to use to invoke this method.)rÅ   Ú	build_url)r9   rI   rK   s      r   Úbuild_request_urlzMethod.build_request_urlV  s   € à%ˆt�|‰|×%Ñ% lÑF°oÑ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Å   ro   )r9   rr   rI   rK   s       r   Úbuild_representationzMethod.build_representationZ  s*   € ð +ˆt�|‰|×*Ñ*Ø˜ñ9Ø(7ñ9ð 	9r   c                 óØ  — d}|�| j                   j                  |«      }|€y|�;t        |«      dkD  r-| j                   }|€y	 |j                  |j                  |d«       |�t        |«      dk(  ry|�|j                  |«      S | j                   j                  D ]0  }	 |j                  |j                  | j                  «      |d«        y y# t
        $ r Y yw xY w# t
        $ r Y ŒNw xY w)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Å   rt   rE   rN   r“   r4   r‘   Úrepresentationsr=   r3   )r9   rr   Úquery_valuesÚrepresentation_valuesro   rÅ   s         r   r‘   zMethod.is_described_byc  s  € ð$ ˆØÐ!Ø!Ÿ\™\×GÑGØóˆNàÐ%ØàÐ#¬¨LÓ(9¸AÒ(=Ø—l‘lˆGØˆð ðØ×-Ñ-Ø×(Ñ(¨,¸ô?ð "Ð)ÜÐ(Ó)¨QÒ.ØàÐ%Ø!×1Ñ1Ø%ó'ð 'à"Ÿl™l×:Ñ:ò 	ˆNðØ×4Ñ4Ø"×)Ñ)¨$¯-©-Ó8Ø)¨5ô2ñ ð	ð øô' ò Ùðûô" ò Ùðús$   ÁC Â,CÃ	CÃCÃ	C)Ã(C)rO   ©NN)NNN)r%   r&   r'   r(   rU   r¿   rÅ   rŠ   rd   rA   rÏ   rÑ   r‘   r   r   r   r   r   1  s�   „ ñòð ñMó ðMð ñIó ðIð
 ñ)ó ð)ð ñ3ó ð3óGð /3Ø*.ó9ð =AØ.2ô5r   r   c                   óN   — e Zd ZdZd„ Zed„ «       Zed„ «       Zd	d„Zd
d„Z	d	d„Z
y)rÆ   zBA wrapper around the description of the request invoking a method.c                 óŒ   — || _         | j                   j                  | _        | j                  j                  | _        || _        y)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–   r3   rT   r5   )r9   r–   Úrequest_tags      r   rU   zRequestDefinition.__init__�  s5   € ð ˆŒØŸ™×,Ñ,ˆŒØŸ=™=×4Ñ4ˆÔØˆ�r   c                 ó&   — | j                  dg«      S )z,Return the query parameters for this method.Úquery)r=   rg   s    r   r“   zRequestDefinition.query_params¨  s   € ð �{‰{˜G˜9Ó%Ð%r   c              #   ó¤   K  — | j                   j                  t        d«      «      D ]%  }t        | j                  | j
                  |«      –— Œ' y ­w)Nro   )r5   r6   r   r   rT   r3   )r9   r^   s     r   rÓ   z!RequestDefinition.representations­  sH   è ø€ àŸ(™(×*Ñ*¬:Ð6FÓ+GÓHò 	=ˆJÜ*Ø× Ñ  $§-¡-°ó=ó =ñ	=ùs   ‚AANc                 óP   — | j                   D ]  }|�|j                  |k(  sŒ|c S  y)z1Return the appropriate representation definition.N)rÓ   rr   ©r9   rr   ro   s      r   rt   z/RequestDefinition.get_representation_definition³  s5   € à"×2Ñ2ò 	&ˆNØÐ! ^×%>Ñ%>À*Ó%LØ%Ò%ð	&ð r   c                 ój   — | j                  |«      }|€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).
        z,Cannot build representation of media type %s)rt   Ú	TypeErrorr…   )r9   rr   rI   rK   r^   s        r   ro   z RequestDefinition.representationº  sH   € ð ×7Ñ7¸
ÓCˆ
ØÐÜÐJØ(ñ)ó *ð *àˆz�‰˜|Ñ?¨Ñ?Ð?r   c                 óì   —  | j                   | j                  |fi |¤Ž}| j                  j                  }t	        |«      dkD  r1d|v rd}nd}||t        t        |j                  «       «      «      z   z  }|S )rÍ   r   ú?ú&)rN   r“   r3   ru   rE   r   ÚsortedÚitems)r9   rI   rK   rL   ru   Úappends         r   rÎ   zRequestDefinition.build_urlÆ  s€   € à5˜4×5Ñ5Ø×Ñ˜|ñ@Ø/>ñ@Ðà�m‰m×ÑˆÜÐÓ  1Ò$Ø�c‰zØ‘à�Ø�6œI¤fÐ-=×-CÑ-CÓ-EÓ&FÓGÑGÑGˆCØˆ
r   rO   rÖ   )r%   r&   r'   r(   rU   r¿   r“   rÓ   rt   ro   rÎ   r   r   r   rÆ   rÆ   ›  sB   „ ÙLò	ð ñ&ó ð&ð ñ=ó ð=ó
ó
@ôr   rÆ   c                   ó6   — e Zd ZdZd	d„Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)
r   z;A wrapper around the description of a response to a method.Nc                 óP   — |j                   | _         || _        || _        || _        y)zgInitialize with a <response> tag.

        :param response_tag: An ElementTree <response> tag.
        N)rT   r3   r5   Úheaders)r9   r3   Úresponse_tagré   s       r   rU   zResponseDefinition.__init__Ü  s'   € ð
 $×/Ñ/ˆÔØ ˆŒØˆŒØˆ�r   c              #   ó¼   K  — t        d«      }| j                  j                  |«      D ]/  }t        | j                  j
                  | j                  |«      –— Œ1 y­w)z¢Get an iterator over the representation definitions.

        These are the representations returned in response to an
        invocation of this method.
        ro   N)r   r5   r6   r   r3   rT   )r9   ÚpathrŒ   s      r   Ú__iter__zResponseDefinition.__iter__æ  sY   è ø€ ô Ð*Ó+ˆØ"&§(¡(×"2Ñ"2°4Ó"8ò 	NÐÜ*Ø—‘×)Ñ)¨4¯=©=Ð:LóNó Nñ	Nùs   ‚AAc                 óD   — 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   r3   r5   )r9   ré   s     r   r…   zResponseDefinition.bindñ  s   € ô " $§-¡-°·±¸7ÓCÐCr   c                 óì   — | j                   j                  t        d«      «      D ]M  }|j                  j	                  d«      |k(  sŒ"|j                  j	                  d«      dk(  sŒAt        | |«      c S  y)z,Find a header parameter within the response.r1   rA   r2   ÚheaderN)r5   r6   r   r7   r8   r   )r9   r    r<   s      r   r¡   z ResponseDefinition.get_parameterù  si   € àŸ™×)Ñ)¬*°WÓ*=Ó>ò 	2ˆIØ× Ñ ×$Ñ$ VÓ,°
Ó:Ø×$Ñ$×(Ñ(¨Ó1°XÓ=Ü   yÓ1Ò1ð	2ð r   c                 óÈ   — | j                   €t        d«      ‚|j                  dk7  rt        d|j                  z  «      ‚| j                   j	                  |j
                  «      S )z:Find the value of a parameter, given the Parameter object.z,Response object is not bound to any headers.rð   r¤   )ré   r   r2   rb   r8   rA   )r9   r­   s     r   r°   z&ResponseDefinition.get_parameter_value  sc   € à�<‰<ÐÜ,Ø>ó@ð @à�?‰?˜hÒ&Ü%ðØ&Ÿ_™_ñ-ó.ð .ð �|‰|×Ñ 	§¡Ó/Ð/r   c                 óR   — | j                   €y| D ]  }|j                  |k(  sŒ|c S  y)z8Get one of the possible representations of the response.N)r5   rr   rÞ   s      r   rt   z0ResponseDefinition.get_representation_definition  s7   € à�8‰8ÐØØ"ò 	&ˆNØ×(Ñ(¨JÓ6Ø%Ò%ð	&ð r   rO   )
r%   r&   r'   r(   rU   rí   r…   r¡   r°   rt   r   r   r   r   r   Ô  s%   „ ÙEóò	NòDòò	0ór   r   c                   ón   ‡ — 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                 óH   •— t         t        | �  |«       || _        || _        y rO   )rk   r   rU   r3   r5   )r9   rT   r3   rŒ   rx   s       €r   rU   z!RepresentationDefinition.__init__  s!   ø€ ÜÔ&¨Ñ6°{ÔCØ ˆŒØ%ˆ�r   c                 ó0   •— t         t        | �  ddg|«      S )NrÛ   r£   )rk   r   r=   )r9   r3   rx   s     €r   r=   zRepresentationDefinition.params  s"   ø€ ÜÔ-¨tÑ;Ø�gÐ ó*ð 	*r   c                 ó^   — | j                  |«      D �cg c]  }|j                  ‘Œ c}S c c}w )z#Return the names of all parameters.)r=   rA   )r9   r3   r1   s      r   rœ   z(RepresentationDefinition.parameter_names"  s#   € à(,¯©°HÓ(=Ö>˜u�—
“
Ò>Ð>ùÒ>s   ”*c                 óP   — | j                  «       j                  j                  d   S )z4The media type of the representation described here.rˆ   )r_   r5   r7   rg   s    r   rr   z#RepresentationDefinition.media_type&  s$   € ð ×&Ñ&Ó(×,Ñ,×3Ñ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   j                  d«      }t        j                  ||t        j                  ¬	«      s	 |S |d
z   t        |«      z   }|dz  }Œj)z;Make a random boundary that does not appear in `all_parts`.r³   z%%0%ddz===============z==r   z^--z(--)?$Úascii)Úflagsú.)rE   ÚreprÚsysÚmaxsizeÚrandomÚ	randrangeÚreÚescapeÚencodeÚsearchÚ	MULTILINEr   )	r9   Ú	all_partsÚ_widthÚ_fmtÚtokenÚboundaryÚbÚcounterÚpatterns	            r   Ú_make_boundaryz'RepresentationDefinition._make_boundary+  sÄ   € ä”Tœ#Ÿ+™+¨™/Ó*Ó+ˆØ˜&Ñ ˆÜ× Ñ ¤§¡Ó-ˆØ ¨¡Ñ.°Ñ5ˆØÐØˆOØˆØˆØØœrŸy™y¨›|Ñ+¨hÑ6×>Ñ>¸wÓGˆGÜ—9‘9˜W i´r·|±|ÕDØð ˆð ˜3‘¤ W£Ñ-ˆAØ�q‰LˆGð r   c                 óþ   — |D ]g  \  }}|j                  |j                  d«      «       |j                  d«       |j                  |j                  d«      «       |j                  d«       Œi |j                  d«       y)z$Write MIME headers to a file object.úUTF-8s   : ó   
N©Úwriter  )r9   Úbufré   ÚkeyrD   s        r   Ú_write_headersz'RepresentationDefinition._write_headers=  se   € à!ò 	‰JˆC�Ø�I‰I�c—j‘j Ó)Ô*Ø�I‰I�eÔØ�I‰I�e—l‘l 7Ó+Ô,Ø�I‰I�gÕð		ð
 	�	‰	�'Õr   c                 ó®   — |j                  d«       |j                  |j                  d«      «       |r|j                  d«       |j                  d«       y)z,Write a multipart boundary to a file object.s   --r  r  Nr  )r9   r  r
  Úclosings       r   Ú_write_boundaryz(RepresentationDefinition._write_boundaryF  s>   € à�	‰	�%ÔØ�	‰	�(—/‘/ 'Ó*Ô+ÙØ�I‰I�eÔØ�	‰	�'Õr   c                 ó6  — g }|D �]Y  \  }}}t        j                  «       }|rd}dt        |«      ›dt        |«      ›d�}nd}dt        |«      z  }| j                  |dd|fd	|fg«       |r9t	        |t
        «      st        d
t        |«      z  «      ‚|j                  |«       n›t	        |t        «      st        dt        |«      z  «      ‚t        j                  d|«      }	|	dd D ]3  }
|j                  |
j                  d«      «       |j                  d«       Œ5 |j                  |	d   j                  d«      «       |j                  |j                  «       «       �Œ\ | j                  dj!                  |«      «      }t        j                  «       }dt        |«      z  }| j                  |dd|fg«       |D ]6  }| j#                  ||«       |j                  |«       |j                  d«       Œ8 | j#                  ||d¬«       ||j                  «       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="r@   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  rm   Úbytesrà   r{   r  r   r  r´   r  ræ   Úgetvaluer  rF   r  )r9   ÚpartsÚencoded_partsÚ	is_binaryrA   rD   r  ÚctypeÚcdispÚlinesÚliner
  Úencoded_parts                r   Ú_generate_multipart_formz1RepresentationDefinition._generate_multipart_formN  s	  € ð ˆØ&+ó 	1Ñ"ˆI�t˜UÜ—*‘*“,ˆCÙØ2‘ô
 ˜$•K¤ t¥ð.‘ð 6�Ø.´°t³Ñ<�Ø×Ñ Ø'Ø Ð'Ø&¨Ð.ð&ô ñ
 Ü! %¬Ô/Ü#Ð$@Ä4ÈÃ;Ñ$NÓOÐOØ—	‘	˜%Õ ä! %¬Ô7Ü#Ø5¼¸U»ÑCóEð EäŸ™ °Ó6�Ø! # 2˜Jò '�DØ—I‘I˜dŸk™k¨'Ó2Ô3Ø—I‘I˜gÕ&ð'ð —	‘	˜% ™)×*Ñ*¨7Ó3Ô4Ø× Ñ  §¡£Ö0ð=	1ðB ×&Ñ& w§|¡|°MÓ'BÓCˆô �j‰j‹lˆØ4´u¸X³ÑFˆØ×Ñ˜CØ#Ø˜UÐ#ð"ô 	ð *ò 	ˆLØ× Ñ   hÔ/Ø�I‰I�lÔ#Ø�I‰I�gÕð	ð 	×Ñ˜S (°DÐÔ9à�c—l‘l“nÐ$Ð$r   c                 ó>  — | j                  «       }|j                  | j                  «      } | j                  ||fi |¤Ž}| j                  }|dk(  r&t        t        |j                  «       «      «      }||fS |dk(  rwg }t        «       }	|D ]N  }
|j                  |
j                  |	«      }||	usŒ$|j                  |
j                  dk(  |
j                  |f«       ŒP | j                  |«      \  }}||fS |dk(  rt        j                  |«      }||fS t!        d|z  «      ‚)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Úbinaryrj   zUnsupported media type: '%s')r_   r=   r3   rN   rr   r   rä   rå   Úobjectr8   rA   ræ   r{   r(  rp   Údumpsr4   )r9   rI   rK   r^   r=   rL   rr   Údocr   Úmissingr1   rD   s               r   r…   zRepresentationDefinition.bind�  s>  € ð
 ×,Ñ,Ó.ˆ
Ø×"Ñ" 4§=¡=Ó1ˆØ5˜4×5Ñ5Ø�Lñ5Ø$3ñ5Ðà—_‘_ˆ
ØÐ<Ò<ÜœFÐ#3×#9Ñ#9Ó#;Ó<Ó=ˆCð ˜3ˆÐð Ð0Ò0ØˆEÜ“hˆGØò N�Ø(×,Ñ,¨U¯Z©Z¸ÓA�Ø Ò'Ø—L‘L %§*¡*°Ñ"8¸%¿*¹*ÀeÐ!LÕMðNð #×;Ñ;¸EÓB‰OˆJ˜ð
 ˜3ˆÐð	 Ð-Ò-Ü—*‘*Ð-Ó.ˆCð ˜3ˆÐô Ð;¸jÑHÓIÐIr   c                 óL   — | j                   j                  j                  |«      S )z9Turn a representation ID into a RepresentationDefinition.)rT   Úrepresentation_definitionsr8   rc   s     r   rZ   z,RepresentationDefinition._definition_factory©  s   € à×Ñ×:Ñ:×>Ñ>¸rÓBÐBr   c                 óL   — | j                   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»   rg   s    r   rX   z,RepresentationDefinition._get_definition_url­  r¼   r   )F)r%   r&   r'   r(   rU   r=   rœ   r¿   rr   r  r  r  r(  r…   rZ   rX   rÀ   rÁ   s   @r   r   r     sP   ø„ Ù<ô&ô
*ò?ð ñAó ðAòò$óò?%òBò4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y)r   z5One of the parameters of a representation definition.c                 óB   — |j                   | _         || _        || _        y)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)rT   Úvalue_containerr5   )r9   r5  r5   s      r   rU   zParameter.__init__º  s!   € ð +×6Ñ6ˆÔØ.ˆÔØˆ�r   c                 óL   — | j                   j                  j                  d«      S )zThe name of this parameter.rA   r»   rg   s    r   rA   zParameter.nameÈ  ó   € ð �x‰x�‰×"Ñ" 6Ó*Ð*r   c                 óL   — | j                   j                  j                  d«      S )zThe style of this parameter.r2   r»   rg   s    r   r2   zParameter.styleÍ  s   € ð �x‰x�‰×"Ñ" 7Ó+Ð+r   c                 óL   — | j                   j                  j                  d«      S )zThe XSD type of this parameter.r{   r»   rg   s    r   r{   zParameter.typeÒ  r7  r   c                 óL   — | j                   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»   rg   s    r   rB   zParameter.fixed_value×  s   € ð �x‰x�‰×"Ñ" 7Ó+Ð+r   c                 ón   — | j                   j                  j                  dd«      j                  «       dv S )z6Whether or not a value for this parameter is required.ÚrequiredÚfalse)Ú1ÚtruerË   rg   s    r   rG   zParameter.is_requiredâ  s2   € ð —‘—‘×#Ñ# J°Ó8×>Ñ>Ó@Ø ð!ð 	"r   c                 ó8   — | j                   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.
        )r5  r°   rg   s    r   Ú	get_valuezParameter.get_valueè  s   € ð ×#Ñ#×7Ñ7¸Ó=Ð=r   c                 ó„   — | j                   j                  t        d«      «      D �cg c]  }t        | |«      ‘Œ c}S c c}w )z7Return the set of acceptable values for this parameter.rM   )r5   r6   r   ÚOption)r9   Ú
option_tags     r   rC   zParameter.optionsñ  sC   € ð $(§8¡8×#3Ñ#3´J¸xÓ4HÓ#IöKØô �t˜ZÕ(ò Kð 	Kùò Ks   §=c                 óh   — | j                   j                  t        d«      «      }|€y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)r5   rÇ   r   r   )r9   Úlink_tags     r   rG  zParameter.link÷  s1   € ð —8‘8—=‘=¤¨FÓ!3Ó4ˆØÐØÜ�D˜(Ó#Ð#r   c                 óL   — | 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.
        z(This parameter isn't a link to anything.)rG  r4   Úfollow)r9   rG  s     r   Úlinked_resourcezParameter.linked_resource  s(   € ð �y‰yˆØˆ<ÜÐGÓHÐHØ�{‰{Ðr   N)r%   r&   r'   r(   rU   r¿   rA   r2   r{   rB   rG   rB  rC   rG  rK  r   r   r   r   r   ·  s±   „ Ù?òð ñ+ó ð+ð ñ,ó ð,ð ñ+ó ð+ð ñ,ó ð,ð ñ"ó ð"ò
>ð ñKó ðKð
 ñ$ó ð$ð ñó ñr   r   c                   ó&   — e Zd ZdZd„ Zed„ «       Zy)rD  z0One of a set of possible values for a parameter.c                 ó    — || _         || _        y)z}Initialize the option.

        :param parameter: A Parameter.
        :param link_tag: An ElementTree <option> tag.
        N)r­   r5   )r9   r­   rE  s      r   rU   zOption.__init__  s   € ð #ˆŒØˆ�r   c                 óL   — | j                   j                  j                  d«      S )NrD   r»   rg   s    r   rD   zOption.value   s   € à�x‰x�‰×"Ñ" 7Ó+Ð+r   N)r%   r&   r'   r(   rU   r¿   rD   r   r   r   rD  rD    s   „ Ù:òð ñ,ó ñ,r   rD  c                   óN   ‡ — 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                  «       || _        || _        y)zyInitialize the link.

        :param parameter: A Parameter.
        :param link_tag: An ElementTree <link> tag.
        N)rk   r   rU   rT   r­   r5   )r9   r­   rH  rx   s      €r   rU   zLink.__init__,  s(   ø€ ô 	Œd�DÑ" 9×#8Ñ#8Ô9Ø"ˆŒØˆ�r   c                 óP   — | j                   st        d«      ‚| j                  «       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   r_   rg   s    r   rJ  zLink.follow6  s.   € ð �ŠÜð .ó /ð /ð ×&Ñ&Ó(Ð(r   c                 óD   — 	 | j                  «       }y# t        $ r Y yw xY w)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)rX   r   )r9   Údefinition_urls     r   rR  zLink.can_follow?  s.   € ð	Ø!×5Ñ5Ó7ˆNð øô ò 	Ùð	ús   ‚ “	žc                 óº   — t        | j                  | j                  j                  «       | j                  j                  j                  |«      j                  «      S )z,Turn a resource type ID into a ResourceType.)r	   rT   r­   rB  r¹   r8   r5   rc   s     r   rZ   zLink._definition_factoryL  sG   € äØ×Ñ˜dŸn™n×6Ñ6Ó8Ø×Ñ×+Ñ+×/Ñ/°Ó3×7Ñ7ó9ð 	9r   c                 ój   — | j                   j                  j                  d«      }|€t        d«      ‚|S )z(Find the URL containing the definition .rv   zIParameter is a link, but not to a resource with a known WADL description.)r5   r7   r8   r   )r9   r{   s     r   rX   zLink._get_definition_urlR  s6   € à�x‰x�‰×"Ñ" ?Ó3ˆØˆ<Üð =ó >ð >àˆr   )r%   r&   r'   r(   rU   r¿   rJ  rR  rZ   rX   rÀ   rÁ   s   @r   r   r   %  s?   ø„ ñôð ñ)ó ð)ð ñ
ó ð
ò9ör   r   c                   ó   — e Zd ZdZd„ Zy)r
   z,A wrapper around an XML <resource_type> tag.c                 ó   — || _         y)zvInitialize with a <resource_type> tag.

        :param resource_type_tag: An ElementTree <resource_type> tag.
        N)r5   )r9   Úresource_type_tags     r   rU   zResourceType.__init__^  s   € ð
 %ˆ�r   N)r%   r&   r'   r(   rU   r   r   r   r
   r
   [  s
   „ Ù6ó%r   r
   c                   ó4   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)	r   z1A WADL document made programmatically accessible.c                 ó¬  — || _         t        |d«      r| j                  |«      | _        n| j	                  |«      | _        | j                  j                  t        d«      «      | _        | j                  j                  j                  d«      | _
        i | _        i | _        | j                  j                  t        d«      «      D ]<  }|j                  j                  d«      }|€Œ!t        | d|«      }|| j                  |<   Œ> | j                  j                  t        d«      «      D ])  }|j                  d   }t        |«      | j                  |<   Œ+ y)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�   ro   rd   Nrv   )r}   ÚhasattrÚ_from_streamr-  Ú_from_stringrÇ   r   r]  r7   r8   Úresource_baser0  r¹   r6   r   r
   )r9   r}   Úmarkupro   rd   r^   rv   s          r   rU   zApplication.__init__i  s-  € ð %ˆŒÜ�6˜6Ô"Ø×(Ñ(¨Ó0ˆD�Hà×(Ñ(¨Ó0ˆDŒHØŸ™Ÿ™¤z°+Ó'>Ó?ˆŒØ!Ÿ^™^×2Ñ2×6Ñ6°vÓ>ˆÔØ*,ˆÔ'Ø ˆÔØ"Ÿh™h×.Ñ.¬zÐ:JÓ/KÓLò 	AˆNØ×&Ñ&×*Ñ*¨4Ó0ˆBØ‰~Ü5Ø˜$ ó0�
à6@�×/Ñ/°Ò3ð	Að "ŸX™X×-Ñ-¬j¸Ó.IÓJò 	BˆMØ×%Ñ% dÑ+ˆBÜ&2°=Ó&AˆD×Ñ Ò#ñ	Br   c                 ó   — d}d}g }t        j                  ||«      D ][  \  }}|dk(  r|j                  |«       Œ|dk(  r|j                  «        Œ3|dk(  sŒ9|€|}|j	                  t
        t        |«      «       Œ] t        j                  |«      S )zrTurns markup into a document.

        Just a wrapper around ElementTree which keeps track of namespaces.
        )Ústartústart-nsúend-nsNre  rf  rd  )ÚETÚ	iterparseræ   ÚpopÚsetrµ   r!   ÚElementTree)r9   ÚstreamÚeventsÚrootr·   ÚeventÚelems          r   r_  zApplication._from_stream‚  s‹   € ð
 /ˆØˆØˆäŸ<™<¨°Ó7ò 	/‰KˆE�4Ø˜
Ò"Ø—‘˜dÕ#Ø˜(Ò"Ø—
‘
•Ø˜'Ó!Ø�<Ø�DØ—‘œ¤ f£Õ.ð	/ô �~‰~˜dÓ#Ð#r   c                 óŒ   — t        |t        «      s|j                  d«      }| j                  t	        j
                  |«      «      S )zTurns markup into a document.r  )rm   r  r  r_  r  r  )r9   rb  s     r   r`  zApplication._from_string–  s4   € ä˜&¤%Ô(Ø—]‘] 7Ó+ˆFØ× Ñ ¤§¡¨FÓ!3Ó4Ð4r   c                 ó~   — | j                  |«      }| j                  j                  |«      }|€t        d|z  «      ‚|S )z7Retrieve a resource type by the URL of its description.rW   )rY   r¹   r8   r[   )r9   Úresource_type_urlr]   rv   s       r   rn   zApplication.get_resource_typeœ  sG   € à×#Ñ#Ð$5Ó6ˆØ×+Ñ+×/Ñ/°Ó7ˆØÐ ÜÐ1Ð4EÑEÓFÐFØÐr   c                 ó  — t        | j                  «      j                  «       }d|_        |j	                  d«      rt        |«      j                  «       }n|j                  |«      }|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Úresolverb   )r9   ru   Ú
markup_uriÚthis_uriÚpossible_xml_ids        r   rY   zApplication.lookup_xml_id¤  s’   € ô ˜Ÿ™Ó)×7Ñ7Ó9ˆ
Ø"ˆ
Ôà�>‰>˜&Ô!ä˜3“x×-Ñ-Ó/‰Hð "×)Ñ)¨#Ó.ˆHØ"×+Ñ+ˆØ ˆÔà�zÒ!ð #Ð"ô "ð #-Ø/2ñ#3ó 4ð 	4r   c                 ó  — | j                   D �cg c]  }|j                  d   |k(  r|‘Œ }}t        |«      dk  ryt        |«      dkD  rt        d|z  «      ‚t	        | t        | j                  |d«      |d   «      S c c}w )zpLocate one of the resources described by this document.

        :param path: The path to the resource.
        rì   r³   Nz+More than one resource defined with path %sTr   )r]  r7   rE   r   r	   r   ra  )r9   rì   r3   Úmatchings       r   Úget_resource_by_pathz Application.get_resource_by_pathÄ  s–   € ð .2¯^©^ö 8 Ø—‘ vÑ.°$Ò6ò ð 8ˆð 8äˆx‹=˜1ÒØÜˆx‹=˜1ÒÜÐIØ"ñ#ó $ð $äØ”%˜×*Ñ*¨D°$Ó7¸À!¹óFð 	Fùò8s   �A<N)
r%   r&   r'   r(   rU   r_  r`  rn   rY   r  r   r   r   r   r   f  s&   „ Ù;òBò2$ò(5òò4ó@Fr   r   )6r(   r{   Ú__metaclass__Ú__all__rª   Úemail.utilsr   r  rp   rÿ   r  rý   r«   Úurllib.parser   ÚImportErrorÚurllibÚxml.etree.cElementTreeÚetreeÚcElementTreerg  Úxml.etree.ElementTreerk  Úlazr.urir   r   Úwadllibr   r   Úwadllib.iso_strptimer   rµ   r©   r   r   r"   Ú	Exceptionr   r   r+   r+  r-   r/   rQ   r	   r   rÆ   r   r   r   rD  r   r
   r   r   r   r   ú<module>rŽ     sx  ðñ"
ð €ò€ó Ý Û 	Û Û Û 	Û 
Û ð!Ý&ð'ß'Ð'÷  ÷õ .à	€Ø6Ð ò?ò
%ò
ô	�	ô 	ô
 ô ô 	ô ôJˆvô J÷? ñ ? ôD:$˜xô :$ôzyÐ'ô yôx	gˆXô gôT6˜Ð"4ô 6ôr?Ð+ô ?ôD^+Ð7Ð9Kô ^+ôB[�ô [ôz,ˆXô ,ô"3Ð#ô 3ôl%�8ô %ônF�(õ nFøða! ò !ß ð!ûð ò 'ß&Ò&ð'ús"   ¬D ³	D" ÄDÄDÄ"D3Ä2D3