ɺh-xdZddlmZGddeZdZdZdZdZGd d eZ d Z d Z d Z dS)zContains FieldMask class.)FieldDescriptorcJeZdZdZdZdZdZdZdZdZ dZ d Z d d Z d S) FieldMaskz!Class for FieldMask message type.cg}|jD]$}|t|%d|S)z;Converts FieldMask to string according to proto3 JSON spec.,)pathsappend_SnakeCaseToCamelCasejoin)selfcamelcase_pathspaths /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib64/python3.11/site-packages/google/protobuf/internal/field_mask.py ToJsonStringzFieldMask.ToJsonString)sJO ::24889999 88O $ $$c"t|ts"td|||r?|dD]+}|jt|*dSdS)z;Converts string to FieldMask according to proto3 JSON spec.z'FieldMask JSON value not a string: {!r}rN) isinstancestr ValueErrorformatClearsplitr r _CamelCaseToSnakeCase)r valuers rFromJsonStringzFieldMask.FromJsonString0s eS ! !P @GGNN O OOJJLLL 7++c""77$ /5566667777rc@|jD]}t||sdSdS)z=Checks whether the FieldMask is valid for Message Descriptor.FT)r _IsValidPath)r message_descriptorrs rIsValidForDescriptorzFieldMask.IsValidForDescriptor9s7  ,d 3 3uu 4rc||jD]!}|j|j"dS)z:Gets all direct fields of Message Descriptor to FieldMask.N)rfieldsr r name)r rfields rAllFieldsFromDescriptorz!FieldMask.AllFieldsFromDescriptor@sFJJLLL#*$$ j ####$$rcNt|}||dS)a: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)_FieldMaskTree ToFieldMask)r masktrees rCanonicalFormFromMaskzFieldMask.CanonicalFormFromMaskFs+ $  DTrct|t|t|}||||dS)z+Merges mask1 and mask2 into this FieldMask.N)_CheckFieldMaskMessager'MergeFromFieldMaskr()r mask1mask2r*s rUnionzFieldMask.UnionSsY5!!!5!!! % DE"""Trct|t|t|}t}|jD]}|||||dS)z/Intersects mask1 and mask2 into this FieldMask.N)r-r'r IntersectPathr()r r/r0r* intersectionrs r IntersectzFieldMask.Intersect[sz5!!!5!!! % D!##L -- |,,,,T"""""rFcTt|}|||||dS)aMerges 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)r' MergeMessage)r source destinationreplace_message_fieldreplace_repeated_fieldr*s rr7zFieldMask.MergeMessageesC $  D 24JLLLLLrN)FF) __name__ __module__ __qualname____doc__ __slots__rrr r%r+r1r5r7rrrrr$s)))%%%777$$$   ###;@LLLLLLrrc|d}|}|D]R}|j|}|*|jt jks|jt jkrdS|j }S||jvS)z8Checks whether the path is valid for Message Descriptor..NF) rpopfields_by_namegetlabelrLABEL_REPEATEDtype TYPE_MESSAGE message_type)rrpartslastr#r$s rrrws **S//% $,,d  - 1 1$ 7 7E  555 o222 UU+ #2 22rc|j}|jdks|jjdkr'td|jdS)z0Raises ValueError if message is not a FieldMask.rz google/protobuf/field_mask.protozMessage {0} is not a FieldMask.N) DESCRIPTORr#filerr full_name)messagers rr-r-s_),,"&HHH 6==$&& ' ''IHrcg}d}|D]}|r"td||r`|r*||d}xtd||dkrd}||z }|r"td|d|S)z2Converts a path name from snake_case to camelCase.FzYFail to print FieldMask to Json string: Path name {0} must not contain uppercase letters.znFail to print FieldMask to Json string: The character after a "_" must be a lowercase letter in path name {0}._TzFFail to print FieldMask to Json string: Trailing "_" in path name {0}.)isupperrrislowerr upperr ) path_nameresultafter_underscorecs rr r s & ayy{{G  44:F94E4E G GG  3 aggii     &y 1 133 3 c kff< ))/ ):): < << rcg}|D]`}|dkr"td||r|dz }||z }[||z }ad|S)z3Converts a field name from camelCase to snake_case.rSz=Fail to parse FieldMask: Path name {0} must not contain "_"s.rT)rrrUlowerr )rXrYr[s rrrs & aCxx 44:F94E4E G GGyy{{ mf  ff kff rcBeZdZdZdZd dZdZdZdZdZ d Z d Z dS) r'a7Represents 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. )_rootNcFi|_|r||dSdS)z"Initializes the tree by FieldMask.N)r_r.r field_masks r__init__z_FieldMaskTree.__init__s5DJ* j)))))**rcD|jD]}||dS)zMerges a FieldMask to the tree.N)r AddPath)r rbrs rr.z!_FieldMaskTree.MergeFromFieldMasks3  ll4rc|j}|dD]}||vri||<n ||sdS||} |dS)a Adds a field path into the tree. If the field path to add is a sub-path of an existing field path in the tree (i.e., a leaf node), it means the tree already matches the given path so nothing will be added to the tree. If the path matches an existing non-leaf node in the tree, that non-leaf node will be turned into a leaf node with all its children removed because the path matches all the node's children. Otherwise, a new path will be added. Args: path: The field path to add. rBN)r_rclear)r rnoder#s rrez_FieldMaskTree.AddPathsi :D 3 T  T Dz $ZddJJLLLLLrcZ|t|jd|dS)z!Converts the tree to a FieldMask.rTN)r_AddFieldPathsr_ras rr(z_FieldMaskTree.ToFieldMasks.4:r:.....rc|j}|dD]1}||vrdS||s||dS||}2|||dS)zCalculates the intersection part of a field path with this tree. Args: path: The field path to calculates. intersection: The out tree to record the intersection part. rBN)r_rre AddLeafNodes)r rr4rhr#s rr3z_FieldMaskTree.IntersectPaths :D 3 T  DzT""" $ZdddD)))))rc|s|||D]&}|dz|z}||||'dS)z/Adds leaf nodes begin with prefix to this tree.rBN)rerl)r prefixrhr# child_paths rrlz_FieldMaskTree.AddLeafNodess`  ll600C<$&j  DJ////00rc6t|j||||dS)zCMerge all fields specified by this tree from source to destination.N) _MergeMessager_)r r8r9replace_messagereplace_repeateds rr7z_FieldMaskTree.MergeMessage s3 FK:JLLLLLr)N) r<r=r>r?r@rcr.rer(r3rlr7rrrr'r's  )****  2/// ***"000LLLLLrr'cZt|ts|dS|S)z#Converts value to str if it is not.zutf-8)rrencode)rs r _StrConvertrvs- E3  ! <<  ,rc |j}|D]}||}|j|}|(td||j|r|jt jks|jt j kr(td||j| |r/t|t||t|||||jt jkr[|r"| t|t||} t||} | | K|jt j krl|r"| t|| |r1t||t||t!||t||dS)zDMerge all fields specified by a sub-tree from source to destination.Nz+Error: Can't find field {0} in message {1}.z[Error: Field {0} in message {1} is not a singular message field and cannot have sub-fields.)rNrDrrrPrFrrGcpp_typeCPPTYPE_MESSAGEHasFieldrqgetattr ClearFieldrv MergeFromsetattr) rhr8r9rrrssource_descriptorr#childr$repeated_sourcerepeated_destinations rrqrqs'::d JE  ,T 2E } ELL !+-- . ..  +7 7 7 .O; ; ;EEKV!#4#>F@F@AA A   / 764(('+t*D*D - / / / {o444 2{400111--o$[$77$$_5555 ?: : :  4  T!2!2 3 3 3 ??4  F +t $ $ . .wvt/D/D E E E T764#8#89999?::rc|s|r|j|dSt|D]&}|r |dz|z}n|}t||||'dS)z7Adds the field paths descended from node to field_mask.NrB)r r sortedrj)rhrnrbr#ros rrjrjCs  & F### FTll77d C<$&jjj4:z:6666 77rN) r?google.protobuf.descriptorrobjectrrr-r rr'rvrqrjrrrrs > 666666PLPLPLPLPLPLPLPLf 3 3 3''':   VLVLVLVLVLVVLVLVLr#:#:#:L 7 7 7 7 7r