handle missing extra_projects.yaml

This commit is contained in:
Matt Venn
2023-04-28 13:52:48 +02:00
parent 40060b69d2
commit eb41dd0f94
+6 -2
View File
@@ -21,8 +21,12 @@ class Orders():
self.orders = sorted(orders, key=lambda d: d['time']) self.orders = sorted(orders, key=lambda d: d['time'])
def add_extra_project(self, git_url): def add_extra_project(self, git_url):
with open(self.config['extra_projects']) as fh: try:
config = yaml.safe_load(fh) with open(self.config['extra_projects']) as fh:
config = yaml.safe_load(fh)
except FileNotFoundError as e:
config = []
config.append({'project': {'url' : git_url, 'timestamp' : time.time()}}) config.append({'project': {'url' : git_url, 'timestamp' : time.time()}})
with open(self.config['extra_projects'], 'w') as fh: with open(self.config['extra_projects'], 'w') as fh:
yaml.safe_dump(config, fh) yaml.safe_dump(config, fh)