ask-for-destination-fix #23
1 changed files with 9 additions and 6 deletions
|
@ -4,7 +4,7 @@
|
|||
import npyscreen
|
||||
import json
|
||||
import datetime
|
||||
from sys import argv
|
||||
import sys
|
||||
import pathlib
|
||||
|
||||
from base_data_model import base_data_model
|
||||
|
@ -57,18 +57,21 @@ class FormApp(npyscreen.NPSAppManaged):
|
|||
return pathlib.Path(filename).name == 'example.json'
|
||||
|
||||
def main(*_args):
|
||||
if len(argv) > 1:
|
||||
filename = argv[1]
|
||||
if len(sys.argv) > 1:
|
||||
file_path = pathlib.Path(sys.argv[1])
|
||||
if not file_path.exists():
|
||||
print("Trying to open nonexistent file. Aborting.")
|
||||
sys.exit(0)
|
||||
else:
|
||||
filename = pathlib.Path(pathlib.Path(__file__).absolute().parent, 'example.json')
|
||||
file_path = pathlib.Path(pathlib.Path(__file__).absolute().parent, 'example.json')
|
||||
|
||||
app = FormApp(filename)
|
||||
app = FormApp(file_path)
|
||||
|
||||
try:
|
||||
app.run()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return 0
|
||||
sys.exit(0)
|
||||
|
||||
if app.data_has_changed():
|
||||
out_data = app.get_data_from_form()
|
||||
|
|
Loading…
Reference in a new issue