import npyscreen class financial_data_model(): def __init__(self, financial_data_dict): self.financial_data_dict = financial_data_dict self.forms = {} def add_edit_fields(self, form): fin = self.financial_data_dict self.forms['iban'] = form.add(npyscreen.TitleText, name="IBAN: ", value=fin['iban']) self.forms['bic'] = form.add(npyscreen.TitleText, name="BIC: ", value=fin['bic']) self.forms['holder'] = form.add(npyscreen.TitleText, use_two_lines=False, name="Kontoinhaber: ", value=fin['holder']) self.forms['issuance'] = form.add(npyscreen.TitleText, begin_entry_at=38, use_two_lines=False, name="Tag der Erteilung Lastschriftmandat: ", value=fin['issuance']) self.forms['reference'] = form.add(npyscreen.TitleText, begin_entry_at=24, use_two_lines=False, name="Mandatsreferenznummer: ", value=fin['reference']) self.forms['scan-sepa-mandate'] = form.add(npyscreen.TitleText, begin_entry_at=24, use_two_lines=False, name="URI Scan SEPA-Mandat: ", value=fin['scan-sepa-mandate']) def get_form_values_dict(self): financial_data_model = dict(zip(self.forms.keys(), map(lambda f: f.value, self.forms.values()))) return financial_data_model def has_changed(self): return self.financial_data_dict != self.get_form_values_dict()