def get_reports_for_last_days_of_month( self, report_name: str, date: datetime, company: str = None) -> List[Tuple[datetime, pd.DataFrame]]: path = self._report_base_path if company is not None: company = normalize_company(name=company) path = f'{path}/{company}' path = date.strftime( f'{path}/{report_name}/{company.upper() + "_" if company else ""}{report_name}_%Y' ) reports_set = [] for report in self.container_client.list_blobs(name_starts_with=path): report_name = report['name'] match = re.search(pattern=r'\d{4}-\d{2}-\d{2}', string=report_name) report_date = datetime.strptime(match.group(), '%Y-%m-%d').date() date = datetime(year=report_date.year, month=report_date.month, day=monthrange(report_date.year, report_date.month)[1]) if report_date.strftime('%Y-%m-%d') == date.strftime('%Y-%m-%d'): reports_set.append( (report_date, self.read_pandas_dataframe_from_csv(path=report_name))) return reports_set
def get_private_push_events_commits_file_path(self, date: datetime, company: str): path = self.BASE_PATH / self.BASE_AREA_DIR / normalize_company( name=company).upper() path = path / 'github' / 'events' / 'push' / date.strftime( "%Y") / date.strftime("%m") path.mkdir(parents=True, exist_ok=True) return path / date.strftime('%Y-%m-%d.parquet')
def get_report_path(self, report_name: str, date: datetime, company: str = None) -> str: path = self._report_base_path if company is not None: company = normalize_company(name=company) path = f'{path}/{company}' return date.strftime( f'{path}/{report_name}/{company.upper() + "_" if company else ""}{report_name}_%Y-%m-%d.csv' )
def get_report_path(self, report_name: str, date: datetime, company: str = None) -> Path: path = self._report_base_path if company is not None: company = normalize_company(name=company) path /= company path = path / report_name path.mkdir(parents=True, exist_ok=True) filename = f'{company.upper() + "_" if company else ""}{report_name}_{date.strftime("%Y-%m-%d")}.csv' return path / filename