|
|
|
@ -3,6 +3,8 @@ import icalendar |
|
|
|
|
import datetime |
|
|
|
|
import requests |
|
|
|
|
import urllib |
|
|
|
|
import glob |
|
|
|
|
import pytz |
|
|
|
|
import json |
|
|
|
|
import os |
|
|
|
|
|
|
|
|
@ -77,15 +79,16 @@ for trash_type in trash_types: |
|
|
|
|
if not os.path.exists(trash_type_folder): |
|
|
|
|
os.makedirs(trash_type_folder) |
|
|
|
|
|
|
|
|
|
for f in next(os.walk(trash_type_folder), (None, None, []))[2]: |
|
|
|
|
for f in os.listdir(trash_type_folder): |
|
|
|
|
ical_path = os.path.join(trash_type_folder, f) |
|
|
|
|
with open(ical_path, "rb") as fh: |
|
|
|
|
try: |
|
|
|
|
cal = icalendar.Calendar.from_ical(fh.read()) |
|
|
|
|
except ValueError: |
|
|
|
|
print("{} is not an parsable ical file".format(ical_path)) |
|
|
|
|
continue |
|
|
|
|
if cal.walk()[1]["DTSTAMP"].dt.year == current_year: |
|
|
|
|
if os.path.isfile(ical_path): |
|
|
|
|
with open(ical_path, "rb") as fh: |
|
|
|
|
try: |
|
|
|
|
cal = icalendar.Calendar.from_ical(fh.read()) |
|
|
|
|
except ValueError: |
|
|
|
|
print("{} is not an parsable ical file".format(ical_path)) |
|
|
|
|
continue |
|
|
|
|
if cal.walk()[1]["DTSTART"].dt > datetime.datetime.now(pytz.utc): |
|
|
|
|
os.remove(ical_path) |
|
|
|
|
|
|
|
|
|
radicale_prop_file = os.path.join(trash_type_folder, ".Radicale.props") |
|
|
|
|