66
77"""
88
9+ import calendar
910import glob
1011import os
1112import re
1213import shutil
1314from datetime import datetime , timedelta
1415from typing import Union
15- import calendar
1616
1717# third party
1818import pandas as pd
19- import pytz
2019from delphi_utils import GeoMapper
2120
2221from .config import Config
2322
2423gmpr = GeoMapper ()
2524
25+
2626def store_backfill_file (claims_filepath , _end_date , backfill_dir , logger ):
2727 """
2828 Store county level backfill data into backfill_dir.
@@ -71,14 +71,14 @@ def store_backfill_file(claims_filepath, _end_date, backfill_dir, logger):
7171 "state_id" : "string"
7272 })
7373
74- filename = "claims_hosp_as_of_%s.parquet" % datetime .strftime (_end_date , "%Y%m%d" )
74+ filename = "claims_hosp_as_of_%s.parquet" % datetime .strftime (_end_date , "%Y%m%d" )
7575 path = f"{ backfill_dir } /{ filename } "
7676
7777 # Store intermediate file into the backfill folder
7878 try :
7979 backfilldata .to_parquet (path , index = False )
8080 logger .info ("Stored source data in parquet" , filename = filename )
81- except :
81+ except : # pylint: disable=W0702
8282 logger .info ("Failed to store source data in parquet" )
8383 return path
8484
@@ -108,7 +108,7 @@ def get_file_with_date(files) -> Union[str, None]:
108108 if pattern :
109109 file_month = datetime .strptime (pattern [0 ], "%Y%m" ).replace (day = 1 )
110110 end_date = (file_month + timedelta (days = 32 )).replace (day = 1 )
111- if issue_date >= file_month and issue_date < end_date :
111+ if file_month <= issue_date < end_date :
112112 return filename
113113 return ""
114114
@@ -118,7 +118,9 @@ def get_file_with_date(files) -> Union[str, None]:
118118 logger .info ("Issue date has no matching merged files" , issue_date = issue_date .strftime ("%Y-%m-%d" ))
119119 return
120120
121- logger .info ("Adding missing date to merged file" , issue_date = issue_date , filename = backfill_file , merged_filename = file_name )
121+ logger .info (
122+ "Adding missing date to merged file" , issue_date = issue_date , filename = backfill_file , merged_filename = file_name
123+ )
122124
123125 # Start to merge files
124126 merge_file = f"{ file_name .split ('.' )[0 ]} _after_merge.parquet"
@@ -168,7 +170,7 @@ def get_date(file_link):
168170 logger .info ("Not enough days, skipping merging" , n_file_days = len (date_list ))
169171 return
170172
171- logger .info (f "Merging files" , start_date = date_list [0 ], end_date = date_list [- 1 ])
173+ logger .info ("Merging files" , start_date = date_list [0 ], end_date = date_list [- 1 ])
172174 # Start to merge files
173175 pdList = []
174176 for fn in new_files :
0 commit comments