From 02e863bae53ed03e58bafa16876a1db11c606da9 Mon Sep 17 00:00:00 2001 From: Noa Aviel Dove Date: Fri, 22 Mar 2024 19:31:10 -0700 Subject: [PATCH] Extract ABC from verbatim manifest generator --- src/azul/service/manifest_service.py | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/azul/service/manifest_service.py b/src/azul/service/manifest_service.py index f55b4546e..4962932b2 100644 --- a/src/azul/service/manifest_service.py +++ b/src/azul/service/manifest_service.py @@ -2012,19 +2012,7 @@ def qualify(qualifier, column_name, index=None): bundle_tsv_writer.writerow(row) -class VerbatimManifestGenerator(FileBasedManifestGenerator): - - @property - def content_type(self) -> str: - return 'application/jsonl' - - @classmethod - def file_name_extension(cls) -> str: - return 'jsonl' - - @classmethod - def format(cls) -> ManifestFormat: - return ManifestFormat.verbatim_jsonl +class VerbatimManifestGenerator(FileBasedManifestGenerator, metaclass=ABCMeta): @property def entity_type(self) -> str: @@ -2105,6 +2093,21 @@ def _join_replicas(self, keys: Iterable[ReplicaKeys]) -> Iterable[Hit]: ])) return request.scan() + +class JSONLVerbatimManifestGenerator(VerbatimManifestGenerator): + + @property + def content_type(self) -> str: + return 'application/jsonl' + + @classmethod + def file_name_extension(cls) -> str: + return 'jsonl' + + @classmethod + def format(cls) -> ManifestFormat: + return ManifestFormat.verbatim_jsonl + def create_file(self) -> tuple[str, Optional[str]]: fd, path = mkstemp(suffix=f'.{self.file_name_extension()}') os.close(fd)