| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -117,6 +117,12 @@ def filter(self, **criterions): | |||
| 117 | 117 | bar = [kl for kl in s.klassen() | |
| 118 | 118 | if kl.id in {'1A', '2A', '3A', '4A'}] | |
| 119 | 119 | ||
| 120 | + # Or you can use a list: this keeps the order: the first element | ||
| 121 | + # of the result corresponds to the first element in the filter | ||
| 122 | + # Important after using combine() | ||
| 123 | + bar = s.klassen().filter(name=['1A', '2A', '3A', '4A']) | ||
| 124 | + # --> bar[0].name == '1A' | ||
| 125 | + | ||
| 120 | 126 | # Since ``filter`` returns a ListResult itself too, we can chain | |
| 121 | 127 | # multiple calls together: | |
| 122 | 128 | bar = s.klassen().filter(id=4, name='7A') # is the same as | |
@@ -151,6 +157,14 @@ def meets_criterions(item): | |||
| 151 | 157 | ||
| 152 | 158 | return True | |
| 153 | 159 | ||
| 160 | + if isinstance(criterions[0][1], list): | ||
| 161 | + return type(self)( | ||
| 162 | + parent=self, | ||
| 163 | + data=[self.filter(**{key: v})[0] | ||
| 164 | + for key, values in criterions | ||
| 165 | + for v in values | ||
| 166 | + ]) | ||
| 167 | + | ||
| 154 | 168 | return type(self)( | |
| 155 | 169 | parent=self, | |
| 156 | 170 | data=[item for item in self if meets_criterions(item)] | |
@@ -306,7 +320,7 @@ def klassen(self): | |||
| 306 | 320 | this period.""" | |
| 307 | 321 | ||
| 308 | 322 | return self._session.klassen(from_cache=True).filter( | |
| 309 | - id=set([kl[u'id'] for kl in self._data[u'kl']]) | ||
| 323 | + id=list([kl[u'id'] for kl in self._data[u'kl']]) | ||
| 310 | 324 | ) | |
| 311 | 325 | ||
| 312 | 326 | @lazyproperty | |
@@ -315,7 +329,7 @@ def teachers(self): | |||
| 315 | 329 | which are attending this period.""" | |
| 316 | 330 | ||
| 317 | 331 | return self._session.teachers(from_cache=True).filter( | |
| 318 | - id=set([te[u'id'] for te in self._data[u'te']]) | ||
| 332 | + id=list([te[u'id'] for te in self._data[u'te']]) | ||
| 319 | 333 | ) | |
| 320 | 334 | ||
| 321 | 335 | @lazyproperty | |
@@ -326,7 +340,7 @@ def subjects(self): | |||
| 326 | 340 | their own period.""" | |
| 327 | 341 | ||
| 328 | 342 | return self._session.subjects(from_cache=True).filter( | |
| 329 | - id=set([su[u'id'] for su in self._data[u'su']]) | ||
| 343 | + id=list([su[u'id'] for su in self._data[u'su']]) | ||
| 330 | 344 | ) | |
| 331 | 345 | ||
| 332 | 346 | @lazyproperty | |
@@ -336,7 +350,7 @@ def rooms(self): | |||
| 336 | 350 | lesson that is actually occuring at multiple locations (?).""" | |
| 337 | 351 | ||
| 338 | 352 | return self._session.rooms(from_cache=True).filter( | |
| 339 | - id=set([ro[u'id'] for ro in self._data[u'ro']]) | ||
| 353 | + id=list([ro[u'id'] for ro in self._data[u'ro']]) | ||
| 340 | 354 | ) | |
| 341 | 355 | ||
| 342 | 356 | @lazyproperty | |
@@ -356,7 +370,7 @@ def code(self): | |||
| 356 | 370 | def original_teachers(self): | |
| 357 | 371 | """ Support for original teachers """ | |
| 358 | 372 | try: | |
| 359 | - return self._session.teachers(from_cache=True).filter(id=set([te[u'orgid'] for te in self._data[u'te']])) | ||
| 373 | + return self._session.teachers(from_cache=True).filter(id=list([te[u'orgid'] for te in self._data[u'te']])) | ||
| 360 | 374 | except KeyError: | |
| 361 | 375 | pass | |
| 362 | 376 | return [] | |
@@ -365,7 +379,7 @@ def original_teachers(self): | |||
| 365 | 379 | def original_rooms(self): | |
| 366 | 380 | """ Support for original rooms """ | |
| 367 | 381 | try: | |
| 368 | - return self._session.rooms(from_cache=True).filter(id=set([ro[u'orgid'] for ro in self._data[u'ro']])) | ||
| 382 | + return self._session.rooms(from_cache=True).filter(id=list([ro[u'orgid'] for ro in self._data[u'ro']])) | ||
| 369 | 383 | except KeyError: | |
| 370 | 384 | pass | |
| 371 | 385 | return [] | |
@@ -877,7 +891,7 @@ def subject(self): | |||
| 877 | 891 | def teachers(self): | |
| 878 | 892 | """@TODO: untested - always empty""" | |
| 879 | 893 | try: | |
| 880 | - tes = set(int(te) for te in self._data[u'teacherIds'] if te) | ||
| 894 | + tes = list(int(te) for te in self._data[u'teacherIds'] if te) | ||
| 881 | 895 | except ValueError: | |
| 882 | 896 | return [] | |
| 883 | 897 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments