(self, item: Dict, item_type: str)
| 44 | return f"{base_path}/{file_name}" |
| 45 | |
| 46 | async def write_to_csv(self, item: Dict, item_type: str): |
| 47 | file_path = self._get_file_path('csv', item_type) |
| 48 | async with self.lock: |
| 49 | file_exists = os.path.exists(file_path) |
| 50 | async with aiofiles.open(file_path, 'a', newline='', encoding='utf-8-sig') as f: |
| 51 | writer = csv.DictWriter(f, fieldnames=item.keys()) |
| 52 | if not file_exists or await f.tell() == 0: |
| 53 | await writer.writeheader() |
| 54 | await writer.writerow(item) |
| 55 | |
| 56 | async def write_to_jsonl(self, item: Dict, item_type: str): |
| 57 | file_path = self._get_file_path('jsonl', item_type) |
no test coverage detected