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: webuntis.objects.Result

Represents 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: webuntis.objects.ListResult

A list of absences.

class webuntis.objects.ClassRegEvent(data, parent=None, session=None)

Bases: webuntis.objects.Result

Represents an ClassRegEvent.

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: webuntis.objects.ListResult

A list of ClassRegEvents.

class webuntis.objects.ColorInfo(data, parent=None, session=None)

Bases: webuntis.objects.Result, webuntis.objects.ColorMixin

An 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'
name

The name of the LessonType or PeriodCode

class webuntis.objects.ColorMixin

Interface 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: webuntis.objects.ListResult

A list of departments, in form of DepartmentObject instances.

class webuntis.objects.DepartmentObject(data, parent=None, session=None)

Bases: webuntis.objects.ListItem

Represents 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: webuntis.objects.Result

Represents an Exam.

end

The end date/time of the period.

klassen

A KlassenList containing the classes which are attending this period.

start

The start date/time of the period, as datetime object.

students

A list of StudentObject instances, which are attending this period.

subject

A SubjectObject with the subject which are topic of this period.

teachers

A list of TeacherObject instances, which are attending this period.

class webuntis.objects.ExamTypeList(data, parent=None, session=None)

Bases: webuntis.objects.ListResult

A list of exam types

class webuntis.objects.ExamTypeObject(data, parent=None, session=None)

Bases: webuntis.objects.Result

Represents 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: webuntis.objects.ListResult

A list of exams.

class webuntis.objects.HolidayList(data, parent=None, session=None)

Bases: webuntis.objects.ListResult

A list of holidays, in form of HolidayObject instances.

class webuntis.objects.HolidayObject(data, parent=None, session=None)

Bases: webuntis.objects.ListItem

Represents 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: webuntis.objects.ListResult

A list of school classes, in form of KlassenObject instances.

class webuntis.objects.KlassenObject(data, parent=None, session=None)

Bases: webuntis.objects.ListItem, webuntis.objects.ColorMixin

Represents a school class.

long_name

Long name of class

name

Name of class

class webuntis.objects.ListItem(data, parent=None, session=None)

Bases: webuntis.objects.Result

ListItems represent an item in a Result. They don’t contain methods to retrieve data.

class webuntis.objects.ListResult(data, parent=None, session=None)

Bases: webuntis.objects.Result

A list-like version of Result that 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'}]

# 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 the in operator on a ListResult:

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: webuntis.objects.ListResult

Aka timetable, a list of periods, in form of PeriodObject instances.

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.date objects that definetly should be included in the table. If this parameter is None, the timetable is just as wide as it has to be, leaving out days without periods.
  • times – An iterable of datetime.time objects that definetly should be included in the table. If this parameter is None, 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.PeriodObject instances which are happening at the same time.

class webuntis.objects.PeriodObject(data, parent=None, session=None)

Bases: webuntis.objects.ListItem

Represents a time range, where lessons/subjects may be held.

code

May be:

  • None – There’s nothing special about this period.
  • "cancelled" – Cancelled
  • "irregular" – Substitution/”Supplierung”/Not planned event
end

The end date/time of the period.

klassen

A KlassenList containing the classes which are attending this period.

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.

subjects

A SubjectList containing 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.

teachers

A list of TeacherObject instances, 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: webuntis.objects.ListItem

Represents 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: object

Base 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 with ListItem objects.

  • parent – (optional) A result object this result should be the child of. If given, the session will be inherited.
  • session – Mandatory if parent is 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: webuntis.objects.ListResult

A list of rooms, in form of RoomObject instances.

class webuntis.objects.RoomObject(data, parent=None, session=None)

Bases: webuntis.objects.ListItem, webuntis.objects.ColorMixin

Represents 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: webuntis.objects.ListResult

A list of schoolyears, in form of SchoolyearObject instances.

current

Returns the current schoolyear in form of a SchoolyearObject

class webuntis.objects.SchoolyearObject(data, parent=None, session=None)

Bases: webuntis.objects.ListItem

Represents 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: webuntis.objects.Result

Information about lesson types and period codes and their colors.

lesson_types

A list of ColorInfo objects, containing information about all lesson types defined

Return type:list [ColorInfo]
period_codes

A list of ColorInfo objects, containing information about all period codes defined

Return type:list [ColorInfo]
class webuntis.objects.StudentObject(data, parent=None, session=None)

Bases: webuntis.objects.PersonObject

Represents a student.

full_name

full name of student (forname, longname)

class webuntis.objects.StudentsList(data, parent=None, session=None)

Bases: webuntis.objects.ListResult

A list of students

class webuntis.objects.SubjectList(data, parent=None, session=None)

Bases: webuntis.objects.ListResult

A list of subjects, in form of SubjectObject instances.

class webuntis.objects.SubjectObject(data, parent=None, session=None)

Bases: webuntis.objects.ListItem, webuntis.objects.ColorMixin

Represents 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: webuntis.objects.ListResult

A list of substitutions in form of SubstitutionObject instances.

combine(combine_breaks=True)

Combine consecutive entries :param combine_breaks: combine of breaks :return:

class webuntis.objects.SubstitutionObject(data, parent=None, session=None)

Bases: webuntis.objects.PeriodObject

Information 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
type
type of substitution
cancel cancellation subst teacher substitution add additional period shift shifted period rmchg room change
Return type:str
class webuntis.objects.TeacherList(data, parent=None, session=None)

Bases: webuntis.objects.ListResult

A list of teachers, in form of TeacherObject instances.

class webuntis.objects.TeacherObject(data, parent=None, session=None)

Bases: webuntis.objects.PersonObject

Represents 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: webuntis.objects.Result

Information 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: webuntis.objects.Result

Information about the time grid

name

Name of Timeunit

class webuntis.objects.TimegridDayObject(data, parent=None, session=None)

Bases: webuntis.objects.Result

Information about one day in the time grid

class webuntis.objects.TimegridObject(data, parent=None, session=None)

Bases: webuntis.objects.ListResult

A list of TimegridDayObjects