FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

error handling: AbsenceObject · python-webuntis/python-webuntis@d12edd1 · GitHub

Commit d12edd1

Browse files
committed
error handling: AbsenceObject
1 parent e980754 commit d12edd1

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

‎webuntis/objects.py‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -843,21 +843,22 @@ def student(self):
843843
@lazyproperty
844844
def subject(self):
845845
"""@TODO: untested - always empty"""
846-
sid = int(self._data[u'subjectId'])
847-
if sid:
848-
return self._session.subjects(from_cache=True).filter(id=sid)[0]
849-
else:
846+
try:
847+
sid = int(self._data[u'subjectId'])
848+
except ValueError:
850849
return ""
850+
return self._session.subjects(from_cache=True).filter(id=sid)[0]
851851

852852
@lazyproperty
853853
def teachers(self):
854854
"""@TODO: untested - always empty"""
855-
tes = set(int(te) for te in self._data[u'teacherIds'] if te)
856-
if tes:
857-
return self._session.teachers(from_cache=True).filter(id=tes)
858-
else:
855+
try:
856+
tes = set(int(te) for te in self._data[u'teacherIds'] if te)
857+
except ValueError:
859858
return []
860859

860+
return self._session.teachers(from_cache=True).filter(id=tes)
861+
861862
@lazyproperty
862863
def student_group(self):
863864
return self._data[u'student_group']

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL