how do I reference "tag" that is in my "DataIngestor" class inside my "S3PlayerWritter" class in python?

Viewed 7

i have a class called s3playerswrittter where I need to record the name of a file including information that is in another class. (DataIngestor) how could I do that? I'm new using python and I just got stuck with this doubt

        class DataIngestor(ABC):
    def __init__(self, writer, tag: list[str], sub_type: list[str]) -> None:
        self.writer = writer
        self.tag = tag
        self.sub_type = sub_type
  
    @abstractmethod
    def ingest(self) -> None:
        pass

class PlayersApiIngestor(DataIngestor):

    def ingest(self) -> None:
        for sub_type in self.sub_type:
            for my_tag in self.tag:
                api = PlayersAPI()
                my_tag = my_tag
                data = api.get_data(tag=my_tag, sub_type= sub_type)
                self.writer(sub_type=sub_type, api=api.type, tag=my_tag).write(data)

class DataWritter:
    def __init__(self, api: str, sub_type: str) -> None:
        self.api = api
        self.sub_type = sub_type
        self.filename = f"{self.api}/{self.sub_type}/{datetime.datetime.now()}.json" 

class S3DataWritter(DataWritter):
    def __init__(self, api: str, sub_type: str) -> None: #here
        super().__init__(api, sub_type)
        self.tempfile = NamedTemporaryFile()
        self.client = boto3.client("s3")
        self.key = f"APIRoyale/{self.api}/sub_type={self.sub_type}/extracted_at={datetime.datetime.now().date()}/{datetime.datetime.now()}.json"

class S3PlayerWritter(S3DataWritter):
    def __init__(self, api: str, sub_type: str) -> None: 
        super().__init__(api, sub_type)
        S3DataWritter.__init__(self, tempfile, client)
        self.key = f"APIRoyale/{self.api}/sub_type={self.sub_type}/extracted_at={datetime.datetime.now().date()}/{tag}_{datetime.datetime.now()}.json"
0 Answers
Related