11"""Translate an ics file's events to a different timezone."""
22
3- < << << << HEAD
4- from optparse import OptionParser
5- import vobject
6-
7- try :
8- import PyICU
9- except :
10- PyICU = None
11-
12- == == == =
13- >> >> >> > master
143from datetime import datetime
154from optparse import OptionParser
165
176import pytz
187from dateutil import tz
198
20- from vobject import base , icalendar
9+ import vobject
2110
2211version = "0.1"
2312
@@ -57,7 +46,7 @@ def convert_events(utc_only, args):
5746 _tzone = args [1 ] if len (args ) > 1 else 'UTC'
5847
5948 print ("... Reading {}" .format (ics_file ))
60- cal = base .readOne (open (ics_file ))
49+ cal = vobject .readOne (open (ics_file ))
6150 change_tz (cal , new_timezone = tz .gettz (_tzone ), default = tz .gettz ('UTC' ), utc_only = utc_only )
6251
6352 out_name = "{}.converted" .format (ics_file )
@@ -74,32 +63,7 @@ def main():
7463 if options .list :
7564 show_timezones ()
7665 elif args :
77- < << << << HEAD
78- utc_only = options .utc
79- if utc_only :
80- which = "only UTC"
81- else :
82- which = "all"
83- print ("Converting {0!s} events" .format (which ))
84- ics_file = args [0 ]
85- if len (args ) > 1 :
86- timezone = PyICU .ICUtzinfo .getInstance (args [1 ])
87- else :
88- timezone = PyICU .ICUtzinfo .default
89- print ("... Reading {0!s}" .format (ics_file ))
90- cal = vobject .readOne (open (ics_file ))
91- change_tz (cal , timezone , PyICU .ICUtzinfo .default , utc_only )
92-
93- out_name = ics_file + '.converted'
94- print ("... Writing {0!s}" .format (out_name ))
95-
96- with open (out_name , 'wb' ) as out :
97- cal .serialize (out )
98-
99- print ("Done" )
100- == == == =
10166 convert_events (utc_only = options .utc , args = args )
102- >> >> >> > master
10367
10468
10569def get_options ():
0 commit comments