Objects and Models

Note

The classes listed here never should be instantiated directly. Instead, use the methods of webuntis.Session.

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

Bases: webuntis.objects.Result

An object containing information about a lesson type or a period code:

>>> 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'
backcolor

The background color used in the web interface and elsewhere

forecolor

The foreground color used in the web interface and elsewhere

name

The name of the LessonType or PeriodCode

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.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

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.

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.

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.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

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:

>>> 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

period_codes

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

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

Represents a subject.

long_name

Long name of subject, such as Physics

name

Short name of subject, such as PHY

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.ListItem

Represents a teacher.

fore_name

fore name of the teacher

long_name

surname of teacher

name

full name of the teacher

surname

surname of teacher