From 06f34ba5fefdb4f7e7906e09f45175179896dc9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 16 Sep 2021 12:26:17 +0200 Subject: [PATCH] introduce .courseignore file You can now place a file name '.courseignore' in the ROOT directory and specify - in each line - the name of a directory. Directories named this way and located in the ROOT directory will not be treated as course directories --- .gitignore | 1 + scripts/courses.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 048246c..12ff3e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.swp scripts/__pycache__ +scripts/test.py diff --git a/scripts/courses.py b/scripts/courses.py index 34cfe41..46a87f5 100755 --- a/scripts/courses.py +++ b/scripts/courses.py @@ -29,10 +29,18 @@ class Courses(list): list.__init__(self, self.read_files()) def read_files(self): - course_directories = [x for x in ROOT.iterdir() if x.is_dir()] + course_directories = [x for x in ROOT.iterdir() if x.is_dir() and not x in self.ignored_courses()] _courses = [Course(path) for path in course_directories] return sorted(_courses, key=lambda c: c.name) + def ignored_courses(self): + with open(ROOT / '.courseignore') as ignore: + lines = ignore.readlines() + paths = [] + for line in lines: + paths.append(ROOT / line.strip()) + return paths + @property def current(self): return Course(CURRENT_COURSE_ROOT.resolve())