[tasque-list] Small python script to automatically add a list of tasks from a generic text file line by line to tasque...



Hope anyone else finds this useful.. "*****" needs to be replaced by the current user's username. It is very basic, and written in python.
#! /usr/bin/env python
# program takes a list of tasks line by line and inputs them as tasks in tasque
# you need to change "*****" to your user

import evolution
import sys
taskSource = evolution.ecal.open_calendar_source('file:///home/"*****"/.evolution/tasks/local/system', evolution.ecal.CAL_SOURCE_TYPE_TODO)
for c in taskSource.get_all_objects():
    print c.get_uid(), c.get_summary(), c.get_description()

if len(sys.argv) != 2: 
   print 'Usage: textfiletotasquelist.py <todolistfilename>' 
   sys.exit(1) 

count = 0
with open(sys.argv[1], 'r') as f:
    for line in f:
	count += 1
    	summary = line
    	description = repr(count)

    	obj = evolution.ecal.ECalComponent(evolution.ecal.CAL_COMPONENT_TODO)
    	obj.set_summary(summary)
   	obj.set_description(description)

	uid = taskSource.add_object(obj)
    	print "Added %s to %s (uid: %s)" % (obj, taskSource, uid)

print "Added %s tasks" (repr(count))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]