Fix issue with database writing
In order for YAML to parse projects: as an empty array it needs to be marked as an empty array with '[]' at the end of the line. Also, when `data' is saved, it doesn't contain the updated project_list
This commit is contained in:
parent
62c96a30c6
commit
58c5b97400
|
@ -60,7 +60,7 @@ def store_project(project: dict):
|
||||||
|
|
||||||
if not os.path.exists(database):
|
if not os.path.exists(database):
|
||||||
with open(database, 'w') as f:
|
with open(database, 'w') as f:
|
||||||
f.write('projects:')
|
f.write('projects: []')
|
||||||
data = None
|
data = None
|
||||||
with open(database, 'r') as f:
|
with open(database, 'r') as f:
|
||||||
data = yaml.safe_load(f)
|
data = yaml.safe_load(f)
|
||||||
|
@ -74,6 +74,8 @@ def store_project(project: dict):
|
||||||
else:
|
else:
|
||||||
print('Project already exists')
|
print('Project already exists')
|
||||||
|
|
||||||
|
data = { 'projects' : project_list }
|
||||||
|
|
||||||
with open(database, 'w') as f:
|
with open(database, 'w') as f:
|
||||||
yaml.safe_dump(data, f)
|
yaml.safe_dump(data, f)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue