Best Python code snippet using lisa_python
import_students.py
Source:import_students.py
...40 existing_student = student.find_by_registration_id(matricule)41 if existing_student:42 internship_student_information = mdl_isi.find_by_person(existing_student.person, cohort).first()43 if internship_student_information:44 student_information_diff = _update_information(internship_student_information, cohort, row)45 if(student_information_diff):46 diff.append(student_information_diff)47 else:48 student_information = mdl_isi.InternshipStudentInformation()49 student_information.person = existing_student.person50 _update_information(student_information, cohort, row)51 diff.append({52 "data": student_information,53 "new_record": True,54 })55def _update_information(information, cohort, row):56 old_data = copy(information)57 information.location = row[15].value58 information.postal_code = str(row[16].value)59 information.city = row[17].value60 information.country = row[18].value61 information.email = row[19].value62 information.phone_mobile = str(row[14].value)63 information.cohort = cohort64 return _get_data_differences(old_data, information)65def _get_data_differences(old, new):66 old.cohort = new.cohort67 new_set = set(new.__dict__.items()) - set(old.__dict__.items())68 data_diff = {69 "data": new,...
pager.py
Source:pager.py
...6 page = 17 self._filter = self._make_filter(cls, *args, **kwargs)8 self.count = self._get_count()9 self.data = self._get_data(page)10 self._update_information(page)11 def _make_filter(self, cls, *args, **kwargs):12 def _filter():13 return cls.objects.filter(*args, **kwargs)14 return _filter15 def _get_count(self):16 return self._filter().count()17 def _get_data(self, page):18 start = (page - 1) * self.page_length19 end = page * self.page_length20 return self._filter()[start:end]21 def _update_information(self, page):22 max_page = self.count / self.page_length23 if self.count % self.page_length:24 max_page += 125 self.current_page = page26 self.prev_page = page - 127 self.next_page = page + 1 if page < max_page else 028 self.max_page = max_page29 def get_dict(self, page):30 self._update_information(page)31 return {32 "data": self._get_data(page),33 "current_page": self.current_page,34 "prev_page": self.prev_page,35 "next_page": self.next_page,36 "max_page": self.max_page,37 }38class PagerMixin(models.Model):39 """40 pageræ©è½ã追å ãã41 """42 class Meta:43 abstract = True44 @classmethod...
variableController.py
Source:variableController.py
...5 view: VariableUI6 def __init__(self, variable: Variable):7 self.variable = variable8 self.view = VariableUI()9 self._update_information()10 self.show_window()11 def _update_information(self):12 self.view.info_boxes['UID'].setText(self.variable.uid)13 self.view.info_boxes['parameter_UID'].setText(self.variable.parameter_uid)14 self.view.input_boxes['nominal'].setValue(self.variable.nominal_value)15 self.view.input_boxes['minimum'].setValue(self.variable.minimal_value)16 self.view.input_boxes['maximum'].setValue(self.variable.maximal_value)17 def show_window(self):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!