N-Coder / studip-fuse

Python FUSE drive for courses and files available through the Stud.IP University Access Portal
GNU General Public License v3.0
20 stars 2 forks source link

Parse further information from Stud.IP #2

Closed N-Coder closed 5 years ago

N-Coder commented 6 years ago

The optimal solution would be a generic method for generating listings of a certain group of objects and then querying further details about these objects (if they weren't included in the listing).

N-Coder commented 6 years ago

Old checks that assume that one Course can only exist within one Semester:

if self._course:
    assert not self._semester or self._course.semester == self._semester, \
        "virtual path %s describes course %s of semester %s, " \
        "which doesn't match the semester of the virtual path %s" % \
        (self, self._course, self._course.semester, self._semester)
if self._file:
    assert not self._semester or self._file.semester == self._semester, \
        "virtual path %s describes file %s of semester %s, " \
        "which doesn't match the semester of the virtual path %s" % \
        (self, self._file, self._file.semester, self._semester)
    assert not self._course or self._file.course == self._course, \
        "virtual path %s describes file %s of course %s %s, " \
        "which doesn't match the course of the virtual path %s %s" % \
        (self, self._file, self._file.course, self._file.course.semester, self._course, self._course.semester)

New checks that ensure that known_data doesn't change:

if self.parent:
    assert self.partial_path.startswith(self.parent.partial_path), \
        "Path of child file %s doesn't start with the path of its parent %s. " \
        "Does your path format specification make sense?" % (self, self.parent)
    assert set(self._known_tokens.items()).issuperset(self.parent._known_tokens.items()), \
        "Known data of child file %s doesn't include all data of its parent %s. " \
        "Does your path format specification make sense? " \
        "Offending keys are:\n%s" % (self, self.parent, tabulate(
            ((key, self.parent._known_tokens.get(key, "unset"), self._known_tokens.get(key, "unset"))
             for key in set(chain(self._known_tokens.keys(), self.parent._known_tokens.keys()))),
            headers=["key", "parent value", "child value"], missingval="None"
        ))