77import typing as t
88
99from flareio_cli .csv import PydanticCsvWriter
10- from flareio_cli .cursor import CursorFile
10+ from flareio_cli .cursor import Cursor
1111from flareio_cli .progress import export_progress
1212
1313
14- ExportItem = t .TypeVar ("ExportItem" , bound = pydantic .BaseModel )
14+ ExportItem = t .TypeVar (
15+ "ExportItem" ,
16+ bound = pydantic .BaseModel ,
17+ )
1518
1619
1720@dataclasses .dataclass (frozen = True )
@@ -24,7 +27,7 @@ def export_to_csv(
2427 * ,
2528 output_file : pathlib .Path ,
2629 pages : t .Iterator [ExportPage [ExportItem ]],
27- cursor : CursorFile ,
30+ cursor : Cursor ,
2831 object_name : str = "items" ,
2932 item_model : type [ExportItem ],
3033) -> None :
@@ -45,7 +48,7 @@ def _export_to_csv(
4548 * ,
4649 output_file : pathlib .Path ,
4750 pages : t .Iterator [ExportPage [ExportItem ]],
48- cursor : CursorFile ,
51+ cursor : Cursor ,
4952 object_name : str = "items" ,
5053 item_model : type [ExportItem ],
5154) -> None :
@@ -65,12 +68,15 @@ def _export_to_csv(
6568 writer .writeheader ()
6669
6770 for page in pages :
71+ cursor .save (page .next )
72+
6873 for row in page .items :
69- writer .writerow (row )
74+ writer .writerow (
75+ row = row ,
76+ cursor = cursor ,
77+ )
7078 writer .flush ()
7179
72- cursor .save (page .next )
73-
7480 progress_manager .update_progress (
7581 incr_completed = len (page .items ),
7682 new_cursor = cursor .value (),
0 commit comments