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
This commit is contained in:
Maximilian Keßler 2021-09-16 12:26:17 +02:00
parent 704793af5a
commit 06f34ba5fe
2 changed files with 10 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.swp
scripts/__pycache__
scripts/test.py

View File

@ -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())