MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python2.7/site-packages/leapp/models/__init__.pyo
�
g��fc@s'dZddlZddlmZddlmZddlmZddlm	Z	ddl
mZmZm
Z
ddlmZmZd	efd
��YZdee�fd��YZd
efd��YZdefd��YZd�Zdefd��YZd�Zd�Zd�Ze�dS(sy Leapp Models

These packages provide an interface describing a message payload data structure in the form of Models.
Together with the :py:mod:`leapp.models.fields`, package models are defined.

Example::

    class Boom(Model):
        topic = SomeTopic
        reason = fields.String()

    class Foobar(Model):
        topic = SomeTopic
        baz = fields.List(fields.String(), default=[])
        boom = fields.Model(Boom)

Now, the models can be used like this::

    f = Foobar(boom=Boom())
    f.boom.reason = "Example"
    f.baz.append("Add a string value to the list")
    from pprint import pprint
    pprint(f.dump())

i����N(tModelDefinitionError(tfields(t
ErrorSeverity(tModelMisuseError(tDialogTopict
ErrorTopictTopic(tget_flattened_subclassestwith_metaclasst	ModelMetacBs eZdZd�Zd�ZRS(s�
    ModelMeta is a metaclass used for Model

    It verifies the validity of attributes and registers the model as a message type with the :py:class:`Topic`.
    c
	Cs�tt|�j||||�}xD|D]<}t|dt�r(tdjd|d|j���q(q(Wt�j	d�}|dks�|r�t
||�r�ttj
|j||�|St�j	d�}|rCt
||�rCt|dd�}|s	t
|t�r!tdj|���ntt|j|f��|_nt|d	d�pXij�}	|	jd
�|j�D��|	j�|_ttj
|j||�|S(Nt__non_inheritable__sB{cls} cannot inherit from {base} because {base} is not inheritabletclstbaset_ModelReferencetModelttopicsMissing topic in Model {}RcSs1i|]'\}}t|tj�r||�qS((t
isinstanceRtField(t.0tnametvalue((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pys
<dictcomp>?s	(tsuperR	t__new__tgetattrtFalset	TypeErrortformatt__name__tglobalstgett
issubclasstsetattrtsystmodulest
__module__tNoneRRttupletsettmessagestcopytupdatetitemsR(
tmcsRtbasestattrstklassRt
model_ref_clst	model_clsRt	kls_attrs((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyR*s(!
!"cCs tt|�j|||�dS(N(RR	t__init__(RRR+R,((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyR1Es(RR"t__doc__RR1(((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyR	$s	RcBsVeZdZdd�ZdZdZed��Zd�Z	d�Z
ed��ZRS(s�
    Model is a base class for all models.

    Models are defining the data structure of the payload of messages and the
    metadata required, such as a name and topic.
    tfrom_initializationcKs�tt|�j�t|�jp%i}x>|D]6}||kr/tdjt|�j|���q/q/Wx+|D]#}t|||�|||�qpWdS(Ns?Trying to initialize model {} with value for undefined field {}(	RRR1ttypeRRRRR(tselftinit_methodtkwargstdefined_fieldstkeytfield((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyR1Rs
%
cCs|dd|�S(s�
        Create an instance of this class and use the data to initialize the fields within.

        :param data: Data to initialize the Model from deserialized data
        :type data: dict
        :return: Instance of this class
        R6tto_model((Rtdata((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pytcreateis	cCsJi}x=t|�jj�D]&}t|�j|j|||�qW|S(s�
        Dumps the data in the dictionary form that is safe to serialize to JSON.

        :return: dict with a builtin representation of the data that can be safely serialized to JSON
        (R4Rtkeyst
to_builtin(R5tresultR:((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pytdumpts$csGt�t���oFt��fd�tt��jj��D��S(sK
        Implementation for equality comparison of Model instances
        c3s-|]#}t�|�t�|�kVqdS(N(R(RR(totherR5(s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pys	<genexpr>�s(RR4talltsortedRR>(R5RB((RBR5s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyt__eq__scCs5i|jd6d�|jj�D�d6|jjd6S(s& Returns serialized data of the model t
class_namecSs%i|]\}}|j�|�qS((t	serialize(RRR:((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pys
<dictcomp>�s	RR(RRR)R(R((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyRG�s
N(RR"R2R1R#RRtclassmethodR=RARERG(((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyRIs
		t
ErrorModelcBseeZeZej�Zejdej	dej
�Zejej��Z
ej�Zej�ZRS(tchoicestdefault(RR"RRRtStringtmessaget
StringEnumRtALLOWED_VALUEStERRORtseveritytNullabletdetailstactortDateTimettime(((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyRI�stDialogModelcBsPeZeZej�Zej�Zej	ej��Z
ej	ej��ZRS((RR"RRRtJSONtanswerfile_sectionsRLRTRRRSR9(((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyRW�s
cCs2gtt�D]!}|t|t�k	r
|^q
S(sh
    Returns a list of all currently loaded subclasses of Model

    :return: List Model subclasses
    (RRRR
(tmodel((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyt
get_models�sR
cBs;eZdZdZd�Zed��Zed��ZRS(cOs|j�||�S(N(tresolve(RtargsR7((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyR�scCs|j�dd|�S(NR6R;(R\(RR<((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyR=�scCsV|jsOyt�|j|_WqOtk
rKtdj|j���qOXn|jS(NsUndefined Model "{}"(t	_resolvedRt_referencedtKeyErrorRR(R((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyR\�s	
N(	RR"R#R_R^RRHR=R\(((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyR
�s
	cCs%xtt�D]}|j�q
WdS(s
    Resolves all dynamically created model references. When importing a model that has not been loaded
    yet, a dynamic model reference is created. After loading all models, resolve_model_references
    must be called to ensure the consistency of the code.

    :return: None
    N(RR
R\(t	reference((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pytresolve_model_references�scCs&t|dtfi�}||_|S(Nt	Reference(R4R
R_(RRa((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyt_module_ref�s	cCs4dtfd��Y}|tjt�tjt<dS(Nt
ReferenceDictcBs,eZd�Zd�Zd�Zd�ZRS(cSs||jd<dS(Nt_module(t__dict__(R5tmodule((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyR1�scSst|j||�dS(N(RRf(R5RR((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyt__setattr__�scSst|j|�dS(N(tdelattrRf(R5R((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyt__delattr__�scSs>|jd�rt|j|�St|j|d�p=t|�S(Nt_(t
startswithRRfR#Rd(R5titem((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyt__getattr__�s(RR"R1RiRkRo(((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyRe�s			(tobjectR R!R(Re((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyt_patch_module_getitem�s(R2R tleapp.exceptionsRtleapp.modelsRtleapp.models.error_severityRtleapp.models.fieldsRtleapp.topicsRRRtleapp.utils.metaRRR4R	RRIRWR[R
RbRdRq(((s9/usr/lib/python2.7/site-packages/leapp/models/__init__.pyt<module>s"%G