class TQZAutoReport:
__is_updating = False
@classmethod
def tqz_update(cls, settlement_jsonfile):
"""
Create or Update today auto report.
"""
if TQZAutoReport.__source_data_is_update(
current_source_data_name=TQZAutoReportFilePath.current_source_data_excel_path()
) is False:
print(f'auto-report today({TQZAutoReportFilePath.today_string()}) not update yet')
cls.__tqz_update_today_auto_report(settlement_jsonfile=settlement_jsonfile)
else:
print(f'auto-report today({TQZAutoReportFilePath.today_string()}) is update all right')
cls.__tqz_update_today_auto_report()
# --- outer operation private part ---
@classmethod
def __current_source_data_dataframe(cls):
"""
Get dataframe of current source data
"""
data_frame = None
if os.path.exists(TQZAutoReportFilePath.theory_source_data_excel_path()):
data_frame = pandas.read_excel(TQZAutoReportFilePath.theory_source_data_excel_path(), sheet_name=TQZAutoReportSheetType.SOURCE_DATA.value)
return data_frame
@classmethod
def __source_data_is_update(cls, current_source_data_name):
"""
Judge source data of current day is update or not
"""
target_string = TQZAutoReportFilePath.today_string()
source_string = current_source_data_name
ret = re.search(target_string, source_string)
if ret:
is_update = True
else:
is_update = False
return is_update
@classmethod
def __tqz_update_today_auto_report(cls, settlement_jsonfile=None):
"""
Update today auto report (Create today source data excel at first when settlement_jsonfile is not None)
"""
if cls.__is_updating is True:
return
cls.__is_updating = True # lock
if settlement_jsonfile is not None:
cls.__create_source_data_excel(settlement_jsonfile=settlement_jsonfile)
cls.__update_per_account_data_excel()
cls.__update_today_images()
cls.__update_total_data_excel()
if time.localtime().tm_wday is TQZWeekDayType.FRIDAY.value:
cls.__update_weekly_pdfs(begin_weekday=TQZWeekDayType.FRIDAY.value)
cls.__is_updating = False # unlock
...