grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a q©j@ã@sâddlmZddlmZmZmZmZmZmZm Z m Z m Z m Z e e eedfZe de defZee efZe ddefZee efZeeZe dƒZe d ƒZGd d „d eƒZee eed œd d„ZGdd„deƒZejZeeegefe e eefe eefdœdd„Zefee e eefe eefdœdd„Zefee e eefe ee fdœdd„Z!efee e eefe ee fdœdd„Z"ee ee ee dœdd„Z#ee ee e e fee e e fdœdd„Z$efee e eefe eefdœdd „Z%efee eegefe eefe eefd!œd"d#„Z&efee e eefe ee e fdœd$d%„Z'efee ee e eefe ee fd&œd'd(„Z(ee eegefe ee efd)œd*d+„Z)d,eed-œd.d/„Z*eeed0œd1d2„Z+eedd0œd3d4„Z,dS)5é)ÚEnum) ÚCallableÚ ContainerÚDictÚListÚMappingÚOptionalÚSequenceÚTypeÚTypeVarÚUnionNÚ JsonObjectÚ JsonValueÚJsonDictÚJsonListÚDTÚTcs.eZdZUeed<eedœ‡fdd„ Z‡ZS)Ú JsonErrorÚvalue)rÚmsgcstƒ |¡||_dS©N)ÚsuperÚ__init__r)Úselfrr©Ú __class__©ú4/usr/lib/python3.9/site-packages/cockpit/jsonutil.pyrs zJsonError.__init__)Ú__name__Ú __module__Ú __qualname__ÚobjectÚ__annotations__ÚstrrÚ __classcell__rrrrrs r)rÚ expected_typeÚreturncCs t||ƒst|d|j›�ƒ‚|S)z>Ensure a JSON value has the expected type, returning it if so.zmust have type )Ú isinstancerr)rr%rrrÚ typechecked!s r(c@seZdZdZdS)Ú_EmptyrN)rrr ÚTOKENrrrrr)+sr))ÚobjÚcastÚkeyÚdefaultr&c Cs¤z|||ƒWStyD|tur,|YSt|d|›d�ƒd‚Yn\tyž}zDd|›d�|j||urndnd}t||›d|›�ƒ|‚WYd}~n d}~00dS)Nz attribute 'z ' requiredú'z elements:ú:ú )ÚKeyErrorÚ_emptyrr)r+r,r-r.ÚexcÚtargetrrrÚ_get2s "r6)r+r-r.r&cCst|dd„||ƒS)NcSs t|tƒSr)r(Úbool©ÚvrrrÚ?ózget_bool..©r6©r+r-r.rrrÚget_bool>sr>cCst|dd„||ƒS)NcSs t|tƒSr)r(Úintr8rrrr:Cr;zget_int..r<r=rrrÚget_intBsr@cCst|dd„||ƒS)NcSs t|tƒSr©r(r#r8rrrr:Gr;zget_str..r<r=rrrÚget_strFsrBcCst|dd„||ƒS)NcSs|dur dSt|tƒSrrAr8rrrr:Kr;z!get_str_or_none..r<r=rrrÚget_str_or_noneJsrCcCs&ttttfdœdd„}t||||ƒS)N©rr&cSst|ttfƒst|dƒ‚|S)Nzmust be a string or integer)r'r#r?r©rrrrÚ as_str_or_intOs z%get_str_or_int..as_str_or_int)rr r#r?r6)r+r-r.rFrrrÚget_str_or_intNsrGcCst|dd„||ƒS)NcSs t|tƒSr©r(Údictr8rrrr:Xr;zget_dict..r<r=rrrÚget_dictWsrJ)r+r-Ú constructorr.r&cst|‡fdd„||ƒS)Ncsˆt|tƒƒSrrHr8©rKrrr:ar;zget_object..r<)r+r-rKr.rrLrÚ get_object[srMcCs"tttdœdd„}t||||ƒS)NrDcSstdd„t|tƒDƒƒS)Ncss|]}t|tƒVqdSrrA©Ú.0ÚitemrrrÚ fr;z,get_strv..as_strv..©Útupler(ÚlistrErrrÚas_strveszget_strv..as_strv)rr r#r6)r+r-r.rUrrrÚget_strvdsrV)r+r-Úchoicesr.r&cs"ttdœ‡fdd„ }t||||ƒS)NrDcs0t|tƒr|ˆvr|St|d|›dˆ›�ƒ‚dS)Nzinvalid value "z " not in )r'r#rrE©rWrrÚ as_choicemszget_enum..as_choice)rr#r6)r+r-rWr.rYrrXrÚget_enumjsrZ)r+r-rKr&cs&tttdœ‡fdd„ }t|||dƒS)NrDcst‡fdd„t|tƒDƒƒS)Nc3s|]}ˆt|tƒƒVqdSrrHrNrLrrrQxr;z,get_objv..as_objv..rRrErLrrÚas_objvwszget_objv..as_objvr)rr rr6)r+r-rKr[rrLrÚget_objvvsr\zJsonObject | None)ÚmessageÚkwargsr&cCs6t|piƒ}| ¡D]\}}| dd¡}|||<q|S)a»Constructs a JSON object based on message and kwargs. If only message is given, it is returned, unmodified. If message is None, it is equivalent to an empty dictionary. A copy is always made. If kwargs are present, then any underscore ('_') present in a key name is rewritten to a dash ('-'). This is intended to bridge between the required Python syntax when providing kwargs and idiomatic JSON (which uses '-' for attributes). These values override values in message. The idea is that `message` should be used for passing data along, and kwargs used for data originating at a given call site, possibly including modifications to an original message. Ú_ú-)rIÚitemsÚreplace)r]r^Úresultr-rZjson_keyrrrÚ create_object|s    rd)ÚcurrentÚpatchr&cCspt|ƒ}| ¡D]Z\}}t|tƒrL| |d¡}t|tƒsr?r@rBrCrGrJrMrVrZr\rdrhrlrrrrÚsL 0   0 (((, (ü   û ,ÿ þ *