From b1369f900b1295fd5721670e75c433f67b383dd0 Mon Sep 17 00:00:00 2001 From: David Kilias Date: Fri, 6 Mar 2020 23:37:21 +0100 Subject: [PATCH] initial commit after move from prozesse --- edit_data_form.py | 75 +++++++++++++++++++++++++++++++++++++++++++++++ example.json | 39 ++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 115 insertions(+) create mode 100755 edit_data_form.py create mode 100644 example.json create mode 100644 requirements.txt diff --git a/edit_data_form.py b/edit_data_form.py new file mode 100755 index 0000000..43aeaee --- /dev/null +++ b/edit_data_form.py @@ -0,0 +1,75 @@ +#!/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) diff --git a/example.json b/example.json new file mode 100644 index 0000000..e8225c9 --- /dev/null +++ b/example.json @@ -0,0 +1,39 @@ +{ + "timestamp": "", + "stammdaten": { + "fullname": "Max Hackerberg", + "nickname": "maxH", + "address" : { + "label": "Max Hackerberg\nLeibnizstr. 32\n39104 Magdeburg", + "street": "Leibnizstr. 32", + "locality": "Magdeburg", + "region": "", + "code": "39104", + "country": "DE" + }, + "birth": { + "date": "1972-02-03", + "location": "Magdeburg" + }, + "email": "max.hackerberg@netz39.de", + "pgp-key": "https://cdn.netz39.de/maxH.asc", + "ssh-key": "https://cdn.netz39.de/maxH.pub" + }, + "finanzdaten": { + "iban": "", + "bic": "", + "holder": "", + "issuance": "", + "reference": "", + "scan-sepa-mandate": "" + }, + "mitgliederdaten": { + "status": "", + "von": "", + "bis": "", + "mitgliedsbeitrag": "", + "spendenbeitrag": "", + "schliessberechtigung": "", + "scan-antrag": "" + } +} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e57ed46 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +npyscreen==4.10.5