| Server IP : 104.21.25.180 / Your IP : 162.159.115.42 Web Server : Apache/2.4.37 System : Linux almalinux.duckdns.org 4.18.0-553.111.1.el8_10.x86_64 #1 SMP Sun Mar 8 20:06:07 EDT 2026 x86_64 User : ricodeal ( 1046) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /lib/python2.7/site-packages/leapp/models/ |
Upload File : |
from leapp.models.fields import ModelMisuseError
def init_from_tuple(model_class, field_names, data):
"""
Create an instance of the given model class and use the data to initialize the fields with it.
:param model_class: Model class to initialize with the given data
:param field_names: Names of the fields to be mapped from the tuple
:param data: Data to initialize the Model from
:type data: dict
:return: Instance of this class
"""
if len(field_names) != len(data):
raise ModelMisuseError(
'Number of field names do not match number of tuple elements while initializing ' + model_class.__name__)
return model_class(**dict(zip(field_names, data)))