Hi Jared,
> I'd love to learn vobject enough to do this myself, but seems like a
> 15-minute hack for someone that already knew what they were doing with that
> api.
Said 15 minute hack attached.
Sincerely,
Jeffrey
from optparse import OptionParser
import vobject
import os
import codecs
def main():
options = getOptions()
if options:
ics_file, output_dir = options
input_calendar = vobject.readOne(file(ics_file))
try:
os.mkdir(output_dir)
except OSError:
pass
for event in input_calendar.vevent_list:
# many uids include dashes, fix those
uid = event.uid.value.replace('-', '_')
out_filename = os.path.join(output_dir, uid+'.ics')
print "serializing", out_filename
out_file = codecs.open(out_filename, 'w', 'utf-8')
new_cal = vobject.iCalendar()
new_cal.vevent = event
new_cal.serialize(out_file)
out_file.close()
def getOptions():
##### Configuration options #####
usage = "usage: %prog ics_file output_dir"
parser = OptionParser(usage=usage)
parser.set_description(
"split_ics will split an ics file containing multiple events into "
"several files in the given output_dir")
(cmdline_options, args) = parser.parse_args()
if len(args) < 2:
print "error: too few arguments given"
print
print parser.format_help()
return False
return args
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print "Aborted"
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Open Source Applications Foundation "chandler-dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/chandler-dev