Skip to content

Commit f6ea382

Browse files
committed
Generalize clear_date.py to handle a range of dates
1 parent 4c03487 commit f6ea382

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

clear_date.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
table and SQLite files) for a single given date."""
33
import sys
44
from util.sqlite_util import clear_cache_for_date
5+
from datetime import timedelta
56
from dateutil import parser
67

78
from parameters.local_parameters import path
@@ -15,5 +16,17 @@
1516
print("Attempting to clear the SQLite cache for date = {}".format(date_i))
1617
clear_cache_for_date(path,reference_time,date_i)
1718
print("SQLite cache cleared for {}".format(date_i))
19+
elif len(sys.argv) == 3:
20+
first_dt = parser.parse(sys.argv[1])
21+
first_date_i = first_dt.date()
22+
last_dt = parser.parse(sys.argv[2])
23+
last_date_i = last_dt.date()
24+
print("Attempting to clear the SQLite cache for dates {} through {}".format(first_date_i,last_date_i))
25+
date_i = first_date_i
26+
while date_i <= last_date_i:
27+
clear_cache_for_date(path,reference_time,date_i)
28+
print(" SQLite cache cleared for {}".format(date_i))
29+
date_i += timedelta(days=1)
30+
print("SQLite cache cleared for {} through {}".format(first_date_i,last_date_i))
1831
else:
1932
raise ValueError("Incorrect number of command-line parameters found.")

0 commit comments

Comments
 (0)