How anghkooey/uafm_ical works
Project type and purpose
• This is a standalone CLI/open‑source Python tool whose sole responsibility is to import events from a local ICS file into Google Calendar (either an existing calendar or one it creates). It also offers an “edit” mode to adjust event time zones before import.
File‐structure analysis
• Top‐level modules and files:
• main.py – the entry point for both ics_import and ics_edit functions
• requirements.txt – Python dependencies (gcsa, ics, pytz)
• .old/ – legacy code (csv.py), can be ignored in current design
• README.md, LICENSE, .gitignore – meta, no runtime impact
Key insights from README
• No database or UI server; pure script + external API.
Main components
a. Input source
• ICS file (downloaded from university link or provided manually)
b. Processor modules (in main.py)
• ICS Parser (uses ics library)
• Cleanup Engine (fetches and deletes outdated events > 30 days via gcsa)
• Import Engine (pushes new events via gcsa)
c. Authentication & Configuration
• OAuth2 Credential Store (~/.credentials/credentials.json + locally cached token)
• Optional config.py / parameters (calendar_id, ics_path, open_browser)
d. External system
• Google Calendar API (REST endpoints behind gcsa client)
e. Optional utilities
• Logging / Console output
• Error handling
Relationships and data flows
1. User invokes main.py with ics_import() or ics_edit()
2. Script loads OAuth2 credentials → authenticates to Google
3. If ics_edit:
• Read ICS file → parse events → apply time‑zone adjustments → write back or hand off to importer
Else (ics_import):
• If no calendar_id: call Google API to create new calendar “Study”
• Query calendar for events older than 30 days → delete via API
• Push events to Google Calendar
4. Console logs successes/errors
Architectural patterns & design principles
• Single‐responsibility: separate parsing, transformation, cleanup, and import logic
• External integration point: decoupled via gcsa client
• No persistent local state except cached OAuth2 token