Commit ea583df4 authored by erdnaxe's avatar erdnaxe 🎇

Add counter

parent d1d96d6a
......@@ -8,7 +8,7 @@ import caldav
import icalendar
import keyring
import yaml
from caldav.objects import dav, Calendar
from caldav.objects import dav
import filters
......@@ -31,7 +31,6 @@ class Configuration:
self.output_directory = '.'
def get_all_dav_components(self):
"""Return all components from the given calendars"""
components = []
......@@ -47,7 +46,8 @@ class Configuration:
def write_calendar_from_dav(f, dav_components, selected_groups):
"""Write a master calendar in file f using components from CalDav"""
for dav_component in dav_components:
for i, dav_component in enumerate(dav_components):
print('Traitement de {}/{}\r'.format(i, len(dav_components)), end='')
dav_component.load() # Download CalDav component
ical = icalendar.Event.from_ical( # Parse ical
ical_components = [c for c in ical.walk() if != 'VCALENDAR']
......@@ -67,10 +67,11 @@ if __name__ == '__main__':
logging.addLevelName(logging.WARNING, "\033[1;103mWARNING\033[1;0m")
logging.addLevelName(logging.ERROR, "\033[1;41mERROR\033[1;0m")
format='\033[1;90m%(asctime)s\033[1;0m %(levelname)s %(message)s')
format='\033[1;90m%(asctime)s\033[1;0m %(levelname)s %(message)s'
conf = Configuration('config.yml') # Load user configuration and calendars
dav_components = conf.get_all_dav_components() # Load components
with open(os.path.join(conf.output_directory, 'calendar.ics'), 'wb') as f: # Write master calendar
with open(os.path.join(conf.output_directory, 'calendar.ics'), 'wb') as f:
write_calendar_from_dav(f, dav_components, conf.selected_groups)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment