Removed useless comments
This commit is contained in:
parent
8df31ef074
commit
b401b0335e
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
# Configure logging format
|
|
||||||
LOGFORMAT = "%(asctime)s - %(levelname)s - %(message)s"
|
LOGFORMAT = "%(asctime)s - %(levelname)s - %(message)s"
|
||||||
DATEFORMAT = "%Y-%m-%d %H:%M:%S"
|
DATEFORMAT = "%Y-%m-%d %H:%M:%S"
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ def compare_events(
|
|||||||
|
|
||||||
logger.info(f"Comparing {len(server_events)} server events with {len(local_events)} local events")
|
logger.info(f"Comparing {len(server_events)} server events with {len(local_events)} local events")
|
||||||
|
|
||||||
# Find new and updated events
|
|
||||||
for uid, event in server_events.items():
|
for uid, event in server_events.items():
|
||||||
if uid not in local_events:
|
if uid not in local_events:
|
||||||
logger.debug(f"New event found: {event['summary']} (UID: {uid})")
|
logger.debug(f"New event found: {event['summary']} (UID: {uid})")
|
||||||
@ -67,7 +66,6 @@ def compare_events(
|
|||||||
event["google_event_id"] = local_events[uid].get("google_event_id")
|
event["google_event_id"] = local_events[uid].get("google_event_id")
|
||||||
updated_events.append(event)
|
updated_events.append(event)
|
||||||
|
|
||||||
# Find deleted events
|
|
||||||
for uid, event in local_events.items():
|
for uid, event in local_events.items():
|
||||||
if uid not in server_events:
|
if uid not in server_events:
|
||||||
logger.debug(f"Deleted event found: {event['summary']} (UID: {uid})")
|
logger.debug(f"Deleted event found: {event['summary']} (UID: {uid})")
|
||||||
@ -117,7 +115,6 @@ def save_local_sync(file_path: str, events: EventsDict) -> None:
|
|||||||
logger.info(f"Saving {len(events)} events to local sync file")
|
logger.info(f"Saving {len(events)} events to local sync file")
|
||||||
sanitized_events = {}
|
sanitized_events = {}
|
||||||
|
|
||||||
# Sanitize events
|
|
||||||
for event_id, event_data in events.items():
|
for event_id, event_data in events.items():
|
||||||
try:
|
try:
|
||||||
sanitized_events[event_id] = _sanitize_event_for_json(event_data)
|
sanitized_events[event_id] = _sanitize_event_for_json(event_data)
|
||||||
@ -125,7 +122,6 @@ def save_local_sync(file_path: str, events: EventsDict) -> None:
|
|||||||
logger.error(f"Failed to sanitize event {event_id} ({event_data.get('summary', 'No summary')}): {str(e)}")
|
logger.error(f"Failed to sanitize event {event_id} ({event_data.get('summary', 'No summary')}): {str(e)}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Save to file
|
|
||||||
try:
|
try:
|
||||||
with open(file_path, "w") as file:
|
with open(file_path, "w") as file:
|
||||||
json.dump(sanitized_events, file, indent=4)
|
json.dump(sanitized_events, file, indent=4)
|
||||||
@ -142,7 +138,6 @@ def save_local_sync(file_path: str, events: EventsDict) -> None:
|
|||||||
logger.error(f"Event summary: {event_data.get('summary', 'No summary')}")
|
logger.error(f"Event summary: {event_data.get('summary', 'No summary')}")
|
||||||
logger.error(f"Error: {str(e)}")
|
logger.error(f"Error: {str(e)}")
|
||||||
|
|
||||||
# Debug field values
|
|
||||||
for key, value in event_data.items():
|
for key, value in event_data.items():
|
||||||
try:
|
try:
|
||||||
json.dumps({key: value})
|
json.dumps({key: value})
|
||||||
@ -161,7 +156,6 @@ def add_event_to_google(service: Resource, event: EventDict, calendar_id: str) -
|
|||||||
logger.info(f"Processing event: {event['summary']} (UID: {event['uid']})")
|
logger.info(f"Processing event: {event['summary']} (UID: {event['uid']})")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Prepare event data
|
|
||||||
google_event = {
|
google_event = {
|
||||||
"summary": event["summary"],
|
"summary": event["summary"],
|
||||||
"description": event.get("description", ""),
|
"description": event.get("description", ""),
|
||||||
@ -170,7 +164,6 @@ def add_event_to_google(service: Resource, event: EventDict, calendar_id: str) -
|
|||||||
"end": {"dateTime": event["end"], "timeZone": "UTC"},
|
"end": {"dateTime": event["end"], "timeZone": "UTC"},
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle recurring events
|
|
||||||
if event.get("rrule"):
|
if event.get("rrule"):
|
||||||
logger.debug(f"Processing recurring event rules for {event['summary']}")
|
logger.debug(f"Processing recurring event rules for {event['summary']}")
|
||||||
rrule_parts = []
|
rrule_parts = []
|
||||||
@ -181,13 +174,11 @@ def add_event_to_google(service: Resource, event: EventDict, calendar_id: str) -
|
|||||||
rrule_parts.append(f"{key}={value}")
|
rrule_parts.append(f"{key}={value}")
|
||||||
google_event["recurrence"] = [f"RRULE:{';'.join(rrule_parts)}"]
|
google_event["recurrence"] = [f"RRULE:{';'.join(rrule_parts)}"]
|
||||||
|
|
||||||
# Handle excluded dates
|
|
||||||
if event.get("exdate"):
|
if event.get("exdate"):
|
||||||
logger.debug(f"Processing {len(event['exdate'])} excluded dates")
|
logger.debug(f"Processing {len(event['exdate'])} excluded dates")
|
||||||
exdates = [f"EXDATE;TZID=UTC:{date}" for date in event["exdate"]]
|
exdates = [f"EXDATE;TZID=UTC:{date}" for date in event["exdate"]]
|
||||||
google_event["recurrence"].extend(exdates)
|
google_event["recurrence"].extend(exdates)
|
||||||
|
|
||||||
# Add event to Google Calendar
|
|
||||||
created_event = (
|
created_event = (
|
||||||
service.events()
|
service.events()
|
||||||
.insert(
|
.insert(
|
||||||
@ -200,7 +191,6 @@ def add_event_to_google(service: Resource, event: EventDict, calendar_id: str) -
|
|||||||
event["google_event_id"] = created_event["id"]
|
event["google_event_id"] = created_event["id"]
|
||||||
logger.info(f"Successfully created event: {event['summary']} (Google ID: {created_event['id']})")
|
logger.info(f"Successfully created event: {event['summary']} (Google ID: {created_event['id']})")
|
||||||
|
|
||||||
# Rate limiting
|
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -228,7 +218,6 @@ def delete_event_from_google(service: Resource, event: EventDict, calendar_id: s
|
|||||||
service.events().delete(calendarId=calendar_id, eventId=google_event_id).execute()
|
service.events().delete(calendarId=calendar_id, eventId=google_event_id).execute()
|
||||||
logger.info(f"Successfully deleted event: {event['summary']}")
|
logger.info(f"Successfully deleted event: {event['summary']}")
|
||||||
|
|
||||||
# Rate limiting
|
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user