Best Python code snippet using pandera_python
test_io.py
Source:test_io.py
...537 """Schema with a global check"""538 a: pat.Series[pat.Int64]539 b: pat.Series[pat.Int64]540 @pandera.dataframe_check()541 def unregistered_check(self, _):542 """sample unregistered check"""543 ...544 with pytest.warns(UserWarning, match=".*registered checks.*"):545 CheckedSchemaModel.to_yaml()546def test_serialize_deserialize_custom_datetime_checks():547 """548 Test that custom checks for datetime columns can be serialized and549 deserialized550 """551 # pylint: disable=unused-variable,unused-argument552 @pandera.extensions.register_check_method(statistics=["stat"])553 def datetime_check(pandas_obj, *, stat):554 ...555 schema = pandera.DataFrameSchema(...
register.py
Source:register.py
1# -*- coding: utf-8 -*-2# Form implementation generated from reading ui file 'register.ui'3#4# Created by: PyQt5 UI code generator 5.13.25#6# WARNING! All changes made in this file will be lost!7from PyQt5 import QtCore, QtGui, QtWidgets8class Ui_MainWindow(object):9 def setupUi(self, MainWindow):10 MainWindow.setObjectName("MainWindow")11 MainWindow.resize(737, 439)12 self.centralwidget = QtWidgets.QWidget(MainWindow)13 self.centralwidget.setObjectName("centralwidget")14 self.btn_newuser = QtWidgets.QPushButton(self.centralwidget)15 self.btn_newuser.setGeometry(QtCore.QRect(10, 110, 121, 31))16 self.btn_newuser.setLayoutDirection(QtCore.Qt.LeftToRight)17 self.btn_newuser.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";\n"18"border-color: rgb(45, 45, 185);\n"19"background-color: rgb(191, 191, 191);")20 self.btn_newuser.setObjectName("btn_newuser")21 self.btn_login = QtWidgets.QPushButton(self.centralwidget)22 self.btn_login.setGeometry(QtCore.QRect(10, 170, 121, 31))23 self.btn_login.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";\n"24"border-color: rgb(45, 45, 185);\n"25"background-color: rgb(191, 191, 191);")26 self.btn_login.setObjectName("btn_login")27 self.l_id = QtWidgets.QLabel(self.centralwidget)28 self.l_id.setGeometry(QtCore.QRect(170, 90, 71, 16))29 self.l_id.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")30 self.l_id.setObjectName("l_id")31 self.l_pw = QtWidgets.QLabel(self.centralwidget)32 self.l_pw.setGeometry(QtCore.QRect(170, 130, 56, 12))33 self.l_pw.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")34 self.l_pw.setObjectName("l_pw")35 self.l_city = QtWidgets.QLabel(self.centralwidget)36 self.l_city.setGeometry(QtCore.QRect(170, 170, 56, 12))37 self.l_city.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")38 self.l_city.setObjectName("l_city")39 self.l_code = QtWidgets.QLabel(self.centralwidget)40 self.l_code.setGeometry(QtCore.QRect(170, 210, 56, 12))41 self.l_code.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")42 self.l_code.setObjectName("l_code")43 self.l_mail = QtWidgets.QLabel(self.centralwidget)44 self.l_mail.setGeometry(QtCore.QRect(170, 250, 56, 12))45 self.l_mail.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")46 self.l_mail.setObjectName("l_mail")47 self.l_mobile = QtWidgets.QLabel(self.centralwidget)48 self.l_mobile.setGeometry(QtCore.QRect(170, 290, 61, 16))49 self.l_mobile.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")50 self.l_mobile.setObjectName("l_mobile")51 self.t_loginid = QtWidgets.QLineEdit(self.centralwidget)52 self.t_loginid.setGeometry(QtCore.QRect(240, 90, 113, 20))53 self.t_loginid.setObjectName("t_loginid")54 self.t_password = QtWidgets.QLineEdit(self.centralwidget)55 self.t_password.setGeometry(QtCore.QRect(240, 130, 113, 20))56 self.t_password.setObjectName("t_password")57 self.t_city = QtWidgets.QLineEdit(self.centralwidget)58 self.t_city.setGeometry(QtCore.QRect(240, 170, 113, 20))59 self.t_city.setObjectName("t_city")60 self.t_pocode = QtWidgets.QLineEdit(self.centralwidget)61 self.t_pocode.setGeometry(QtCore.QRect(240, 210, 113, 20))62 self.t_pocode.setObjectName("t_pocode")63 self.t_email = QtWidgets.QLineEdit(self.centralwidget)64 self.t_email.setGeometry(QtCore.QRect(240, 250, 113, 20))65 self.t_email.setObjectName("t_email")66 self.t_mobileno = QtWidgets.QLineEdit(self.centralwidget)67 self.t_mobileno.setGeometry(QtCore.QRect(240, 290, 113, 20))68 self.t_mobileno.setObjectName("t_mobileno")69 self.Employee_check = QtWidgets.QCheckBox(self.centralwidget)70 self.Employee_check.setGeometry(QtCore.QRect(390, 90, 81, 16))71 self.Employee_check.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")72 self.Employee_check.setObjectName("Employee_check")73 self.TeamLeader_check = QtWidgets.QCheckBox(self.centralwidget)74 self.TeamLeader_check.setGeometry(QtCore.QRect(390, 120, 101, 16))75 self.TeamLeader_check.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")76 self.TeamLeader_check.setObjectName("TeamLeader_check")77 self.Projectmanager_check = QtWidgets.QCheckBox(self.centralwidget)78 self.Projectmanager_check.setGeometry(QtCore.QRect(390, 150, 121, 16))79 self.Projectmanager_check.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")80 self.Projectmanager_check.setObjectName("Projectmanager_check")81 self.AsstProjectManager_check = QtWidgets.QCheckBox(self.centralwidget)82 self.AsstProjectManager_check.setGeometry(QtCore.QRect(390, 180, 141, 16))83 self.AsstProjectManager_check.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")84 self.AsstProjectManager_check.setObjectName("AsstProjectManager_check")85 self.Manager_check = QtWidgets.QCheckBox(self.centralwidget)86 self.Manager_check.setGeometry(QtCore.QRect(390, 210, 81, 16))87 self.Manager_check.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")88 self.Manager_check.setObjectName("Manager_check")89 self.Admin_check = QtWidgets.QCheckBox(self.centralwidget)90 self.Admin_check.setGeometry(QtCore.QRect(390, 240, 81, 16))91 self.Admin_check.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")92 self.Admin_check.setObjectName("Admin_check")93 self.NonEmployee_check = QtWidgets.QCheckBox(self.centralwidget)94 self.NonEmployee_check.setGeometry(QtCore.QRect(550, 90, 121, 16))95 self.NonEmployee_check.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")96 self.NonEmployee_check.setObjectName("NonEmployee_check")97 self.Unregistered_check = QtWidgets.QCheckBox(self.centralwidget)98 self.Unregistered_check.setGeometry(QtCore.QRect(550, 120, 101, 16))99 self.Unregistered_check.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")100 self.Unregistered_check.setObjectName("Unregistered_check")101 self.Registered_check = QtWidgets.QCheckBox(self.centralwidget)102 self.Registered_check.setGeometry(QtCore.QRect(550, 150, 81, 16))103 self.Registered_check.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")104 self.Registered_check.setObjectName("Registered_check")105 self.Student_check = QtWidgets.QCheckBox(self.centralwidget)106 self.Student_check.setGeometry(QtCore.QRect(550, 180, 81, 16))107 self.Student_check.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")108 self.Student_check.setObjectName("Student_check")109 self.Trainee_check = QtWidgets.QCheckBox(self.centralwidget)110 self.Trainee_check.setGeometry(QtCore.QRect(550, 210, 81, 16))111 self.Trainee_check.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")112 self.Trainee_check.setObjectName("Trainee_check")113 self.checkBox_12 = QtWidgets.QCheckBox(self.centralwidget)114 self.checkBox_12.setGeometry(QtCore.QRect(550, 240, 81, 16))115 self.checkBox_12.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";")116 self.checkBox_12.setObjectName("checkBox_12")117 self.btn_register = QtWidgets.QPushButton(self.centralwidget)118 self.btn_register.setGeometry(QtCore.QRect(440, 330, 131, 31))119 self.btn_register.setStyleSheet("font: 75 9pt \"ëëëª
ì¡° ExtraBold\";\n"120"border-color: rgb(45, 45, 185);\n"121"background-color: rgb(191, 191, 191);")122 self.btn_register.setCheckable(False)123 self.btn_register.setObjectName("btn_register")124 MainWindow.setCentralWidget(self.centralwidget)125 self.statusbar = QtWidgets.QStatusBar(MainWindow)126 self.statusbar.setObjectName("statusbar")127 MainWindow.setStatusBar(self.statusbar)128 self.retranslateUi(MainWindow)129 QtCore.QMetaObject.connectSlotsByName(MainWindow)130 def retranslateUi(self, MainWindow):131 _translate = QtCore.QCoreApplication.translate132 MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))133 self.btn_newuser.setText(_translate("MainWindow", "New User"))134 self.btn_login.setText(_translate("MainWindow", "Login"))135 self.l_id.setText(_translate("MainWindow", "Login ID"))136 self.l_pw.setText(_translate("MainWindow", "Password"))137 self.l_city.setText(_translate("MainWindow", "City"))138 self.l_code.setText(_translate("MainWindow", "POCode"))139 self.l_mail.setText(_translate("MainWindow", "Email"))140 self.l_mobile.setText(_translate("MainWindow", "Mobile No"))141 self.Employee_check.setText(_translate("MainWindow", "Employee"))142 self.TeamLeader_check.setText(_translate("MainWindow", "Team Leader"))143 self.Projectmanager_check.setText(_translate("MainWindow", "Project Manager"))144 self.AsstProjectManager_check.setText(_translate("MainWindow", "AsstProject Manager"))145 self.Manager_check.setText(_translate("MainWindow", "Manager"))146 self.Admin_check.setText(_translate("MainWindow", "Admin"))147 self.NonEmployee_check.setText(_translate("MainWindow", "Non-Employee"))148 self.Unregistered_check.setText(_translate("MainWindow", "Unregistered"))149 self.Registered_check.setText(_translate("MainWindow", "Registered"))150 self.Student_check.setText(_translate("MainWindow", "Student"))151 self.Trainee_check.setText(_translate("MainWindow", "Trainee"))152 self.checkBox_12.setText(_translate("MainWindow", "HR"))153 self.btn_register.setText(_translate("MainWindow", "Register"))154if __name__ == "__main__":155 import sys156 app = QtWidgets.QApplication(sys.argv)157 MainWindow = QtWidgets.QMainWindow()158 ui = Ui_MainWindow()159 ui.setupUi(MainWindow)160 MainWindow.show()...
individualtemplate.py
Source:individualtemplate.py
1# -*- coding: utf-8 -*-2# vi:si:et:sw=4:sts=4:ts=43##4## Copyright (C) 2005-2007 Async Open Source <http://www.async.com.br>5## All rights reserved6##7## This program is free software; you can redistribute it and/or modify8## it under the terms of the GNU Lesser General Public License as published by9## the Free Software Foundation; either version 2 of the License, or10## (at your option) any later version.11##12## This program is distributed in the hope that it will be useful,13## but WITHOUT ANY WARRANTY; without even the implied warranty of14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15## GNU Lesser General Public License for more details.16##17## You should have received a copy of the GNU Lesser General Public License18## along with this program; if not, write to the Free Software19## Foundation, Inc., or visit: http://www.gnu.org/.20##21## Author(s): Stoq Team <stoq-devel@async.com.br>22##23""" Individual edition template slaves implementation. """24from kiwi.datatypes import ValidationError25from kiwi.python import AttributeForwarder26from kiwi.utils import gsignal27from stoqlib.api import api28from stoqlib.domain.address import CityLocation29from stoqlib.domain.person import Individual, IndividualView30from stoq.lib.gui.editors.baseeditor import BaseEditorSlave31from stoq.lib.gui.slaves.addressslave import CityLocationMixin32from stoqlib.lib.dateutils import localtoday33from stoqlib.lib.translation import stoqlib_gettext34from stoq.lib.gui.utils.databaseform import DatabaseForm35_ = stoqlib_gettext36class _IndividualDocuments(BaseEditorSlave):37 model_type = Individual38 gladefile = 'IndividualDocuments'39 proxy_widgets = ('cpf',40 'rg_expedition_date',41 'rg_expedition_local',42 'rg_number',43 'state_registry',44 'city_registry')45 def __init__(self, store, model, visual_mode=None, ui_form_name=None):46 self.db_form = DatabaseForm(ui_form_name) if ui_form_name else None47 BaseEditorSlave.__init__(self, store, model, visual_mode=visual_mode)48 def _setup_widgets(self):49 self.document_l10n = api.get_l10n_field('person_document')50 self.cpf_lbl.set_label(self.document_l10n.label + ':')51 self.cpf.set_mask(self.document_l10n.entry_mask)52 def _setup_form_fields(self):53 if not self.db_form:54 return55 # Do not update the widget if the model already has a responsible56 if self.model.responsible:57 return58 self.db_form.update_widget(self.cpf, other=self.cpf_lbl)59 def setup_proxies(self):60 self._setup_widgets()61 self._setup_form_fields()62 self.proxy = self.add_proxy(self.model,63 _IndividualDocuments.proxy_widgets)64 def on_cpf__validate(self, widget, value):65 # This will allow the user to use an empty value to this field66 if self.cpf.is_empty():67 return68 if not self.document_l10n.validate(value):69 return ValidationError(_('%s is not valid.') % (70 self.document_l10n.label,))71 if self.model.check_cpf_exists(value):72 return ValidationError(_('A person with this %s already exists') % (73 self.document_l10n.label,))74class _IndividualDetailsModel(AttributeForwarder):75 attributes = [76 'birth_date',77 'mother_name',78 'father_name',79 'occupation',80 'spouse_name',81 'marital_status',82 'get_marital_statuses',83 'birth_location',84 'gender',85 'responsible',86 ]87 def __init__(self, target, store, ui_form_name=None):88 """89 :param target: an Individial90 :param store: a store91 """92 # Even though we dont use ui_form_name anywhere in this class, its setup93 # is made in a way we need this argument. see persontemplate94 # attach_model_slave method95 AttributeForwarder.__init__(self, target)96 self.store = store97 if not target.birth_location:98 target.birth_location = CityLocation.get_default(store)99 self.city = target.birth_location.city100 self.state = target.birth_location.state101 self.country = target.birth_location.country102 def is_married(self):103 return self.target.marital_statuses == Individual.STATUS_MARRIED104 def is_male(self):105 return self.target.gender == Individual.GENDER_MALE106 def is_female(self):107 return self.target.gender == Individual.GENDER_FEMALE108 def is_none(self):109 return self.target.gender is None110 def birth_location_changed(self):111 return (self.city != self.target.birth_location.city or112 self.state != self.target.birth_location.state or113 self.country != self.target.birth_location.country)114 def ensure_birth_location(self):115 changed = self.birth_location_changed()116 if changed:117 self.target.birth_location = CityLocation.get_or_create(118 city=self.city,119 state=self.state,120 country=self.country,121 store=self.store)122class _IndividualDetailsSlave(BaseEditorSlave, CityLocationMixin):123 model_type = _IndividualDetailsModel124 gladefile = 'IndividualDetailsSlave'125 proxy_widgets = [126 'birth_date',127 'mother_name',128 'father_name',129 'occupation',130 'spouse_name',131 'marital_status',132 'city',133 'country',134 'state',135 'responsible',136 ]137 gsignal('responsible-changed', object)138 def __init__(self, store, model, visual_mode=False, ui_form_name=None):139 # Even though we dont use ui_form_name anywhere in this class, its setup140 # is made in a way we need this argument. see persontemplate141 # attach_model_slave method142 BaseEditorSlave.__init__(self, store, model, visual_mode=visual_mode)143 def _setup_widgets(self):144 from stoq.lib.gui.widgets.queryentry import IndividualEntryGadget145 self.unregistered_check.set_active(self.model.is_none())146 self.male_check.set_active(self.model.is_male())147 self.female_check.set_active(self.model.is_female())148 self.marital_status.prefill(self.model.get_marital_statuses())149 self.person_gadget = IndividualEntryGadget(150 store=self.store,151 entry=self.responsible,152 initial_value=self.model.responsible,153 search_clause=IndividualView.id != self.model.target.id154 )155 def _update_marital_status(self):156 if self.marital_status.read() == Individual.STATUS_MARRIED:157 self.spouse_lbl.show()158 self.spouse_name.show()159 else:160 self.spouse_lbl.hide()161 self.spouse_name.hide()162 #163 # BaseEditorSlave hooks164 #165 def setup_proxies(self):166 CityLocationMixin.setup_proxies(self)167 self._setup_widgets()168 self.proxy = self.add_proxy(self.model,169 _IndividualDetailsSlave.proxy_widgets)170 self._update_marital_status()171 def validate_confirm(self):172 return CityLocationMixin.validate_confirm(self)173 def update_visual_mode(self):174 self.male_check.set_sensitive(False)175 self.female_check.set_sensitive(False)176 def on_confirm(self):177 if self.unregistered_check.get_active():178 self.model.gender = None179 elif self.male_check.get_active():180 self.model.gender = Individual.GENDER_MALE181 else:182 self.model.gender = Individual.GENDER_FEMALE183 self.model.ensure_birth_location()184 #185 # Callbacks186 #187 def on_marital_status__changed(self, *args):188 self._update_marital_status()189 def on_birth_date__validate(self, widget, date):190 if date > localtoday().date():191 return ValidationError(_(u"Birth date must be less than today"))192 def after_responsible__content_changed(self, *args):193 self.emit('responsible-changed', self.responsible.read())194class IndividualEditorTemplate(BaseEditorSlave):195 model_type = Individual196 gladefile = 'BaseTemplate'197 def __init__(self, store, model=None, person_slave=None,198 visual_mode=False, ui_form_name=None):199 """ Creates a new IndividualEditorTemplate object200 :param store: a store201 :param model: model202 :param person_slave: the person slave203 :param visual_model:204 """205 self._person_slave = person_slave206 self.ui_form_name = ui_form_name207 BaseEditorSlave.__init__(self, store, model, visual_mode=visual_mode)208 def get_person_slave(self):209 return self._person_slave210 def attach_person_slave(self, slave):211 self._person_slave.attach_slave('person_status_holder', slave)212 #213 # BaseEditorSlave hooks214 #215 def setup_slaves(self):216 self.model = self.store.fetch(self.model)217 self.documents_slave = self._person_slave.attach_model_slave(218 'individual_holder', _IndividualDocuments, self.model,219 self.ui_form_name)220 self.details_slave = self._person_slave.attach_model_slave(221 'details_holder', _IndividualDetailsSlave,222 _IndividualDetailsModel(self.model, self.store))223 def on_details_slave__responsible_changed(self, *args):224 has_responsible = bool(self.details_slave.responsible.read())...
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!!