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/fields/__init__.pyo
�
9�Egc@sEddlZddlZddlZddlZyddlmZWn!ek
rgddlmZnXddlZde	fd��YZ
de	fd��YZdefd��YZ
d	e
fd
��YZdefd��YZd
efd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZde
fd��YZd�Zdeefd��YZdeefd��YZd eefd!��YZd"eefd#��YZd$e
fd%��YZd&e
fd'��YZd(e
fd)��YZd*efd+��YZdS(,i����N(tSequencetModelViolationErrorcBseZdZRS(sd
    ModelViolationError is raised if the data in the instances is not matching its definition.
    (t__name__t
__module__t__doc__(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRstModelMisuseErrorcBseZdZRS(sJ
    ModelMisuseError is raised if the Model definition is not valid.
    (RRR(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRstFieldcBs}eZdZed��Zd�Zddd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�ZRS(
s4
    Field is the base of all supported fields.
    cCs|jpdjt|�j�S(sV
        :return: Documentation help string defining what the field is about.
        s-No documentation provided for this field `{}`(t_helptformatttypeR(tself((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pythelpscCs
t|_|S(sS
        Set object` "_nullable_" field to True and return the object back
        (tTruet	_nullable(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pytas_nullable&s	cCs@||_t|_||_t|�tkr<td��ndS(s�
        :param default: Default value to be used if the field is not set
        :param help: Documentation string for generating model documentation
        :type help: str
        sDo not use this type directly.N(RtFalseR
t_defaultR	RR(R
tdefaultR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt__init__-s
			cCs5|dkr1|jr1tdjd|���ndS(s�
        Validates the value in the Model representation

        :param value: Value to be checked
        :param name: Name of the field (used for a better error reporting only)
        :return: None
        s<The value of "{name}" field is None, but this is not allowedtnameN(tNoneR
RR(R
tvalueR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt_validate_model_value:scCs5|dkr1|jr1tdjd|���ndS(s�
        Validates the value in the builtin representation

        :param value: Value to be checked
        :param name: Name of the field (used for a better error reporting only)
        :return: None
        s<The value of "{name}" field is None, but this is not allowedRN(RR
RR(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt_validate_builtin_valueEscCs|jd|d|�|S(s
        Performs the conversion from a builtin type to the model representation

        :param value: Value to convert
        :param name: Name of the field (used for a better error reporting only)
        :return: Converted value in the model format
        RR(R(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt_convert_to_modelPscCs|jd|d|�|S(s
        Performs the conversion from a model type to the builtin representation

        :param value: Value to convert
        :param name: Name of the field (used for a better error reporting only)
        :return: Converted value in the builtin format
        RR(R(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt_convert_from_model[scCsHtj|j||j��}|jd|d|�t|||�dS(s�
        Assigns the value to the target model passed through during the model initialization

        :param source: Dictionary to extract the value from (usually kwargs)
        :type source: dict
        :param name: Name of the field (used for a better error reporting only)
        :type name: str
        :param target: Target model instance
        :type target: Instance of a Model derived class
        :return: None
        RRN(tcopytgetRRtsetattr(R
tsourceRttargettsource_value((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pytfrom_initializationfscCsltj|j||j��}|dk	rB|j|d|�}n|jd|d|�t|||�dS(s�
        Converts the value with the given name to the model representation and assigns the attribute

        :param source: Dictionary to extract the value from
        :type source: dict
        :param name: Name of the field (used for a better error reporting only)
        :type name: str
        :param target: Target model instance
        :type target: Instance of a Model derived class
        :return: None
        RRN(RRRRRRR(R
RRRR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pytto_modelxs
cCs)|jt||d�d|�||<dS(s�
        Converts the value with the given name to the builtin representation and assigns the field

        :param source: Source model to get the value from
        :type source: Instance of a Model derived class
        :param name: Name of the field (used for a better error reporting only)
        :type name: str
        :param target: Dictionary to set the value to
        :type target: dict
        :return: None
        RN(RtgetattrR(R
RRR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt
to_builtin�scCs2i|jd6t|�jd6|jd6|jd6S(s7
        :return: Serialized form of the field
        tnullablet
class_nameRR(R
R	RRR(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt	serialize�s


N(RRRtpropertyRRRRRRRRR R!R#R&(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRs	
							tBuiltinFieldcBsGeZdZed��Zed��Zd�Zd�Zd�ZRS(s_
    Base class for all builtin types to act as pass-through with an additional validation
    cCstd��dS(sU
        :return: Returns the type to be used as a model type representation
        s"_model_type needs to be overriddenN(tNotImplementedError(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt_model_type�scCs|jS(se
        :return: Returns the type to be used as a builtin type representation (e.g. string)
        (R*(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt
_builtin_type�scCs<tt|�j||�|jd|d|d|j�dS(NRRt
expected_type(tsuperR(Rt	_validateR*(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�scCs<tt|�j||�|jd|d|d|j�dS(NRRR,(R-R(RR.R+(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�scCs�t|t�s|f}n|dkr4|jr4dSt||�s�djg|D]}dj|j�^qP�}tdj|t|�j|���ndS(Ns, s{}s%Fields {} is of type: {} expected: {}(	t
isinstanceRRR
tjoinRRRR	(R
RRR,tttnames((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR.�s.(	RRRR'R*R+RRR.(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR(�s		tBooleancBseZdZed��ZRS(s
    Boolean field
    cCstS(N(tbool(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR*�s(RRRR'R*(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR3�stFloatcBseZdZed��ZRS(s
    Float field
    cCstS(N(tfloat(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR*�s(RRRR'R*(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR5�stIntegercBseZdZed��ZRS(s@
    Integer field (int, long in python 2, int in python 3)
    cCstjS(N(tsixt
integer_types(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR*�s(RRRR'R*(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR7�stNumbercBseZdZed��ZRS(s*
    Combined Integer and Float field
    cCstjtfS(N(R8R9R6(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR*�s(RRRR'R*(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR:�stStringcBseZdZed��ZRS(s
    String field
    cCstjtjfS(N(R8tstring_typestbinary_type(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR*�s(RRRR'R*(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR;�stBlobcBs/eZdZed��Zd�Zd�ZRS(s
    Blob field
    cCstjtjfS(N(R8R<R=(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR*�scCs3|jd|d|�|dkr&dStj|�S(NRR(RRtbase64t	b64decode(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRscCs<|jd|d|�|dkr&dStj|�jd�S(NRRtascii(RRR?t	b64encodetdecode(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR
s(RRRR'R*RR(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR>�s	tDateTimecBs>eZdZed��Zed��Zd�Zd�ZRS(st
    DateTime field to handle datetime objects which are converted to the ISO format and parsed back from there
    cCstjS(N(tdatetime(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR*scCstjS(N(R8R<(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR+scCs�|jd|d|�|dkr&|S|jd�}d}d|krPd}ny#tjj|djd|��SWnftk
r�y#tjj|d	jd|��SWq�tk
r�td
jd|d|���q�XnXdS(NRRtZtt.s.%fs%Y-%m-%dT%H:%M:%S{fractions}%Zt	fractionss%Y-%m-%dT%H:%M:%S{fractions}s>The {name} field contains an invalid datetime value: '{value}'(RRtrstripREtstrptimeRt
ValueErrorR(R
RRRI((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR"s	#
#
cCs>|jd|d|�|s |S|j�s:|j�dSdS(NRRRF(Rt	utcoffsett	isoformat(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR:s
(RRRR'R*R+RR(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRDs
	t	EnumMixincBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(sR
    EnumMixin adds the ability to use the field as an Enum type of the field
    cKsGtt|�j|�t|ttf�s:td��n||_dS(s�
        :param choices: List of values that are allowed for this field
        :type choices: List or tuple of allowed values
        s%Choices needs to be a list or a tupleN(R-RORR/ttupletlistRt_choices(R
tchoicestkwargs((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRHscCs-tt|�j||�|j||�dS(N(R-RORt_validate_choices(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRRscCs-tt|�j||�|j||�dS(N(R-RORRU(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRVscCs[|dk	rW||jkrWdjtt|j��}tdjd|d|���ndS(Ns, s5The value of "{name}" field must be one of "{values}"Rtvalues(RRRR0tmaptstrRR(R
RRRV((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRUZscCs0tt|�j�}|ji|jd6�|S(NRS(R-ROR&tupdateRR(R
tresult((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR&`s	(RRRRRRRUR&(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRODs	
			cCs
|j�S(s2
    Helper function to make a field nullable
    (R(t
elem_field((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pytNullablehst
StringEnumcBseZdZRS(s9
    Field that represents an enumeration of Strings
    (RRR(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR]ostIntegerEnumcBseZdZRS(s:
    Field that represents an enumeration of Integers
    (RRR(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR^ust	FloatEnumcBseZdZRS(s8
    Field that represents an enumeration of Floats
    (RRR(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR_{st
NumberEnumcBseZdZRS(s9
    Field that represents an enumeration of Numbers
    (RRR(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR`�stListcBsSeZdZddd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	s:
        List represents lists of `elem_field` values
    cKs�tt|�j|�|jdk	r=tj|j�|_nt|t�s[td��n||_	|pmd|_
||_dS(s
        :param elem_field:
        :type elem: Instance of :py:class:`Field`
        :param minimum: Minimal number of elements
        :type minimum: int or None
        :param maximum: Maximum number of elements
        :type maximum: int or None
        :param default: Default value to use if the field is not set
        :type default: A list of elements with the value type as specified in `elem_field`
        :param help: Documentation string for generating model documentation
        :type help: str
        s;elem_field must be an instance of a type derived from FieldiN(R-RaRRRRR/RRt
_elem_typet_minimumt_maximum(R
R[tminimumtmaximumRT((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�s
	c
Cswd}t|�}|j|ko5|jp/|knsst|jd|d|jd|jpa|d|���ndS(NsbElement count error for field {name} expected between {minimum} and {maximum} elements got {count}RReRftcount(tlenRcRdRR(R
RRtmessageRg((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt_validate_count�s
(cCs�tt|�j||�t|ttf�r�|j||�xot|�D].\}}|jj|ddj	||��qKWn0|dk	r�tdj	t|�j
|���ndS(NRs{}[{}]s)Expected list but got {} for the {} field(R-RaRR/RQRPRjt	enumerateRbRRRR	R(R
RRtidxtentry((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�s)cCs�tt|�j||�t|ttf�r�|j||�xot|�D].\}}|jj|ddj	||��qKWn0|dk	r�tdj	t|�j
|���ndS(NRs{}[{}]s)Expected list but got {} for the {} field(R-RaRR/RQRPRjRkRbRRRR	R(R
RRRlRm((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�s)csU|jd|d��|dkr&|S|jj�t��fd�t|�D��S(NRRc3s3|])\}}�|ddj�|��VqdS(Rs{}[{}]N(R(t.0RlRm(t	converterR(s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pys	<genexpr>�s(RRRbRRQRk(R
RR((RoRs@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�s
csU|jd|d��|dkr&|S|jj�t��fd�t|�D��S(NRRc3s3|])\}}�|ddj�|��VqdS(Rs{}[{}]N(R(RnRlRm(RoR(s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pys	<genexpr>�s(RRRbRRQRk(R
RR((RoRs@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�s
cCsJtt|�j�}|ji|jj�d6|jd6|jd6�|S(NtelementRfRe(R-RaR&RYRbRdRc(R
RZ((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR&�s	
N(RRRRRRjRRRRR&(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRa�s							t	StringMapcBsMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(s>
    Map from strings to instances of a given value type.
    cKshtt|�j|�|jdk	r=tj|j�|_nt|t�s[td��n||_	dS(Ns;value_type must be an instance of a type derived from Field(
R-RqRRRRR/RRt_value_type(R
t
value_typeRT((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�sc	Cs�ttt|�|�}|||�t|t�r�x�|D]w}t|t�szd}t|j|t|�j	���n||}t|j
|�}||ddj||��q;Wn0|dk	r�tdjt|�j	|���ndS(Ns=Expected a key of type `str`, but got a key `{}` of type `{}`Rs{}[{}]s+Expected a dict but got {} for the {} field(R"R-RqR/tdictRXRRR	RRrR(	R
tnew_mapRtvalidation_methodtlist_validator_fntkeyterrRtvalue_validator_fn((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt%_validate_model_value_using_validator�s

$
#cCs|j||d�dS(NR(R{(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�scCs|j||d�dS(NR(R{(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�scsL|jd�d���dkr&�S|jj����fd��D�S(NRRcs5i|]+}��|ddj�|��|�qS(Rs
{0}["{1}"](R(RnRx(RoRR(s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pys
<dictcomp>s	(RRRrR(R
RR((RoRRs@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�s
csL|jd�d���dkr&�S|jj����fd��D�S(NRRcs5i|]+}��|ddj�|��|�qS(Rs
{0}["{1}"](R(RnRx(RoRR(s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pys
<dictcomp>s	(RRRrR(R
RR((RoRRs@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRs
cCs,tt|�j�}|jj�|d<|S(NRs(R-RqR&Rr(R
RZ((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR&s(
RRRRR{RRRRR&(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRq�s								tModelcBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(s5
    Model is used to use other Models as fields
    cKsktt|�j|�ddlm}t|t�sFt||�r^tdj|���n||_	dS(s
        :param model_type: A :py:class:`leapp.model.Model` derived class
        :type model_type: :py:class:`leapp.model.Model` derived class
        :param help: Documentation string for generating the model documentation
        :type help: str
        i����(R|s${} must be a type derived from ModelN(
R-R|Rtleapp.modelsR/R	t
issubclassRRR*(R
t
model_typeRTt	ModelType((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRs
 cCsrtt|�j||�t|jd|j�}|rnt||�rntdj|j|t	|����ndS(Nt	_resolveds:Expected an instance of {} for the {} attribute but got {}(
R-R|RR"R*R/RRRR	(R
RRtresolved_model((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR%s
	cCsWtt|�j||�|rSt|t�rStdj|t|�j���ndS(Ns,Expected a value for the {} field and got {}(	R-R|RR/RtRRR	R(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR,scCs3|j||�|dkr |S|jdd|�S(Ntinit_methodR!(RRR*(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR1scCs*|j||�|dkr |S|j�S(N(RRtdump(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR7scCs3tt|�j�}|ji|jjd6�|S(Ntmodel(R-R|R&RYR*R(R
RZ((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR&=s	(	RRRRRRRRR&(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR|s	
				tJSONcBs/eZdZed��Zd�Zd�ZRS(s�
    The JSON field allows to use json encodable python types as a value.

    The value will be internally encoded to a JSON string and converted back into, whatever the result of json.loads
    is for that value passed.

        Note: The value `None`, however follows the same rules as for all fields and requires the field to be nullable,
              to allow this value. Within nested values such as lists or dicts, a None value is perfectly valid.
    cCstjttttftjS(N(R8R9R6RPRtRQR<(R
((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR*PscCs~|dkr4|js0tdjd|���n|Sytj|dt�SWn,ttfk
rytdj|���nXdS(Ns<The value of "{name}" field is None, but this is not allowedRt	sort_keyss0Expected a json encodable value for the field {}(	RR
RRtjsontdumpsRt	TypeErrorRL(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyRTs	cCs-|j||�|dkr |Stj|�S(N(RRR�tloads(R
RR((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR_s(RRRR'R*RR(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyR�Es		( R?RRER�tcollections.abcRtImportErrortcollectionsR8t	ExceptionRRtobjectRR(R3R5R7R:R;R>RDROR\R]R^R_R`RaRqR|R�(((s@/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.pyt<module>s:
�(					.$	M@1