handle error
This commit is contained in:
parent
a4f973da22
commit
0d7d1cc2f3
1 changed files with 5 additions and 2 deletions
|
@ -84,8 +84,11 @@ class Exercises(list):
|
||||||
return '_'.join(map(self.__generate_name, names))
|
return '_'.join(map(self.__generate_name, names))
|
||||||
|
|
||||||
def new_writeup(self):
|
def new_writeup(self):
|
||||||
new_num = max(self.writeups, key=lambda w: w.number).number + 1
|
try:
|
||||||
new_dir = self.root / 'ub{num}'.format(num=new_num)
|
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_dir.mkdir(parents=True, exist_ok=False)
|
||||||
new_file = new_dir / '{names}_{course}_sheet_{num}.tex'.format(
|
new_file = new_dir / '{names}_{course}_sheet_{num}.tex'.format(
|
||||||
names=self.__generate_names(),
|
names=self.__generate_names(),
|
||||||
|
|
Loading…
Reference in a new issue