Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/lazr/restfulclient/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyc


&ˉTc@sdZeZddddddgZddlZydd	lmZWn!ek
rgdd	lmZnXddl	Z	dd
l
m
Z
ddlZddlZddl
m
Z
mZddlmZdd
lmZddlmZmZddlmZddlmZddlmZeZdfdYZdfdYZ de fdYZdefdYZ!defdYZ"defdYZ#de fdYZ$defdYZ%defdYZ&de&fdYZ'd e
fd!YZ(dS("s)Common support for web service resources.t
CollectiontCollectionWithKeyBasedLookuptEntrytNamedOperationtResourcetServiceRootiN(tMessage(tStringIO(turlparseturljoin(tURI(R(tBrowsertRestfulHttp(tDatetimeJSONEncoder(t	HTTPError(t__version__tHeaderDictionarycBs,eZdZdZddZdZRS(sA dictionary that bridges httplib2's and wadllib's expectations.

    httplib2 expects all header dictionary access to give lowercase
    header names. wadllib expects to access the header exactly as it's
    specified in the WADL file, which means the official HTTP header name.

    This class transforms keys to lowercase before doing a lookup on
    the underlying dictionary. That way wadllib can pass in the
    official header name and httplib2 will get the lowercased name.
    cCs
||_dS(N(twrapped_dictionary(tselfR((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__init__@scCs|jj|jS(s2Retrieve a value, converting the key to lowercase.(Rtgettlower(Rtkeytdefault((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRCscCs1|j|t}|tkr-t|n|S(s2Retrieve a value, converting the key to lowercase.(RtmissingtKeyError(RRtvalue((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__getitem__GsN(t__name__t
__module__t__doc__RtNoneRR(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyR5s
	tRestfulBasecBs&eZdZdZdZdZRS(s=Base class for classes that know about lazr.restful services.sapplication/jsoncCsUi}xH|jD]:\}}t|tr:|j}n|||j|<qW|S(N(titemst
isinstanceRt	self_linkt_get_external_param_name(Rt
dictionarytnew_dictionaryRR((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt_transform_resources_to_linksTscCs|S(sTurn a lazr.restful name into something to be sent over HTTP.

        For resources this may involve sticking '_link' or
        '_collection_link' on the end of the parameter name. For
        arguments to named operations, the parameter name is returned
        as is.
        ((Rt
param_name((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyR$\s(RRRtJSON_MEDIA_TYPER'R$(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyR Os	cBseZdZdZeZeZeZedZ	edZ
edZedZedZ
eZdZdZd	Zd
ZeddedddZddd
ZdZdZdZdZdZRS(s+Base class for lazr.restful HTTP resources.cCs3|dkr|}n||jd<||jd<dS(s5Initialize with respect to a wadllib Resource object.t_roott_wadl_resourceN(Rt__dict__(Rtroott
wadl_resource((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRjs	
cCs|j|jS(s,Name the collections this resource links to.(t_get_parameter_namestFIND_COLLECTIONS(R((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pytlp_collectionsxscCs|j|jS(s(Name the entries this resource links to.(R/tFIND_ENTRIES(R((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt
lp_entries}scCs|j|jS(s'Name this resource's scalar attributes.(R/tFIND_ATTRIBUTES(R((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt
lp_attributesscCsg}x|jjD]}|jj}|dkrO|jjddg}nf|dkrxBddgD]4}|jj|}|dk	rh|j}PqhqhW|j|j}nx1|D])}|jdkr|j	|j
PqqWqW|S(	s.Name all of this resource's custom operations.Rtquerytplaintposts!application/x-www-form-urlencodedsmultipart/form-datasws.opN(R+tmethod_itertnameRtrequesttparamstget_representation_definitionRtresolve_definitiontappendtfixed_value(RtnamestmethodR:R<t
media_typet
definitiontparam((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt
lp_operationss&
		
cCs|j|j|j|jS(s;A hook into dir() that returns web service-derived members.(R/R0R2R4(R((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__members__scGsg}x|jj|jD]}|j}|j}|dkr|dk	r|jr|jdr|j|kr|j	|d qq|j
|kr|j	|d qq|j|kr|j	|qqW|S(s2Retrieve some subset of the resource's parameters.R#t_collection_linkiiN(R+t
parametersR)R:tlinkRt
can_followtendswithR0R?R2R4(RtkindsRAt	parameterR:RJ((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyR/s			
cCs|j|dk	S(s8Does this resource have a parameter with the given name?N(R$R(RR(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pytlp_has_parameterscCs|jxddgD]}|jj||}|dk	ry|j}Wntk
rg}qnX|jdkr~dS|j}|j|j|d|j	SqW|jj|}|dkrtd|n|jS(sGet the value of one of the resource's parameters.

        :return: A scalar value if the parameter is not a link. A new
                 Resource object, whose resource is bound to a
                 representation, if the parameter is a link.
        t_linkRHR(sNo such parameter: %sN(
t_ensure_representationR+t
get_parameterRt	get_valueRtlinked_resourcet_create_bound_resourceR*R:(RR(tsuffixRERteRT((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pytlp_get_parameters$
	
	cCs~i|d6}|jjdd|}|dkrL|jjdd|}n|dkrktd|nt|j||S(sGet a custom operation with the given name.

        :return: A NamedOperation instance that can be called with
                 appropriate arguments to invoke the operation.
        sws.opRtquery_paramsR8trepresentation_paramssNo operation with name: %sN(R+t
get_methodRRRR*(Rtoperation_nameR<RB((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pytlp_get_named_operations
	sapplication/jsoncCs|j}t|d}	t}
|jdsI|dk	rR|jdrRt}
n|jj|	|
}|dk	r|j|||d|}n|||S(sCreate a lazr.restful Resource subclass from a wadllib Resource.

        :param resource: The wadllib Resource to wrap.
        :param representation: A previously fetched representation of
            this resource, to be reused. If not provided, this method
            will act just like the Resource constructor.
        :param representation_media_type: The media type of any previously
            fetched representation.
        :param representation_needs_processing: Set to False if the
            'representation' parameter should be used as
            is.
        :param representation_definition: A wadllib
            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.
        :param param_name: The name of the link that was followed to get
            to this resource.
        :return: An instance of the appropriate lazr.restful Resource
            subclass.
        is-pageRHtrepresentation_definitionN(	ttype_urlRRRLRRtRESOURCE_TYPE_CLASSESRtbind(tclsR-tresourcetrepresentationtrepresentation_media_typetrepresentation_needs_processingR^R(R_t
resource_typeRtr_class((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRUs		cCs|dk	r||j_ni}|dk	r:||d<n|jjj|jd|}||jjjkrqdS|jj||j|j	d<dS(s&Update this resource's representation.s
If-None-MatchtheadersNR+(
RR+t_urlR*t_browserRtNOT_MODIFIEDRaR)R,(Rtnew_urltetagRiRd((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt
lp_refresh3s
	cCsdy|j|SWntk
r$nXy|j|SWn'tk
r_td||fnXdS(s@Try to retrive a named operation or parameter of the given name.s%s object has no attribute '%s'N(R]RRXtAttributeError(Rtattr((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__getattr__Ds

cCsQ|jj||j}|j}t|dkrMg|D]}|j^q:SdS(s0Find the set of possible values for a parameter.iN(R+RRR)toptionstlenRR(RR(RNRstoption((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt
lp_values_forPs		cCs>x7dddgD]&}||}|jj|r|SqWdS(s>What's this parameter's name in the underlying representation?RPRHtN(R+RRR(RR(RVR:((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyR$Ys

cCs|jjdkr|jjj|j}tjt|}t	|t
jkr|d}|dk	r||jjkr|jj
j|}|j|j_qn|jj||jdt|jd<ndS(s5Make sure this resource has a representation fetched.tresource_type_linkRfR+N(R+RdRR*RkRt
simplejsontloadstunicodettypettypestDictTypeR_t_wadltget_resource_typettagRaR)tFalseR,(RRdt	type_linkRg((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRQas

	cCs||kS(sInequality operator.((Rtother((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__ne__zsN(RRRRtobjectR0R2R4tpropertyR1R3R5RFRGt__methods__R/RORXR]tclassmethodRtTrueRURoRrRvR$RQR(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRgs4	
				$			0					tScalarValuecBseZdZedZRS(s.A resource representing a single scalar value.cCs|j|jjS(sReturn the scalar value.(RQR+Rd(R((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs
(RRRRR(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRst
HostedFilecBs;eZdZddddZdZdZdZRS(sAA resource representing a file managed by a lazr.restful service.trcCs/|dkrt||||StddS(s5Open the file on the server for read or write access.Rtws'Invalid mode. Supported modes are: r, wN(RR(tHostedFileBuffert
ValueError(Rtmodetcontent_typetfilename((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pytopenscCs|jjj|jjdS(s Delete the file from the server.N(R*RktdeleteR+turl(R((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRscGsgS(s4HostedFile objects define no web service parameters.((RRM((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyR/scCs"|dk	o!|jj|jjkS(sEquality comparison.

        Two hosted files are the same if they have the same URL.

        There is no need to check the contents because the only way to
        retrieve or modify the hosted file contents is to open a
        filehandle, which goes direct to the server.
        N(RR+R(RR((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__eq__s	N(RRRRRRR/R(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs
		cBsaeZdZied6ed6ZdddddejdZ	e
dZdZdZ
RS(	sEntry point to the service. Subclass this for a service-specific client.

    :ivar credentials: The credentials instance used to access Launchpad.
    RRRwc	Cs|dk	rY|ddkr)|d7}n|t|7}|ddkrY|d7}qYnt||_||_||_t||||||j||_|jj	|j|_
|j
jd}	|	j|jj
|	d}
tt|jd|
dS(sRoot access to a lazr.restful API.

        :param credentials: The credentials used to access the service.
        :param service_root: The URL to the root of the web service.
        :type service_root: string
        it/Rwsapplication/jsonN(RtstrR
t	_root_urit_base_client_nametcredentialsRt_user_agentRktget_wadl_applicationRtget_resource_by_pathRaRtsuperRR(Rt
authorizertservice_roottcachettimeoutt
proxy_infotversiontbase_client_nametmax_retriest
root_resourcet
bound_root((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs"	
		cCsdt}|jdkr1|jd|d}nt}||d<|jdk	r|jj}x4t|D]#}||}|j||dqlWn|dS(sThe value for the User-Agent header.

        This will be something like:
        launchpadlib 1.6.1, lazr.restfulclient 1.0.0; application=apport

        That is, a string describing lazr.restfulclient and an
        optional custom client built on top, and parameters containing
        any authorization-specific information that identifies the
        user agent (such as the application name).
        slazr.restfulclient %sRws (t)s
User-AgentN(RRRRRtuser_agent_paramstsortedt	set_param(Rtbase_portiontmessageRRR((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs
	

cCst||||S(N(R(RRRRR((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pythttpFactoryscCst|}|jdkrM|d dkr8|d}n|jj|}n|jj|}ytjt|}Wn!t	k
rt	d|nX|jd}|d	krt	d|n|jjj
|}t|jj||j}|j|j||ddtS(
sLoad a resource given its URL.RwiRs!%s doesn't serve a JSON document.Rxs+Couldn't determine the resource type of %s.sapplication/jsonRfN(RtschemeRR?RkRRyRzR{RRR*RRtWadlResourceRRUR(RRtparsedtdocumentRdRRgR.((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pytloads&


N(RRRRRR`RRtMAX_RETRIESRRRRR(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs

		cBs;eZdZdZdZdZdZdZRS(s=A class for a named operation to be invoked with GET or POST.cCs||_||_||_dS(s/Initialize with respect to a WADL Method objectN(R-Rctwadl_method(RR-RcR((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs		cOs(t|dkr!tdn|jj}|j|}|jj}|dkr`|j}nZ|jd}|dkr|jd}n|dk	st	d|j
|jj}t
g|D]3}|jd	kst|jdkr|j^q}xB|jD]4\}	}
|	|kr
tj|
d
t||	<q
q
W|dkrr|jj|}d}i}
n4|jj}|jj|\}}i|d6}
|jjj|||jd
|
\}}|jdkr|j|||S|dkr|jjn|j|||SdS(s)Invoke the method and process the result.is(Method must be called with keyword args.RtheadRsmultipart/form-datas!application/x-www-form-urlencodedsYA POST named operation must define a multipart or form-urlencoded request representation.tbinaryRbRwsContent-typet
extra_headersiR8N(sgetsheadsdelete(sgetsheadsdelete(Rtt	TypeErrorRR:R'R;RYR=RtAssertionErrorR<RcR+tsetR|RsR!RytdumpsR
tbuild_request_urltbuild_representationR-Rkt_requesttuppertstatust_handle_201_responseRot_handle_200_response(Rtargstkwargsthttp_methodR;R<RDREtsend_as_is_paramsRRRtin_representationRRCtresponsetcontent((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__call__sJ		' 		
cCsn|jjjt|}|jd}|j}|jjj|j	\}}t
j|j|||dS(s5Handle the creation of a new resource by fetching it.tLocationscontent-type(RRRaRRRRTR-RkRRRRU(RRRRt
wadl_responsetwadl_parameterR.((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyROs	c

Cs!|d}|jj}|j|}|dkrW||jkrStjt|S|Stjt|}|dkr||Sd|krd|kr|d}|jj	j
|d}t|jj	||j}	n'|j
}t|jj	||j}	tj|j|	||dtd|S(s)Process the return value of an operation.scontent-typeR#RxRfR^N(RRR=RR)RyRzR{R-RRRRR>RRUR(
RRRRRtresponse_definitionR^RRgR.((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyR]s0
	

cCs|S(s/Named operation parameter names are sent as is.((RR(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyR$s(RRRRRRRR$(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyR	s		=		1cBsbeZdZdZdZdZdZdZdZdZ	d
dZd	ZRS(sBA class for an entry-type resource that can be updated with PATCH.cCsCtt|j||i|jd<tt|j||dS(Nt_dirty_attributes(RRRR,(RR-R.((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs
cCsdt|jj|jfS(s:Return the WADL resource type and the URL to the resource.s
<%s at %s>(R
RxtfragmentR#(R((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__repr__scCs|jjjt|jS(sDelete the resource.(R*RkRR
R#(R((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt	lp_deletescCs|jS(sReturn the URL to the resource.(R#(R((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__str__scCs?|dkr)||jkr)|j|Sntt|j|S(s-Try to retrive a parameter of the given name.R(RRRRr(RR:((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRrscCs?|j|s.td|jj|fn||j|<dS(s$Set the parameter of the given name.s!'%s' object has no attribute '%s'N(RORpt	__class__RR(RR:R((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__setattr__scCs@|dk	o?|j|jko?|j|jko?|j|jkS(sEquality operator.

        Two entries are the same if their self_link and http_etag
        attributes are the same, and if their dirty attribute dicts
        contain the same values.
        N(RR#t	http_etagR(RR((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRscCs<t|dd}tt|j|||jjdS(s&Update this resource's representation.RN(tgetattrRRRRoRtclear(RRmRn((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRoscCs|j|j}i}t|dd}|dk	rC||d<n|jjjt|j||\}}|j	dkr|j
|dn|jj|d}|j	dkr||jkrt
jt|}||j_||j_ndS(sSave changes to the entry.RsIf-Matchi-tlocationscontent-typeiN(R'RRRR*RktpatchR
R#RRoRR)RyRzR{R+RdRC(RRdRiRnRRRtnew_representation((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pytlp_saves 


N(
RRRRRRRRrRRRRoR(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs							
cBsMeZdZdZdZdZdZdZdZdZ	RS(s4A collection-type resource that supports pagination.cCstt|j||dS(sCreate a collection object.N(RRR(RR-R.((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRscCsH|j}t|tjkr"|St|tr8|jStddS(snThe number of items in the collection.

        :return: length of the collection
        :rtype: int
        s collection size is not availableN(t
total_sizeR|R}tIntTypeR"RRR(RR((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__len__s	ccs|j|jj}x~trx(|j|jdiD]}|Vq;W|jd}|dkriPntjt	|j
jjt|}qWdS(sqIterate over the items in the collection.

        :return: iterator
        :rtype: sequence of `Entry`
        tentriestnext_collection_linkN(
RQR+RdRt_convert_dicts_to_entriesRRRyRzR{R*RkR
(Rtcurrent_pageRct	next_link((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt__iter__
s
			cCset|tr|j|S|jt||d}t|dkrYtdn|dSdS(scLook up a slice, or a subordinate resource by index.

        To discourage situations where a lazr.restful client fetches
        all of an enormous list, all collection slices must have a
        definitive end point. For performance reasons, all collection
        slices must be indexed from the start of the list rather than
        the end.
        islist index out of rangeiN(R"tslicet
_get_sliceRtt
IndexError(RRtfound_slice((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs	
cCs|jpd}|j}|dkr3tdn|dkrNtdn|jj}|dk	r|t|dkr|d}t|}|||!}|jd}n'd}g}|j|jj	d|}||}	|	t|}
x|
dkr|dk	rt
jt|j
jj|}|d}|||
 7}|	t|}
|jd}|dkrxPn|dkrt|}n|
dkr|
|kr|j|d|
}qqW|jdk	r|dd|j}ng|j|D]}
|
^qS(	s!Retrieve a slice of a collection.is6Collection slices must have a nonnegative start point.s>Collection slices must have a definite, nonnegative end point.RRsws.startsws.sizeN(tstarttstopRR+RdRRtRt_with_url_query_variable_setRRyRzR{R*RktstepR(RRRRtexisting_representationt
entry_pagetfirst_page_sizetentry_dictstpage_urltdesired_sizetmore_neededRdtcurrent_page_entriesRc((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyR.sJ	



ccsxx|D]p}|d}|d}|jj}|j|}t|jj||j}tj|j|||jt	VqWdS(sConvert dictionaries describing entries to Entry objects.

        The dictionaries come from the 'entries' field of the JSON
        dictionary you get when you GET a page of a collection. Each
        dictionary is the same as you'd get if you sent a GET request
        to the corresponding entry resource. So each of these
        dictionaries can be treated as a preprocessed representation
        of an entry resource, and turned into an Entry instance.

        :yield: A sequence of Entry instances.
        R#RxN(
R+tapplicationRRRRRUR*R)R(RRt
entry_dicttresource_urlRxtwadl_applicationRgRc((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs


	cCset|}|jdkr$i}ntj|j}t|||<tj|t|_t|S(s1A helper method to set a query variable in a URL.N(	R
R6Rtcgitparse_qsRturllibt	urlencodeR(RRtvariablet	new_valueturiR<((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs	(
RRRRRRRRRR(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs					S	cBs/eZdZdZdZdZdZRS(sA collection-type resource that supports key-based lookup.

    This collection can be sliced, but any single index passed into
    __getitem__ will be treated as a custom lookup key.
    cCst|tr%tt|j|Sy|j|}Wntk
rWtdnX|dkrst	|n||}y|j
Wntk
r}t	|nX|S(s8Look up a slice, or a subordinate resource by unique ID.sunsubscriptable objectN(R"RRRRt_get_url_from_idtNotImplementedErrorRRRRQR(RRRt
shim_resourceRW((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs
cCs(y|j|}Wntk
r2tdnX|dkrNt|n|jdk	rd}t|jjj	d|j}nly(t
jt|jj
j|}Wn7tk
r}|jjdkrt|nnX|d}t|jj||}|j|j|d|dtS(s=Retrieve a member from this collection without looking it up.sunsubscriptable objectt#iRxRdRfN(RRRRRt
collection_ofR	R*Rt
markup_urlRyRzR{RkRRRRRRRUR(RRRRdRxterrorRc((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs,
	"
cCs
tdS(s2Transform the unique ID of an object into its URL.N(R(RR((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRsN(RRRRRRR	R(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs
		.RcBs&eZdZdddZdZRS(s8The contents of a file hosted by a lazr.restful service.c
Cse|jj|_|dkr|dk	r6tdn|dk	rQtdn|jjj|jdt\}}|d}|jd}|d}t|d}	t	j
|	jd	d
}n]|dkrd}|dkrtd
n|dkrtdnd}ntd||_||_
||_||_||_tj||dS(NRs8Files opened for read access can't specify content_type.s4Files opened for read access can't specify filename.treturn_responsescontent-types
last-modifiedscontent-locationiRiRRws8Files opened for write access must specify content_type.s4Files opened for write access must specify filename.s'Invalid mode. Supported modes are: r, w(R+RRRR*RkRRRRtunquotetsplitthosted_fileRRRt
last_modifiedRR(
RRRRRRRRtcontent_locationtpath((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs6

						cCsb|jdkrQd|j}|jjjj|j|j|ji|d6nt	j
|dS(NRsattachment; filename="%s"sContent-Disposition(RRRR*RktputRtgetvalueRRtclose(Rtdisposition((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs
N(RRRRRR(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyRs(()RR|t
__metaclass__t__all__Rt
email.messageRtImportErrort
email.MessageRyRR}RRR	tlazr.uriR
twadllib.applicationRRRkRRt_jsonR
terrorsRtlazr.restfulclientRRRRR RRRRRRRR(((s?/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.pyt<module>sH	
	
a^O