gddlZddlZddlmZddlmZddlmZgej_ dgZ dZ dZ dZ d Zd Zd Zd ZGd deZy)N)tostring) OrderedDict)IntEnumSNAPSHOTct|tr|Dcgc] }t|c}St|tr-|j Dcic]\}}|t|c}}Sdt |dScc}wcc}}w)zV recursively traverse nested dict and add xml CDATA element to the leaves z ) isinstancelist add_cdatadictitemsstr)dxkvs 9/opt/hc_python/lib/python3.12/site-packages/pyone/util.pyr r sw !T'(*q!1q** At ./ggi8iUaIaLi883q6(#&& +9s A6 A;cd}t|tr |jSt|trt |dr |j }t |rkt|jd}||r!tjt|ddSd}|jD]\}}||d|d}|Std |S) ae This function will cast parameters to make them nebula friendly flat dictionaries will be turned into attribute=value vectors dictionaries with root dictionary will be serialized as XML Structures will be turned into strings before being submitted. :param param: the parameter to make nebula friendly :return: casted parameter cR|jD]}t|tsyy)NTF)valuesrr ) dictionaryvals ris_nested_dictz cast2one..is_nested_dict8s'$$&C#t$'_rootrF)indentnewlinesz="z" zCannot cast empty dictionary) rrvaluer hasattrrboolr rdict2xmlr r Exception)paramrrootretrrs rcast2oner&-s %!{{% 5' "KKE ; '*De$((5)9/1ECC#kkmFQ03Q:C, :; ; rc|jS)aW This function returns a dictionary from an anyType binding element The dictionary can then be used later as imput for an udpate This is now deprecated, included for backward compatibility. :param element: anyType element to be converted such as TEMLATE or USER_TEMPLATE :return: a dictionary representing the element )r)elements rone2dictr)Ys ==rc|jD].\}}t|tk(r t|$|dk(s*d||<0y)Nr)r typer none2emptystr)rrrs rr,r,fs:wwy! 7k ! !  $YAaD rc|dk(rEt|ddr5|d}tD]&}||vst||tk7s||g||<(yyy)NTEMPLATE__iter__)rTEMPLATE_ALWAYS_LIST_ELEMr+r )rtagtmplelems rfix_dictr4ns[ jWQz]J?}.Dt|T$Z 0D 8#Dz^T . @rct|}tj|d}t||jd|jvr%|jj dd}||d=n |j}||dk(r t ||<t|t||t s$t||trt ||||<|||_ ||S)zv Creates a dictionary from the documentTree obtained from a binding Element. :param element: :return: F)strip_whitespace}z@xmlnsN) r xmltodictparser4r1splitrr,rr r)r(xmlr%tagNames r child2dictr>xs 7 C //# 6C S'++ gkk++##C(+ L "++ 7|t"}G # c'lK 0ZG d5S"3w<0G CL w<rc\|dk(rt||_y|dk(rt||_yy)z Utility function to build an anyType element that can be accessed as a dictionary :param obj: :param nodeName: :param child: :return: r.T USER_TEMPLATEF)r>r.r@)objnodeNamechilds rbuild_template_noderDs6:!%(  _ $&u-rc*eZdZdZdZdfd ZxZS) TemplatedTypez, Mixin class for Templated bindings c2t|t|d<y)N custom_attrs)r vars)selfnodeattrsalready_processeds r_buildAttributeszTemplatedType._buildAttributess%)%[T >"rcPt|||stt||||||yy)N)rDsuperrF_buildChildren)rJchild_rK nodeName_ fromsubclass_gds_collector_ __class__s rrQzTemplatedType._buildChildrens,"4F; - 5fT)MZh irDobjectrFrrrcs_"# 'L ' )X , F$ jF jr