@@ -1780,8 +1780,9 @@ def delete(self):
1780
1780
1781
1781
return True
1782
1782
1783
- def get_events (self , limit = 25 , * , query = None , order_by = None , batch = None ,
1784
- download_attachments = False , include_recurring = True ):
1783
+ def get_events (self , limit : int = 25 , * , query = None , order_by = None , batch = None ,
1784
+ download_attachments = False , include_recurring = True ,
1785
+ start_recurring = None , end_recurring = None ):
1785
1786
""" Get events from this Calendar
1786
1787
1787
1788
:param int limit: max no. of events to get. Over 999 uses batch.
@@ -1793,6 +1794,8 @@ def get_events(self, limit=25, *, query=None, order_by=None, batch=None,
1793
1794
batches allowing to retrieve more items than the limit.
1794
1795
:param download_attachments: downloads event attachments
1795
1796
:param bool include_recurring: whether to include recurring events or not
1797
+ :param start_recurring: a string datetime or a Query object with just a start condition
1798
+ :param end_recurring: a string datetime or a Query object with just an end condition
1796
1799
:return: list of events in this calendar
1797
1800
:rtype: list[Event] or Pagination
1798
1801
"""
@@ -1822,22 +1825,29 @@ def get_events(self, limit=25, *, query=None, order_by=None, batch=None,
1822
1825
if include_recurring :
1823
1826
start = None
1824
1827
end = None
1825
- if query and not isinstance (query , str ):
1826
- # extract start and end from query because
1827
- # those are required by a calendarView
1828
- start = query .get_filter_by_attribute ('start/' )
1829
- end = query .get_filter_by_attribute ('start/' )
1830
-
1831
- if start :
1832
- start = start .replace ("'" , '' ) # remove the quotes
1833
- query .remove_filter ('start' )
1834
- if end :
1835
- end = end .replace ("'" , '' ) # remove the quotes
1836
- query .remove_filter ('end' )
1837
-
1828
+ if start_recurring is None :
1829
+ pass
1830
+ elif isinstance (start_recurring , str ):
1831
+ start = start_recurring
1832
+ elif isinstance (start_recurring , dt .datetime ):
1833
+ start = start_recurring .isoformat ()
1834
+ else :
1835
+ # it's a Query Object
1836
+ start = start_recurring .get_filter_by_attribute ('start/' )
1837
+ if end_recurring is None :
1838
+ pass
1839
+ elif isinstance (end_recurring , str ):
1840
+ end = end_recurring
1841
+ elif isinstance (end_recurring , dt .datetime ):
1842
+ end = end_recurring .isoformat ()
1843
+ else :
1844
+ # it's a Query Object
1845
+ end = end_recurring .get_filter_by_attribute ('end/' )
1838
1846
if start is None or end is None :
1839
1847
raise ValueError ("When 'include_recurring' is True you must provide "
1840
- "a 'start' and 'end' datetime inside a 'Query' instance." )
1848
+ "a 'start_recurring' and 'end_recurring' with a datetime string." )
1849
+ start = start .replace ("'" , '' ) # remove the quotes
1850
+ end = end .replace ("'" , '' ) # remove the quotes
1841
1851
1842
1852
params [self ._cc ('startDateTime' )] = start
1843
1853
params [self ._cc ('endDateTime' )] = end
0 commit comments