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

new: Session.students · robquant/python-webuntis@a50ce05 · GitHub

Commit a50ce05

Browse files
committed
new: Session.students
new objects.students common part of students and teachers moved to person
1 parent b3750df commit a50ce05

3 files changed

Lines changed: 68 additions & 25 deletions

File tree

‎webuntis/objects.py‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,26 +490,29 @@ class SubjectList(ListResult):
490490
_itemclass = SubjectObject
491491

492492

493-
class TeacherObject(ListItem):
494-
"""Represents a teacher."""
493+
class PersonObject(ListItem):
494+
"""Represents a person (teacher or student)."""
495495

496496
@lazyproperty
497497
def fore_name(self):
498-
"""fore name of the teacher"""
498+
"""fore name of the person"""
499499
return self._data[u'foreName']
500500

501501
@lazyproperty
502502
def long_name(self):
503-
"""surname of teacher"""
503+
"""surname of person"""
504504
return self._data[u'longName']
505505

506506
surname = long_name
507507

508508
@lazyproperty
509509
def name(self):
510-
"""full name of the teacher"""
510+
"""full name of the person"""
511511
return self._data[u'name']
512512

513+
514+
class TeacherObject(PersonObject):
515+
"""Represents a teacher."""
513516
@lazyproperty
514517
def title(self):
515518
"""title of the teacher"""
@@ -681,3 +684,15 @@ def timeUnits(self):
681684

682685
class TimegridObject(ListResult):
683686
_itemclass = TimegridDayObject
687+
688+
689+
class StudentObject(PersonObject):
690+
"""Represents a student."""
691+
692+
@lazyproperty
693+
def full_name(self):
694+
"""full name of student (forname, longname)"""
695+
return " ".join((self.fore_name, self.long_name)).strip()
696+
697+
class StudentsList(ListResult):
698+
_itemclass = StudentObject

‎webuntis/objects.pyi‎

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,29 @@ class PeriodObject(ListItem):
184184
...
185185

186186

187+
class PersonObject(ListItem):
188+
189+
@property
190+
def fore_name(self) -> str:
191+
...
192+
193+
@property
194+
def full_name(self) -> str:
195+
...
196+
197+
@property
198+
def long_name(self) -> str:
199+
...
200+
201+
@property
202+
def name(self) -> str:
203+
...
204+
205+
@property
206+
def surname(self) -> str:
207+
...
208+
209+
187210
class RoomList(ListResult):
188211

189212
def filter(self, **criterions) -> RoomList:
@@ -267,6 +290,20 @@ class SubjectObject(ListItem):
267290
...
268291

269292

293+
class StudentsList(ListResult):
294+
def filter(self, **criterions) -> StudentsList:
295+
...
296+
297+
def __getitem__(self, i: int) -> StudentObject:
298+
...
299+
300+
301+
class StudentObject(PersonObject):
302+
@property
303+
def full_name(self) -> str:
304+
...
305+
306+
270307
class SubstitutionList(ListResult):
271308

272309
def filter(self, **criterions) -> SubstitutionList:
@@ -300,30 +337,13 @@ class TeacherList(ListResult):
300337
...
301338

302339

303-
class TeacherObject(ListItem):
304-
305-
@property
306-
def fore_name(self) -> str:
307-
...
308-
309-
@property
310-
def full_name(self) -> str:
311-
...
312-
313-
@property
314-
def long_name(self) -> str:
315-
...
316-
340+
class TeacherObject(PersonObject):
317341
@property
318-
def name(self) -> str:
319-
...
320-
321-
@property
322-
def surname(self) -> str:
342+
def title(self) -> str:
323343
...
324344

325345
@property
326-
def title(self) -> str:
346+
def full_name(self):
327347
...
328348

329349

‎webuntis/session.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,14 @@ def timegridUnits(self):
323323
return objects.TimegridObject, 'getTimegridUnits', {}
324324

325325

326+
@result_wrapper
327+
def students(self):
328+
"""
329+
330+
:rtype: :py:class:`webuntis.objects.StudentsList`
331+
"""
332+
return objects.StudentsList, 'getStudents', {}
333+
326334
class Session(JSONRPCSession, ResultWrapperMixin):
327335
"""The origin of everything you want to do with the WebUntis API. Can be
328336
used as a context-manager to provide automatic log-out.

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL