SLjc@sdZdZddlZddlmZddlmZddlZddlmZdZdZ d Z d Z d Z d Z d1Zd ZdefdYZdefdYZdefdYZdefdYZdefdYZdZdZdefdYZdZdZdZdZd 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(2sContains well known classes. This files defines well known classes which need extra maintenance including: - Any - Duration - FieldMask - Struct - Timestamp sjieluo@google.com (Jie Luo)iN(tdatetime(t timedelta(tFieldDescriptors%Y-%m-%dT%H:%M:%Siʚ;i@Biiils%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@stAnycBs8eZdZdddZdZdZdZRS(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.iit/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|jtS(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|jjddS(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 TimestampcBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZRS(s!Class for Timestamp message type.cCs|jt}|j|j|t}|t}||t}tdddt||}|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' iigeAitZg.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|dkrftdn|d|!}|jd}|dkr|}d}n|| }||d }tj|t}|td d d }|j|jt} t |d krtd j |n|r>t t d |d} nd} ||dkrt ||d kr7tdj |q7n||} | jd} | dkrtdj | 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. Rit+t-s9Failed to parse timestamp: missing valid timezone offset.it.tiii sCFailed to parse Timestamp: nanos {0} more than 9 fractional digits.s0.geAs5Failed 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.pytFromJsonStringsN            41cCs|jtjdS(s#Get the current UTC into Timestamp.N(t FromDatetimeRtutcnow(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytGetCurrentTimescCs|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 ToNanosecondsscCs|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.pytToMicrosecondss 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.pytToMillisecondss 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 ToSecondsscCs|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.pytFromNanosecondss 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.pytFromMicrosecondss 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.pytFromMillisecondss 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 FromSecondss cCs!tj|j|jttS(sConverts Timestamp to datetime.(RtutcfromtimestampR"R R5R!(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt ToDatetimescCsA|tddd}|j|jt|_|jt|_dS(sConverts datetime to Timestamp.iiN(RR"R&R#t microsecondsRFR (RR'R=((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRAs(RRRR)R@RCRDRGRJRKRLRNRPRQRSRA(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRbs  :          tDurationcBseZdZdZdZdZdZdZdZdZ dZ 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+geAR-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|| }|ddkrtttdj||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. iiRVs'Duration must end with letter "s": {0}.R,iR+s-0{0}geAs0{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|tdS(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|ttdS(s"Converts microseconds to Duration.N(RZRERF(RRM((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRNKscCs |j|t|ttdS(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|jtS(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|jtdS(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.pyRUs          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\eZdZdZdZdZdZdZdZdZ e e dZ 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>|jx-|jdD]}|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.pytIsValidForDescriptorscCs5|jx$|jD]}|jj|jqWdS(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.pytAllFieldsFromDescriptors 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.pytCanonicalFormFromMasks 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.pytUnions     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 Intersects    cCs&t|}|j||||dS(sMerges 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.pyRjs    cCsI|j}|jdks*|jjdkrEtdj|jndS(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.pyRvs   cCsg}t}x|D]}|jr=tdj|n|r|jrk|j|jt}qtdj|q|dkrt}q||7}qW|rtdj|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.pyRds&         cCs{g}xe|D]]}|dkr7tdj|n|jr`|d7}||j7}q ||7}q Wdj|S(s3Converts a field name from camelCase to snake_case.Rs=Fail to parse FieldMask: Path name {0} must not contain "_"s.R-(RR3RtlowerRe(RR(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRi s     RqcBsPeZdZddZdZdZdZdZdZ dZ 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(RRRg((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRw-scCsb|j}xH|jdD]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(RRRRnR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRscCs|dkrd|_nt|tr3||_nt|tjrQ||_nt|trl||_ njt|t r|j j |j j |n;t|tr|jj |jj|n tddS(NisUnexpected type(Rt null_valueRtboolt bool_valuetsixt string_typest string_valuet _INT_OR_FLOATt number_valuetdictt struct_valueRhtupdatetlistt list_valueRRX(RR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt_SetStructValues       cCs|jd}|dkr"|jS|dkr2dS|dkrE|jS|dkrX|jS|dkrk|jS|dkr~|jS|dkrtdndS( NtkindRRRRRRs Value not set(t WhichOneofRRRRRRRX(Rtwhich((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt_GetStructValues       tStructcBseZdZgZdZdZdZdZdZdZ dZ dZ d Z d Z d Zd ZRS( sClass for Struct message type.cCst|j|S(N(RRm(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(RRm(RRR((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|jS(N(R Rm(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt__len__scCs t|jS(N(titerRm(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt__iter__scCs |jjS(N(Rmtkeys(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRscCsg|D]}||^qS(N((RR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytvaluesscCs!g|D]}|||f^qS(N((RR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytitemsscCs;|j|jds-|j|jjn|j|jS(sAReturns a list for this key, creating if it didn't exist already.R(RmRRRh(RR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytget_or_create_listscCs;|j|jds-|j|jjn|j|jS(sCReturns a struct for this key, creating if it didn't exist already.R(RmRRRh(RR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytget_or_create_structscCs5x.|jD] \}}t|j||q WdS(N(RRRm(Rt dictionaryRR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyR s(RRRt __slots__RRRRRRRRRRRR(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRs           t ListValuecBs_eZdZdZdZdZdZdZdZdZ dZ d Z RS( s!Class for ListValue message type.cCs t|jS(N(R R(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRscCst|jj|dS(N(RRR(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.pyRs cCst|jj|S(s&Retrieves item by the specified index.(RRR(Rtindex((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRscCst|jj||dS(N(RRR(RRR((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 |jjj}|j|S(sAAppends and returns a struct value as the next value in the list.(RRRRh(RR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt add_struct+s cCs |jjj}|j|S(s?Appends and returns a list value as the next value in the list.(RRRRh(RR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pytadd_list2s ( RRRRRcRRRRRRR(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyRs        sgoogle.protobuf.Anysgoogle.protobuf.Durationsgoogle.protobuf.FieldMasksgoogle.protobuf.ListValuesgoogle.protobuf.Structsgoogle.protobuf.TimestampiQ(-Rt __author__t collectionsRRRtgoogle.protobuf.descriptorRR2R!RIRFRHRER#R]t ExceptionRRtobjectRRRURWRYR`RjRvRdRiRqRRRt integer_typesR5RRRRtMutableMappingtregisterRtMutableSequencetWKTBASES(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.pyt'sX   N   W )   2)