mirror of
https://github.com/b4tman/sync_ics2gcal
synced 2026-06-27 05:46:12 +03:00
Feature: setup (#15)
* add files for setup * ! package rename * move scripts * + setuptools_scm_git_archive * + fallback_version * + setuptools_scm_git_archive to setup.cfg * bdist_wheel universal * ignore build/ and .eggs/ * don't use version from setuptools_scm * Revert "don't use version from setuptools_scm" This reverts commit7ad0b4d3d8. * Revert "bdist_wheel universal" This reverts commit5027866b39. * no-local-version * +workflow: Upload Python Package
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import yaml
|
||||
|
||||
import dateutil.parser
|
||||
import datetime
|
||||
import logging
|
||||
import logging.config
|
||||
from . import (
|
||||
CalendarConverter,
|
||||
GoogleCalendarService,
|
||||
GoogleCalendar,
|
||||
CalendarSync
|
||||
)
|
||||
|
||||
def load_config():
|
||||
with open('config.yml', 'r', encoding='utf-8') as f:
|
||||
result = yaml.safe_load(f)
|
||||
return result
|
||||
|
||||
|
||||
def get_start_date(date_str):
|
||||
result = datetime.datetime(1,1,1)
|
||||
if 'now' == date_str:
|
||||
result = datetime.datetime.utcnow()
|
||||
else:
|
||||
result = dateutil.parser.parse(date_str)
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
config = load_config()
|
||||
|
||||
if 'logging' in config:
|
||||
logging.config.dictConfig(config['logging'])
|
||||
|
||||
calendarId = config['calendar']['google_id']
|
||||
ics_filepath = config['calendar']['source']
|
||||
srv_acc_file = config['service_account']
|
||||
|
||||
start = get_start_date(config['start_from'])
|
||||
|
||||
converter = CalendarConverter()
|
||||
converter.load(ics_filepath)
|
||||
|
||||
service = GoogleCalendarService.from_srv_acc_file(srv_acc_file)
|
||||
gcalendar = GoogleCalendar(service, calendarId)
|
||||
|
||||
sync = CalendarSync(gcalendar, converter)
|
||||
sync.prepare_sync(start)
|
||||
sync.apply()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user