Skip to content

Commit

Permalink
fetch: Fix case in which feed_info.txt exists but doesn't contain the…
Browse files Browse the repository at this point in the history
… required row
  • Loading branch information
jbruechert committed Nov 6, 2024
1 parent fbc9033 commit 457f13e
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,24 @@ def validate_source_name(name: str):

def check_feed_timeframe_valid(zip_content: bytes):
with ZipFile(file=io.BytesIO(zip_content)) as z:
if "feed_info.txt" in z.namelist():
with z.open("feed_info.txt", "r") as a:
with io.TextIOWrapper(a) as at:
feedinforeader = csv.DictReader(at, delimiter=",",
quotechar='"')
for row in feedinforeader:
start_date = \
datetime.strptime(row["feed_start_date"],
"%Y%m%d")

today = datetime.today()
if start_date > today:
return False
if "feed_info.txt" not in z.namelist():
return True

with z.open("feed_info.txt", "r") as a:
with io.TextIOWrapper(a) as at:
feedinforeader = csv.DictReader(at, delimiter=",",
quotechar='"')
for row in feedinforeader:
if "feed_start_date" not in row:
return True

start_date = \
datetime.strptime(row["feed_start_date"],
"%Y%m%d")

today = datetime.today()
if start_date > today:
return False

return True

Expand Down

0 comments on commit 457f13e

Please sign in to comment.