use Path with prefix

This commit is contained in:
David Kilias 2020-03-18 19:31:02 +01:00
parent d3cabbf573
commit 1989d432d9

View file

@ -5,7 +5,7 @@ import npyscreen
import json import json
import datetime import datetime
from sys import argv from sys import argv
from pathlib import Path import pathlib
from base_data_model import base_data_model from base_data_model import base_data_model
from financial_data_model import financial_data_model from financial_data_model import financial_data_model
@ -16,7 +16,7 @@ class FormApp(npyscreen.NPSAppManaged):
def __init__(self, filename): def __init__(self, filename):
super().__init__() super().__init__()
self.dir_path = Path(filename).absolute().parent self.dir_path = pathlib.Path(filename).absolute().parent
self.member = json.load(open(filename, 'r')) self.member = json.load(open(filename, 'r'))
self.base_data = base_data_model(self.member['stammdaten']) self.base_data = base_data_model(self.member['stammdaten'])
@ -46,7 +46,7 @@ class FormApp(npyscreen.NPSAppManaged):
def get_filepath(self): def get_filepath(self):
name = self.base_data.get_form_values_dict()['fullname'] name = self.base_data.get_form_values_dict()['fullname']
fn = '{}_{}.json'.format('_'.join(name.split()), datetime.datetime.now().replace(microsecond=0).isoformat()) fn = '{}_{}.json'.format('_'.join(name.split()), datetime.datetime.now().replace(microsecond=0).isoformat())
file_path = Path(self.dir_path, fn) file_path = pathlib.Path(self.dir_path, fn)
return file_path return file_path
@ -54,7 +54,7 @@ def main(*_args):
if len(argv) > 1: if len(argv) > 1:
filename = argv[1] filename = argv[1]
else: else:
filename = Path(Path(__file__).absolute().parent, 'example.json') filename = pathlib.Path(pathlib.Path(__file__).absolute().parent, 'example.json')
app = FormApp(filename) app = FormApp(filename)