The rruleset type allows more complex recurrence setups, mixing multiple rules, dates, exclusion rules, and exclusion dates. The type constructor takes the following keyword arguments: :param cache: If True, caching of results will be enabled, improving performance of
| 1320 | |
| 1321 | |
| 1322 | class rruleset(rrulebase): |
| 1323 | """ The rruleset type allows more complex recurrence setups, mixing |
| 1324 | multiple rules, dates, exclusion rules, and exclusion dates. The type |
| 1325 | constructor takes the following keyword arguments: |
| 1326 | |
| 1327 | :param cache: If True, caching of results will be enabled, improving |
| 1328 | performance of multiple queries considerably. """ |
| 1329 | |
| 1330 | class _genitem: |
| 1331 | def __init__(self, genlist, gen): |
| 1332 | try: |
| 1333 | self.dt = next(gen) |
| 1334 | genlist.append(self) |
| 1335 | except StopIteration: |
| 1336 | pass |
| 1337 | self.genlist = genlist |
| 1338 | self.gen = gen |
| 1339 | |
| 1340 | def __next__(self): |
| 1341 | try: |
| 1342 | self.dt = next(self.gen) |
| 1343 | except StopIteration: |
| 1344 | if self.genlist[0] is self: |
| 1345 | heapq.heappop(self.genlist) |
| 1346 | else: |
| 1347 | self.genlist.remove(self) |
| 1348 | heapq.heapify(self.genlist) |
| 1349 | |
| 1350 | |
| 1351 | def __lt__(self, other): |
| 1352 | return self.dt < other.dt |
| 1353 | |
| 1354 | def __gt__(self, other): |
| 1355 | return self.dt > other.dt |
| 1356 | |
| 1357 | def __eq__(self, other): |
| 1358 | return self.dt == other.dt |
| 1359 | |
| 1360 | def __ne__(self, other): |
| 1361 | return self.dt != other.dt |
| 1362 | |
| 1363 | def __init__(self, cache=False): |
| 1364 | super().__init__(cache) |
| 1365 | self._rrule = [] |
| 1366 | self._rdate = [] |
| 1367 | self._exrule = [] |
| 1368 | self._exdate = [] |
| 1369 | |
| 1370 | @_invalidates_cache |
| 1371 | def rrule(self, rrule): |
| 1372 | """ Include the given :py:class:`rrule` instance in the recurrence set |
| 1373 | generation. """ |
| 1374 | self._rrule.append(rrule) |
| 1375 | |
| 1376 | @_invalidates_cache |
| 1377 | def rdate(self, rdate): |
| 1378 | """ Include the given :py:class:`datetime` instance in the recurrence |
| 1379 | set generation. """ |
no outgoing calls