From 0d7d1cc2f34329dd97d6032e2749f0382b3f233f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 10 Oct 2021 21:06:34 +0200 Subject: [PATCH] handle error --- scripts/exercises.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/exercises.py b/scripts/exercises.py index 326d17e..5e3d712 100644 --- a/scripts/exercises.py +++ b/scripts/exercises.py @@ -84,8 +84,11 @@ class Exercises(list): return '_'.join(map(self.__generate_name, names)) def new_writeup(self): - new_num = max(self.writeups, key=lambda w: w.number).number + 1 - new_dir = self.root / 'ub{num}'.format(num=new_num) + try: + new_num = max(self.writeups, key=lambda w: w.number).number + 1 + except ValueError: + new_num = 1 + new_dir = self.root / 'ub{:02d}'.format(new_num) new_dir.mkdir(parents=True, exist_ok=False) new_file = new_dir / '{names}_{course}_sheet_{num}.tex'.format( names=self.__generate_names(),