� S�Ljc@sdZdZddlZddlmZddlmZddlZddlmZdZdZ d Z d Z d Z d Z d1Zd Zdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZd�Zd�Zdefd��YZd�Zd�Zd�Zd�Zd efd!��YZd"�Zd#�Z d$�Z!ej"e#fZ$d%�Z%d&�Z&d'efd(��YZ'ej(j)e'�d)efd*��YZ*ej+j)e*�ied+6ed,6ed-6e*d.6e'd/6ed06Z,dS(2s�Contains well known classes. This files defines well known classes which need extra maintenance including: - Any - Duration - FieldMask - Struct - Timestamp smail protected] (Jie Luo)i����N(tdatetime(t timedelta(tFieldDescriptors%Y-%m-%dT%H:%M:%SiÊš;i@Bi�iil�s%tErrorcBseZdZRS(sTop-level module error.(t__name__t __module__t__doc__(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR<st ParseErrorcBseZdZRS(s Thrown in case of parsing error.(RRR(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR@stAnycBs8eZdZddd�Zd�Zd�Zd�ZRS(sClass for Any Message type.stype.googleapis.com/cCspt|�dks"|ddkr>d||jjf|_nd||jjf|_|jd|�|_dS(s5Packs the specified message into current Any message.ii����t/s%s/%ss%s%st deterministicN(tlent DESCRIPTORt full_namettype_urltSerializeToStringtvalue(tselftmsgttype_url_prefixR ((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytPackGs"cCs0|j}|j|�stS|j|j�tS(s7Unpacks the current Any message into specified message.(R tIstFalsetParseFromStringRtTrue(RRt descriptor((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytUnpackPs  cCs|jjd�dS(s4Returns the protobuf type name of the inner message.R i����(Rtsplit(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytTypeNameXscCs|j�|jkS(s6Checks if this Any represents the given protobuf type.(RR (RR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR]sN(RRRtNoneRRRR(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRDs    t TimestampcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z d �Z d �Z d �Zd �ZRS(s!Class for Timestamp message type.cCs�|jt}|j|j|t}|t}||t}tddd�t||�}|j�}|ddkr�|dS|ddkr�|d|dS|ddkr�|d |dS|d |S( s#Converts Timestamp to RFC 3339 date string format. Returns: A string converted from timestamp. The string is always Z-normalized and uses 3, 6 or 9 fractional digits as required to represent the exact time. Example of the return format: '1972-01-01T10:00:20.021Z' i�ige��AitZg��.As.%03dZg@�@s.%06dZs.%09dZ(tnanost_NANOS_PER_SECONDtsecondst_SECONDS_PER_DAYRRt isoformat(RR t total_secR"tdaystdttresult((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt ToJsonStringes   c CsY|jd�}|dkr-|jd�}n|dkrK|jd�}n|dkrftd��n|d|!}|jd�}|dkr�|}d}n|| }||d }tj|t�}|td d d �}|j|jt} t |�d krtd j |���n|r>t t d |�d�} nd} ||dkr�t |�|d kr7tdj |���q7n�||} | jd�} | dkr�tdj | ���n| ddkr| t | d | !�dt | | d �d8} n1| t | d | !�dt | | d �d7} t | �|_t | �|_dS(sNParse a RFC 3339 date string format to Timestamp. Args: value: A date string. Any fractional digits (or none) and any offset are accepted as long as they fit into nano-seconds precision. Example of accepted format: '1972-01-01T10:00:20.021-05:00' Raises: ParseError: On parsing problems. Ri����t+t-s9Failed to parse timestamp: missing valid timezone offset.it.tii�i sCFailed to parse Timestamp: nanos {0} more than 9 fractional digits.s0.ge��As5Failed to parse timestamp: invalid trailing data {0}.t:s#Invalid timezone offset value: {0}.i<N(tfindtrfindRRtstrptimet_TIMESTAMPFOMATR"R&R#R tformattroundtfloattintR ( RRttimezone_offsett time_valuetpoint_positiont second_valuet nano_valuet date_objectttdR"R ttimezonetpos((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytFromJsonString�sN            41cCs|jtj��dS(s#Get the current UTC into Timestamp.N(t FromDatetimeRtutcnow(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytGetCurrentTime�scCs|jt|jS(s.Converts Timestamp to nanoseconds since epoch.(R"R!R (R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt ToNanoseconds�scCs|jt|jtS(s/Converts Timestamp to microseconds since epoch.(R"t_MICROS_PER_SECONDR t_NANOS_PER_MICROSECOND(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytToMicroseconds�s cCs|jt|jtS(s/Converts Timestamp to milliseconds since epoch.(R"t_MILLIS_PER_SECONDR t_NANOS_PER_MILLISECOND(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytToMilliseconds�s cCs|jS(s*Converts Timestamp to seconds since epoch.(R"(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt ToSeconds�scCs|t|_|t|_dS(s.Converts nanoseconds since epoch to Timestamp.N(R!R"R (RR ((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytFromNanoseconds�s cCs"|t|_|tt|_dS(s/Converts microseconds since epoch to Timestamp.N(RER"RFR (Rtmicros((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytFromMicroseconds�s cCs"|t|_|tt|_dS(s/Converts milliseconds since epoch to Timestamp.N(RHR"RIR (Rtmillis((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytFromMilliseconds�s cCs||_d|_dS(s*Converts seconds since epoch to Timestamp.iN(R"R (RR"((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt FromSeconds�s cCs!tj|j|jtt��S(sConverts Timestamp to datetime.(RtutcfromtimestampR"R R5R!(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt ToDatetime�scCsA|tddd�}|j|jt|_|jt|_dS(sConverts datetime to Timestamp.i�iN(RR"R&R#t microsecondsRFR (RR'R=((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRA�s(RRRR)R@RCRDRGRJRKRLRNRPRQRSRA(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRbs  :          tDurationcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z d �Z d �Z d �Zd �ZRS(s Class for Duration message type.cCs t|j|j�|jdks1|jdkrjd}|j td|jd�}d|jd}n-d}|jt|jd�}|jd}|d|7}|ddkr�|dS|ddkr�|d|dS|d dkr�|d |d S|d |S( s+Converts Duration to string format. Returns: A string converted from self. The string format will contains 3, 6, or 9 fractional digits depending on the precision required to represent the exact Duration value. For example: "1s", "1.010s", "1.000000100s", "-3.100s" iR+ge��AR-s%dtsg��.As.%03dsg@�@s.%06dss.%09ds(t_CheckDurationValidR"R R6(RR(R"R ((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR)�s  cCs9t|�dks"|ddkr:tdj|���ny�|jd�}|dkrqt|d �}d}n{t|| �}|ddkr�tttdj||d!��d ��}n,tttd j||d!��d ��}t||�||_||_ Wn&t k r4td j|���nXd S( s?Converts a string to Duration. Args: value: A string to be converted. The string must end with 's'. Any fractional digits (or none) are accepted as long as they fit into precision. For example: "1s", "1.01s", "1.0000001s", "-3.100s Raises: ParseError: On parsing problems. ii����RVs'Duration must end with letter "s": {0}.R,iR+s-0{0}ge��As0{0}sCouldn't parse duration: {0}.N( R RR3R/R6R4R5RWR"R t ValueError(RRR?R"R ((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR@s$ "  /,    cCs|jt|jS(s#Converts a Duration to nanoseconds.(R"R!R (R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRD4scCs!t|jt�}|jt|S(s$Converts a Duration to microseconds.(t_RoundTowardZeroR RFR"RE(RRM((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRG8scCs!t|jt�}|jt|S(s$Converts a Duration to milliseconds.(RYR RIR"RH(RRO((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRJ=scCs|jS(sConverts a Duration to seconds.(R"(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRKBscCs|j|t|t�dS(s!Converts nanoseconds to Duration.N(t_NormalizeDurationR!(RR ((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRLFs cCs |j|t|tt�dS(s"Converts microseconds to Duration.N(RZRERF(RRM((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRNKscCs |j|t|tt�dS(s"Converts milliseconds to Duration.N(RZRHRI(RRO((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRPQscCs||_d|_dS(sConverts seconds to Duration.iN(R"R (RR"((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRQWs cCs"td|jdt|jt��S(sConverts Duration to timedelta.R"RT(RR"RYR RF(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt ToTimedelta\s cCs)|j|j|jt|jt�dS(sConverts timedelta to Duration.N(RZR"R&R#RTRF(RR=((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt FromTimedeltabscCsE|dkr/|dkr/|d7}|t8}n||_||_dS(s"Set Duration by seconds and nanos.iiN(R!R"R (RR"R ((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRZgs    (RRRR)R@RDRGRJRKRLRNRPRQR[R\RZ(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRU�s          cCsf|t ks|tkr1tdj|���n|t ksJ|tkrbtdj|���ndS(NsRDuration is not valid: Seconds {0} must be in range [-315576000000, 315576000000].sJDuration is not valid: Nanos {0} must be in range [-999999999, 999999999].(t_DURATION_SECONDS_MAXRR3R!(R"R ((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRWqscCs<||}||}|dkr4|dkr4|dS|SdS(s,Truncates the remainder part after division.iiN((RtdividerR(t remainder((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRY|s   t FieldMaskcBs\eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z e e d�Z RS( s!Class for FieldMask message type.cCs:g}x$|jD]}|jt|��qWdj|�S(s;Converts FieldMask to string according to proto3 JSON spec.t,(tpathstappendt_SnakeCaseToCamelCasetjoin(Rtcamelcase_pathstpath((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR)�scCs>|j�x-|jd�D]}|jjt|��qWdS(s;Converts string to FieldMask according to proto3 JSON spec.RaN(tClearRRbRct_CamelCaseToSnakeCase(RRRg((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR@�s cCs+x$|jD]}t||�s tSq WtS(s=Checks whether the FieldMask is valid for Message Descriptor.(Rbt _IsValidPathRR(Rtmessage_descriptorRg((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytIsValidForDescriptor�scCs5|j�x$|jD]}|jj|j�qWdS(s:Gets all direct fields of Message Descriptor to FieldMask.N(RhtfieldsRbRctname(RRktfield((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytAllFieldsFromDescriptor�s cCst|�}|j|�dS(s:Converts a FieldMask to the canonical form. Removes paths that are covered by another path. For example, "foo.bar" is covered by "foo" and will be removed if "foo" is also in the FieldMask. Then sorts all paths in alphabetical order. Args: mask: The original FieldMask to be converted. N(t_FieldMaskTreet ToFieldMask(Rtmaskttree((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytCanonicalFormFromMask�s cCs>t|�t|�t|�}|j|�|j|�dS(s+Merges mask1 and mask2 into this FieldMask.N(t_CheckFieldMaskMessageRqtMergeFromFieldMaskRr(Rtmask1tmask2Rt((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytUnion�s     cCs^t|�t|�t|�}t�}x!|jD]}|j||�q3W|j|�dS(s/Intersects mask1 and mask2 into this FieldMask.N(RvRqRbt IntersectPathRr(RRxRyRtt intersectionRg((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt Intersect�s    cCs&t|�}|j||||�dS(s�Merges fields specified in FieldMask from source to destination. Args: source: Source message. destination: The destination message to be merged into. replace_message_field: Replace message field if True. Merge message field if False. replace_repeated_field: Replace repeated field if True. Append elements of repeated field if False. N(Rqt MergeMessage(Rtsourcet destinationtreplace_message_fieldtreplace_repeated_fieldRt((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR~�s ( RRRR)R@RlRpRuRzR}RR~(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR`�s      cCs�|jd�}|j�}x]|D]U}|jj|�}|dksj|jtjksj|jtj krnt S|j }q"W||jkS(s8Checks whether the path is valid for Message Descriptor.R,N( Rtpoptfields_by_nametgetRtlabelRtLABEL_REPEATEDttypet TYPE_MESSAGERt message_type(RkRgtpartstlastRnRo((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRj�s    cCsI|j}|jdks*|jjdkrEtdj|j���ndS(s0Raises ValueError if message is not a FieldMask.R`s google/protobuf/field_mask.protosMessage {0} is not a FieldMask.N(R RntfileRXR3R (tmessageRk((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRv�s   cCs�g}t}x�|D]�}|j�r=tdj|���n|r�|j�rk|j|j��t}q�tdj|���q|dkr�t}q||7}qW|r�tdj|���ndj|�S(s2Converts a path name from snake_case to camelCase.sYFail to print FieldMask to Json string: Path name {0} must not contain uppercase letters.snFail to print FieldMask to Json string: The character after a "_" must be a lowercase letter in path name {0}.t_sFFail to print FieldMask to Json string: Trailing "_" in path name {0}.R-( RtisupperRR3tislowerRctupperRRe(t path_nameR(tafter_underscoretc((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRd�s&         cCs{g}xe|D]]}|dkr7tdj|���n|j�r`|d7}||j�7}q ||7}q Wdj|�S(s3Converts a field name from camelCase to snake_case.R�s=Fail to parse FieldMask: Path name {0} must not contain "_"s.R-(RR3R�tlowerRe(R�R(R�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRi s     RqcBsPeZdZdd�Zd�Zd�Zd�Zd�Zd�Z d�Z RS( s7Represents a FieldMask in a tree structure. For example, given a FieldMask "foo.bar,foo.baz,bar.baz", the FieldMaskTree will be: [_root] -+- foo -+- bar | | | +- baz | +- bar --- baz In the tree, each leaf node represents a field path. cCs#i|_|r|j|�ndS(s"Initializes the tree by FieldMask.N(t_rootRw(Rt field_mask((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt__init__'s cCs%x|jD]}|j|�q WdS(sMerges a FieldMask to the tree.N(RbtAddPath(RR�Rg((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRw-scCsb|j}xH|jd�D]7}||kr8i||         %cCsf|s|jj|�dSxEt|�D]7}|rD|d|}n|}t||||�q'WdS(s7Adds the field paths descended from node to field_mask.NR,(RbRctsortedR�(R�R�R�RnR�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR��scCs�|dkrd|_n�t|t�r3||_n�t|tj�rQ||_n�t|t�rl||_ njt|t �r�|j j �|j j |�n;t|t�r�|jj �|jj|�n td��dS(NisUnexpected type(Rt null_valueR�tboolt bool_valuetsixt string_typest string_valuet _INT_OR_FLOATt number_valuetdictt struct_valueRhtupdatetlistt list_valueR�RX(R�R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt_SetStructValue�s       cCs�|jd�}|dkr"|jS|dkr2dS|dkrE|jS|dkrX|jS|dkrk|jS|dkr~|jS|dkr�td��ndS( NtkindR�R�R�R�R�R�s Value not set(t WhichOneofR�RR�R�R�R�RX(R�twhich((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt_GetStructValue�s       tStructcBs�eZdZgZd�Zd�Zd�Zd�Zd�Zd�Z d�Z d�Z d �Z d �Z d �Zd �ZRS( sClass for Struct message type.cCst|j|�S(N(R�Rm(Rtkey((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt __getitem__�scCs ||jkS(N(Rm(RR�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt __contains__�scCst|j||�dS(N(R�Rm(RR�R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt __setitem__�scCs|j|=dS(N(Rm(RR�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt __delitem__�scCs t|j�S(N(R Rm(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt__len__�scCs t|j�S(N(titerRm(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt__iter__�scCs |jj�S(N(Rmtkeys(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR��scCsg|D]}||^qS(N((RR�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytvalues�scCs!g|D]}|||f^qS(N((RR�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytitems�scCs;|j|jd�s-|j|jj�n|j|jS(sAReturns a list for this key, creating if it didn't exist already.R�(RmR�R�Rh(RR�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytget_or_create_list�scCs;|j|jd�s-|j|jj�n|j|jS(sCReturns a struct for this key, creating if it didn't exist already.R�(RmR�R�Rh(RR�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytget_or_create_structscCs5x.|j�D] \}}t|j||�q WdS(N(R�R�Rm(Rt dictionaryR�R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR� s(RRRt __slots__R�R�R�R�R�R�R�R�R�R�R�R�(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR��s           t ListValuecBs_eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z RS( s!Class for ListValue message type.cCs t|j�S(N(R R�(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR�scCst|jj�|�dS(N(R�R�R�(RR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRcscCs"x|D]}|j|�qWdS(N(Rc(Rtelem_seqR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR�s cCst|jj|��S(s&Retrieves item by the specified index.(R�R�R�(Rtindex((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR�scCst|jj|�|�dS(N(R�R�R�(RR�R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR�!scCs|j|=dS(N(R�(RR�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR�$sccs*x#tt|��D]}||VqWdS(N(trangeR (Rti((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR�'scCs |jj�j}|j�|S(sAAppends and returns a struct value as the next value in the list.(R�R�R�Rh(RR�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt add_struct+s cCs |jj�j}|j�|S(s?Appends and returns a list value as the next value in the list.(R�R�R�Rh(RR�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytadd_list2s ( RRRR�RcR�R�R�R�R�R�R�(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR�s        sgoogle.protobuf.Anysgoogle.protobuf.Durationsgoogle.protobuf.FieldMasksgoogle.protobuf.ListValuesgoogle.protobuf.Structsgoogle.protobuf.Timestampi�Q(-Rt __author__t collectionsRRR�tgoogle.protobuf.descriptorRR2R!RIRFRHRER#R]t ExceptionRRtobjectRRRURWRYR`RjRvRdRiRqR�R�R�t integer_typesR5R�R�R�R�tMutableMappingtregisterR�tMutableSequencetWKTBASES(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt'sX  �� N   W )   2)