Objects and Models¶
Note
The classes listed here never should be instantiated directly. Instead, use
the methods of webuntis.Session.
- class webuntis.objects.AbsenceObject(data, parent=None, session=None)¶
Bases:
ResultRepresents an absence.
Attention: if there are multiple teachers/groups at the same time -> multiple entries for the same student, but the absentTime is only set for one (the first?) entry.
- end¶
The end date/time of the period.
- name¶
Name of absent student
- start¶
The start date/time of the period, as datetime object.
- student¶
doku says: student ID, but it is the students KEY :return:
- subject¶
@TODO: untested - always empty
- teachers¶
@TODO: untested - always empty
- class webuntis.objects.AbsencesList(data, parent=None, session=None)¶
Bases:
ListResultA list of absences.
- class webuntis.objects.ClassRegCategory(data, parent=None, session=None)¶
Bases:
ResultRepresents an ClassRegCategory.
- group¶
- longname¶
longname of category
- name¶
name of category
- class webuntis.objects.ClassRegCategoryGroup(data, parent=None, session=None)¶
Bases:
ResultRepresents an ClassRegCategoryGroup.
- name¶
name of group
- class webuntis.objects.ClassRegCategoryGroupList(data, parent=None, session=None)¶
Bases:
ListResultA list of ClassRegCategoriesGroups.
- class webuntis.objects.ClassRegCategoryList(data, parent=None, session=None)¶
Bases:
ListResultA list of ClassRegCategories.
- class webuntis.objects.ClassRegEvent(data, parent=None, session=None)¶
Bases:
ResultRepresents an ClassRegEvent.
- category¶
which category
- date¶
the date of the classregevent.
- fore_name¶
fore name of the person
- name¶
fore name of the person
- reason¶
reason of the classregevent
- student¶
doku says: student ID, but it is the students KEY
- Returns:
- subject¶
the subject of the classregevent.
- sur_name¶
sur name of the person
- text¶
text of the classregevent
- class webuntis.objects.ClassRegEventList(data, parent=None, session=None)¶
Bases:
ListResultA list of ClassRegEvents.
- class webuntis.objects.ColorInfo(data, parent=None, session=None)¶
Bases:
Result,ColorMixinAn object containing information about a lesson type or a period code:
>>> import webuntis >>> s = webuntis.Session(...).login() >>> lstype = s.statusdata().lesson_types[0] >>> lstype.name 'ls' >>> lstype.forecolor '000000' >>> lstype.backcolor 'ee7f00'
>>> pcode = s.statusdata().period_codes[0] >>> pcode.name 'cancelled' >>> pcode.forecolor 'FFFFFF' >>> pcode.backcolor 'FF0000'
- id¶
- name¶
The name of the LessonType or PeriodCode
- class webuntis.objects.ColorMixin¶
Bases:
objectInterface support fore/back color
- backcolor¶
The background color used in the web interface and elsewhere
- forecolor¶
The foreground color used in the web interface and elsewhere
- class webuntis.objects.DepartmentList(data, parent=None, session=None)¶
Bases:
ListResultA list of departments, in form of
DepartmentObjectinstances.
- class webuntis.objects.DepartmentObject(data, parent=None, session=None)¶
Bases:
ListItemRepresents a department
- long_name¶
Long name, such as Raum Erste A. Not predictable.
- name¶
short name such as R1A
- class webuntis.objects.ExamObject(data, parent=None, session=None)¶
Bases:
ResultRepresents an Exam.
- end¶
The end date/time of the period.
- klassen¶
A
KlassenListcontaining the classes which are attending this period.
- start¶
The start date/time of the period, as datetime object.
- students¶
A list of
StudentObjectinstances, which are attending this period.
- subject¶
A
SubjectObjectwith the subject which are topic of this period.
- teachers¶
A list of
TeacherObjectinstances, which are attending this period.
- class webuntis.objects.ExamTypeList(data, parent=None, session=None)¶
Bases:
ListResultA list of exam types
- class webuntis.objects.ExamTypeObject(data, parent=None, session=None)¶
Bases:
ResultRepresents an Exam Type.
- long_name¶
Long name
- name¶
- show_in_timetable¶
show this exam type in the timetable
- class webuntis.objects.ExamsList(data, parent=None, session=None)¶
Bases:
ListResultA list of exams.
- class webuntis.objects.HolidayList(data, parent=None, session=None)¶
Bases:
ListResultA list of holidays, in form of
HolidayObjectinstances.
- class webuntis.objects.HolidayObject(data, parent=None, session=None)¶
Bases:
ListItemRepresents a single holiday.
- end¶
The end of the holiday
- name¶
Name, such as Nationalfeiertag.
- short_name¶
Abbreviated form of the name
- start¶
The start date of the holiday, as a datetime object.
- class webuntis.objects.KlassenList(data, parent=None, session=None)¶
Bases:
ListResultA list of school classes, in form of
KlassenObjectinstances.
- class webuntis.objects.KlassenObject(data, parent=None, session=None)¶
Bases:
ListItem,ColorMixinRepresents a school class.
- long_name¶
Long name of class
- name¶
Name of class
- teacher1¶
First teacher of class
- teacher2¶
Second teacher of class
- class webuntis.objects.ListItem(data, parent=None, session=None)¶
Bases:
ResultListItems represent an item in a
Result. They don’t contain methods to retrieve data.
- class webuntis.objects.ListResult(data, parent=None, session=None)¶
Bases:
ResultA list-like version of
Resultthat takes a list and returns a list of objects, containing a list value each.- filter(**criterions)¶
Return a list of all objects, filtered by attributes:
foo = s.klassen().filter(id=1) # is kind-of the same as foo = [kl for kl in s.klassen() if kl.id == 1] # We can also use sets to match multiple values. bar = s.klassen().filter(name={'1A', '2A', '3A', '4A'}) # is kind-of the same as bar = [kl for kl in s.klassen() if kl.id in {'1A', '2A', '3A', '4A'}] # Or you can use a list: this keeps the order: the first element # of the result corresponds to the first element in the filter # Important after using combine() bar = s.klassen().filter(name=['1A', '2A', '3A', '4A']) # --> bar[0].name == '1A' # Since ``filter`` returns a ListResult itself too, we can chain # multiple calls together: bar = s.klassen().filter(id=4, name='7A') # is the same as bar = s.klassen().filter(id=4).filter(name='7A')
filter()is also used when using theinoperator on aListResult:we_have_it = {'name': '6A'} in s.klassen() # same as we_have_it = bool(s.klassen().filter(name='6A'))
Note
This is only available because it looks nicer than list comprehensions or generator expressions. Depending on your usecase alternatives to this method may be faster.
- class webuntis.objects.PeriodList(data, parent=None, session=None)¶
Bases:
ListResultAka timetable, a list of periods, in form of
PeriodObjectinstances.- combine(combine_breaks=True)¶
Combine consecutive entries :param combine_breaks: combine of breaks :return:
- to_table(dates=None, times=None)¶
Creates a table-like structure out of the periods. Useful for rendering timetables in HTML and other markup languages.
Check out the example from the repository for clarification.
- Parameters:
dates – An iterable of
datetime.dateobjects that definetly should be included in the table. If this parameter isNone, the timetable is just as wide as it has to be, leaving out days without periods.times – An iterable of
datetime.timeobjects that definetly should be included in the table. If this parameter isNone, the timetable is just as tall as it has to be, leaving out hours without periods.
- Returns:
A list containing “rows”, which in turn contain “hours”, which contain
webuntis.objects.PeriodObjectinstances which are happening at the same time.
- class webuntis.objects.PeriodObject(data, parent=None, session=None)¶
Bases:
ListItemRepresents a time range, where lessons/subjects may be held.
- activityType¶
activity type of the lesson
only available when timetable_extended() is used :return: str
- bkRemark¶
remark of the period’s booking (optional)
only available when timetable_extended() is used :return: str
- bkText¶
text of the period’s booking (optional)
only available when timetable_extended() is used :return: str
- code¶
May be:
None– There’s nothing special about this period."cancelled"– Cancelled"irregular"– Substitution/”Supplierung”/Not planned event
- code_color¶
The ColorInfo for the code of the current period
- end¶
The end date/time of the period.
- flags¶
statistical flags
only available when timetable_extended() is used :return: str
- info¶
activity type of the lesson
only available when timetable_extended() is used :return: str
- klassen¶
A
KlassenListcontaining the classes which are attending this period.
- lsnumber¶
number of the period’s lesson
only available when timetable_extended() is used :return: int
- lstext¶
text of the period’s lesson
only available when timetable_extended() is used :return: str
- original_rooms¶
Support for original rooms
- original_teachers¶
Support for original teachers
- rooms¶
The rooms (
RoomList) where this period is taking place at. This also is not used for multiple lessons, but rather for a single lesson that is actually occuring at multiple locations (?).
- start¶
The start date/time of the period, as datetime object.
- studentGroup¶
name of the period’s student group
only available when timetable_extended() is used :return: str
- subjects¶
A
SubjectListcontaining the subjects which are topic of this period. This is not used for things like multiple language lessons (e.g. Latin, Spanish, French) – each of those will get placed in their own period.
- substText¶
Untis substitution text
only available when timetable_extended() is used :return: str
- teachers¶
A list of
TeacherObjectinstances, which are attending this period.
- type¶
May be:
"ls"– Normal lesson"oh"– Office hour"sb"– Standby"bs"– Break Supervision"ex"– Examination
- class webuntis.objects.PersonObject(data, parent=None, session=None)¶
Bases:
ListItemRepresents a person (teacher or student).
- fore_name¶
fore name of the person
- long_name¶
surname of person
- name¶
full name of the person
- surname¶
surname of person
- class webuntis.objects.Result(data, parent=None, session=None)¶
Bases:
objectBase class used to represent most API objects.
- Parameters:
data –
Usually JSON data that should be represented.
In the case of
ListResult, however, it might also be a list of JSON mixed withListItemobjects.parent – (optional) A result object this result should be the child of. If given, the session will be inherited.
session – Mandatory if
parentis not supplied. Overrides the parent’s inherited session.
- id¶
The ID of this element.
An ID is needed for the object to be hashable. Therefore a result may bring its own implementation of this method even though the original API response didn’t contain any ID.
- class webuntis.objects.RoomList(data, parent=None, session=None)¶
Bases:
ListResultA list of rooms, in form of
RoomObjectinstances.
- class webuntis.objects.RoomObject(data, parent=None, session=None)¶
Bases:
ListItem,ColorMixinRepresents a physical room. Such as a classroom, but also the physics lab or whatever.
- long_name¶
The long name of the room. Such as “Physics lab”.
- name¶
The short name of the room. Such as PHY.
- class webuntis.objects.SchoolyearList(data, parent=None, session=None)¶
Bases:
ListResultA list of schoolyears, in form of
SchoolyearObjectinstances.- current¶
Returns the current schoolyear in form of a
SchoolyearObject
- class webuntis.objects.SchoolyearObject(data, parent=None, session=None)¶
Bases:
ListItemRepresents a schoolyear.
- end¶
The end date
- is_current¶
Boolean, check if this is the current schoolyear:
>>> import webuntis >>> s = webuntis.Session(...).login() >>> y = s.schoolyears() >>> y.current.id 7 >>> y.current.is_current True >>> y.filter(id=y.current.id).is_current True
- name¶
“2010/2011”
- start¶
The start date of the schoolyear, as datetime object
- class webuntis.objects.StatusData(data, parent=None, session=None)¶
Bases:
ResultInformation about lesson types and period codes and their colors.
- class webuntis.objects.StudentObject(data, parent=None, session=None)¶
Bases:
PersonObjectRepresents a student.
- full_name¶
full name of student (forname, longname)
- class webuntis.objects.StudentsList(data, parent=None, session=None)¶
Bases:
ListResultA list of students
- class webuntis.objects.SubjectList(data, parent=None, session=None)¶
Bases:
ListResultA list of subjects, in form of
SubjectObjectinstances.
- class webuntis.objects.SubjectObject(data, parent=None, session=None)¶
Bases:
ListItem,ColorMixinRepresents a subject.
- long_name¶
Long name of subject, such as Physics
- name¶
Short name of subject, such as PHY
- class webuntis.objects.SubstitutionList(data, parent=None, session=None)¶
Bases:
ListResultA list of substitutions in form of
SubstitutionObjectinstances.- combine(combine_breaks=True)¶
Combine consecutive entries :param combine_breaks: combine of breaks :return:
- class webuntis.objects.SubstitutionObject(data, parent=None, session=None)¶
Bases:
PeriodObjectInformation about substitution.
- reschedule_end¶
The end of the rescheduled substitution (or None)
- Returns:
datetime.datetime
- reschedule_start¶
The start of the rescheduled substitution (or None)
- Returns:
datetime.datetime
- class webuntis.objects.TeacherList(data, parent=None, session=None)¶
Bases:
ListResultA list of teachers, in form of
TeacherObjectinstances.
- class webuntis.objects.TeacherObject(data, parent=None, session=None)¶
Bases:
PersonObjectRepresents a teacher.
- full_name¶
full name of teacher (title, forname, longname
- title¶
title of the teacher
- class webuntis.objects.TimeStampObject(data, parent=None, session=None)¶
Bases:
ResultInformation about last change of data – timestamp (given in milliseconds)
- date¶
get timestamp as python datetime object
- Returns:
datetime.datetime
- class webuntis.objects.TimeUnitObject(data, parent=None, session=None)¶
Bases:
ResultInformation about the time grid
- name¶
Name of Timeunit
- class webuntis.objects.TimegridDayObject(data, parent=None, session=None)¶
Bases:
ResultInformation about one day in the time grid
- class webuntis.objects.TimegridObject(data, parent=None, session=None)¶
Bases:
ListResultA list of TimegridDayObjects