1111
1212LOGGER = get_logger ()
1313
14+
1415class OrderChecker :
1516 """ Class with context manager to check ordering of values. """
1617 order = None
1718 _last_value = None
19+ check_paired_order = None
1820
1921 def __init__ (self , order = 'ASC' ):
2022 self .order = order
23+ self .check_paired_order = operator .lt if order == 'ASC' else operator .gt
2124
2225 def check_order (self , current_value ):
2326 """
2427 We are sub-paginating based on a sort order descending assumption for
2528 Actions, this ensures that this holds up.
2629 """
27- if self .order == 'ASC' :
28- check_paired_order = operator .lt
29- else :
30- check_paired_order = operator .gt
31-
3230 if self ._last_value is None :
3331 self ._last_value = current_value
3432
35- if check_paired_order (current_value , self ._last_value ):
33+ if self . check_paired_order (current_value , self ._last_value ):
3634 asc_desc = "ascending" if self .order == 'ASC' else "descending"
3735 gt_lt = "less than" if self .order == 'ASC' else "greater than"
3836 raise Exception (
@@ -57,9 +55,11 @@ def __enter__(self):
5755 def __exit__ (self , * args ):
5856 """ Required for context manager usage. """
5957
58+
6059class Mixin :
6160 """ Empty class to mark mixin classes as such. """
6261
62+
6363class Unsortable (Mixin ):
6464 """
6565 Mixin class to mark a Stream subclass as Unsortable
@@ -73,6 +73,7 @@ class MyStream(Unsortable, Stream):
7373# NB: We've observed that Trello will only return 50 actions, this is to sub-paginate
7474MAX_API_RESPONSE_SIZE = 50
7575
76+
7677class DateWindowPaginated (Mixin ):
7778 """
7879 Mixin class to provide date windowing on the `get_records` requests
@@ -171,7 +172,6 @@ def _paginate_window(self, window_start, window_end, format_values):
171172 break
172173
173174
174-
175175class LegacyStream :
176176 """
177177 Legacy base class for Trello streams (pre-refactor).
@@ -240,6 +240,7 @@ def sync(self):
240240 for rec in self .get_records (self .get_format_values ()):
241241 yield rec
242242
243+
243244class AddCustomFields (Mixin ):
244245 def _get_dropdown_option_key (self , field_id , option_id ):
245246 return field_id + '_' + option_id
@@ -274,7 +275,6 @@ def modify_record(self, record, **kwargs):
274275 return record
275276
276277
277-
278278class AddBoardId (Mixin ):
279279 def modify_record (self , record , ** kwargs ):
280280 board_id_list = kwargs ['parent_id_list' ]
@@ -423,7 +423,6 @@ def sync(
423423 - https://github.com/singer-io/getting-started/blob/master/docs/SYNC_MODE.md
424424 """
425425
426-
427426 def get_records (self ) -> Iterator :
428427 """Interacts with api client interaction and pagination."""
429428 self .params ["page" ] = self .page_size
0 commit comments