75 lines
3.1 KiB
Python
Executable file
75 lines
3.1 KiB
Python
Executable file
#!/usr/bin/env python
|
|
# encoding: utf-8
|
|
|
|
import npyscreen
|
|
import json
|
|
from sys import argv
|
|
|
|
|
|
class FormApp(npyscreen.NPSAppManaged):
|
|
def __init__(self, member_struct):
|
|
super().__init__()
|
|
self.member = member_struct
|
|
|
|
def main(self):
|
|
f = npyscreen.Form(name='Edit Member data')
|
|
|
|
sd = self.member['stammdaten']
|
|
sd.fn = f.add(npyscreen.TitleText, name="Name: ", value=sd['fullname'])
|
|
sd.nick = f.add(npyscreen.TitleText, name="Nickname: ",
|
|
value=sd['nickname'])
|
|
sd.add.street = f.add(
|
|
npyscreen.TitleText, name="Adresse - Straße: ", value=sd['address']['street'])
|
|
sd.add.loc = f.add(
|
|
npyscreen.TitleText, name="Adresse - Stadt: ", value=sd['address']['locality'])
|
|
sd.add.code = f.add(npyscreen.TitleText,
|
|
name="Adresse - PLZ: ", value=sd['address']['code'])
|
|
sd.add.country = f.add(
|
|
npyscreen.TitleText, name="Adresse - Land: ", value=sd['address']['country'])
|
|
sd.birth.date = f.add(npyscreen.TitleText,
|
|
name="Geburtstag: ", value=sd['birth']['date'])
|
|
sd.birth.locality = f.add(
|
|
npyscreen.TitleText, name="Geburtsort: ", value=sd['birth']['location'])
|
|
sd.email = f.add(npyscreen.TitleText,
|
|
name="email: ", value=sd['email'])
|
|
sd.pgp = f.add(npyscreen.TitleText, name="URI PGP Key: ", value=sd['pgp-key'])
|
|
sd.ssh = f.add(npyscreen.TitleText, name="URI SSH Key: ", value=sd['ssh-key'])
|
|
|
|
fin = self.member['finanzdaten']
|
|
f.add(npyscreen.TitleText, name="IBAN: ", value=fin['iban'])
|
|
f.add(npyscreen.TitleText, name="BIC: ", value=fin['bic'])
|
|
f.add(npyscreen.TitleText, name="Kontoinhaber: ", value=fin['holder'])
|
|
f.add(npyscreen.TitleText, name="Tag der Erteilung Lastschriftmandat: ",
|
|
value=fin['issuance'])
|
|
f.add(npyscreen.TitleText, name="Mandatsreferenznummer: ",
|
|
value=fin['reference'])
|
|
f.add(npyscreen.TitleText, name="URI Scan SEPA-Mandat: ",
|
|
value=fin['scan-sepa-mandate'])
|
|
|
|
mem = self.member['mitgliederdaten']
|
|
f.add(npyscreen.TitleText, name="Status: ", value=mem['status'])
|
|
f.add(npyscreen.TitleText, name="Von: ", value=mem['von'])
|
|
f.add(npyscreen.TitleText, name="Bis: ", value=mem['bis'])
|
|
f.add(npyscreen.TitleText, name="Mitgliedsbeitrag: ",
|
|
value=mem['mitgliedsbeitrag'])
|
|
f.add(npyscreen.TitleText, name="Schliessberechtigung: ",
|
|
value=mem['schliessberechtigung'])
|
|
f.add(npyscreen.TitleText, name="URI Scan Antrag: ",
|
|
value=mem['scan-antrag'])
|
|
|
|
f.edit()
|
|
|
|
|
|
def main(*_args):
|
|
if len(argv) > 1:
|
|
member_struct = json.load(open(argv[1], 'r'))
|
|
else:
|
|
member_struct = json.load(open('example.json', 'r'))
|
|
app = FormApp(member_struct)
|
|
app.run()
|
|
with open('foo.json', 'w') as outfile:
|
|
json.dump(app.member, outfile, sort_keys=True, indent=4)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
npyscreen.wrapper_basic(main)
|