示例#1
0
def main():
	from optparse import OptionParser;

	importFilename = "test.taskpaper"
	tpBlob = None
	debugprint('main function of exactDate')
	setIsoDates = True
	
	#Parse for cmd line values
	optParser = OptionParser()
	optParser.add_option("-i","--inputFilename",dest='filename',help="input file",type='string')

	
	debugprint('parsing')
	(option, arg) = optParser.parse_args();

	if(option.filename and option.filename != ""):
		importFilename = option.filename;
		debugprint('import filename')

	if(importFilename):
		tpBlob =  TaskFile(importFilename)

	if tpBlob and (setIsoDates):
		
		#sets ISO dates based on the passed day
		dueTasks = tpBlob.setIsoDates()
示例#2
0
def main():
	from optparse import OptionParser;

	importFilename = "test.taskpaper"
	tpBlob = None
	taskTextToFind = None	
	debugprint('main function of taskDone')
	
	
	#Parse for cmd line values
	optParser = OptionParser()
	optParser.add_option('-i','--inputFilename',dest='filename',help='input file',type='string')
	optParser.add_option('-t','--taskText',dest ='taskText', help='text_to_match',type='string')
	
	debugprint('parsing')
	(option, arg) = optParser.parse_args();

	if(option.filename and option.filename != ""):
		importFilename = option.filename;
		debugprint('import filename')
	if(option.taskText and option.taskText != ""):
		taskTextToFind = option.taskText


	#do something based on the settings
	if(importFilename):
		tpBlob =  TaskFile(importFilename)

	if tpBlob and (taskTextToFind is not None):
		debugprint('trying to match')
		matchedArray = tpBlob.findTaskByMatching(taskTextToFind)
		print ("== Found %02d Matches ==" % len(matchedArray))
#		dueItems = tpBlob.findDue(targetDatetime)
#		if(exportDueType == "stdout"):
#			print "Due Items:"
	else:
		print "No task to check-off has been specified"
示例#3
0
def main():
	from optparse import OptionParser;

	importFilename = "test.taskpaper"
	tpBlob = None
	debugprint('main function of taskRemover')
	taskToRemoveText = None;
	
	#Parse for cmd line values
	optParser = OptionParser()
	optParser.add_option("-i","--inputFilename",dest='filename',help="input file",type='string')
	optParser.add_option("-r","--removeTask",dest='taskName',help="Task name to remove ",type='string')

	
	debugprint('parsing')
	(option, arg) = optParser.parse_args();

	if(option.filename and option.filename != ""):
		importFilename = option.filename;
		debugprint('import filename')
	if(option.taskName and option.taskName != ""):
		taskToRemoveText = option.taskName


	if(importFilename):
		tpBlob =  TaskFile(importFilename)

	if tpBlob and taskToRemoveText:
		tpBlob.autobackup()
		taskMatches = tpBlob.findTaskByMatching(taskToRemoveText)
		if(len(taskMatches) == 0):
			print "No matches"
		elif(len(taskMatches) == 1):
			print 'Removing task %s' %taskMatches[0]
			tpBlob.removeExactMatch(taskMatches[0])
#			tpBlob.save()
#			if(gDebug == False):
#				tpBlog.deleteAutobackup()
		elif(len(taskMatches) > 1):
			print "Too many matches %d" % len(taskMatches)
			print "==== Matched Tasks ====\n"
			for task in taskMatches:
				print task
		
		#sets ISO dates based on the passed day
		dueTasks = tpBlob.setIsoDates()
示例#4
0
def main():
	""" Main statement for running this as a command line tool.
Command line options are:
-i inputFileName  : input file to parse for things due today
-o outputFileName  : output file to parse for things due today. 
If file exists it's appended to,if no file exsits it is created. If the output filename is stdout,
the output is written to the command line"""

	from optparse import OptionParser;

	importFilename = "test.taskpaper" #default read-from
	outputFilename = None
	tpBlob = None
	targetDatetime = datetime.now()
	dueTasks = None
	
	debugprint('main')
	
	
	#Setup parser for cmd line values
	optParser = OptionParser()
	optParser.add_option("-i","--inputFilename",dest='inFilename',help="input file",type='string')
	optParser.add_option("-o","--outputFilename",dest='outFilename',help="output file",type='string')
	#:TODO: make this magic
	#optParser.add_option("-t","--tag",dest='tags',help="tags",type='string')

	
	#do the a parse
	debugprint('parsing')
	(option, arg) = optParser.parse_args();

	#Load the parsed values to local variables
	if(option.inFilename and option.inFilename != ""):
		importFilename = option.inFilename;
		debugprint('import filename')
	if(option.outFilename and option.outFilename != ""):
		outputFilename = option.outFilename;
		debugprint('write to file %s' %outputFilename)


	#load the tasks and get them
	if(importFilename):
		tpBlob =  TaskFile(importFilename)
		if tpBlob :
			dueTasks = tpBlob.findDue(targetDatetime)

	#default to print-to-stdout
	if dueTasks and (not outputFilename):
		outputFilename == 'stdout'

	#print or write to file the output
	if(outputFilename == 'stdout'):
		for task in dueTasks:
			print str(task)
	elif (outputFilename):
		debugprint('writing to %s' %outputFilename)

		print "else\n"
		try :
			print "trying\n"
			#check for existance
			openOpts = 'w'
			if(os.path.isfile(outputFilename)):	
				debugprint('file %s exists. appending' %(outputFilename))				
				openOpts = 'a'
			debugprint('write to file %s with opts %s' %(outputFilename, openOpts))
			fh = open(outputFilename, openOpts)
			if(fh):
				dateStr = targetDatetime.isoformat()
				fh.write("Due Today:\n")
				fh.write("\t(Autogenerated on %s)\n" %dateStr)
				for task in dueTasks:
					try :
						fh.write(str(task))
						fh.write("\n");
					except IOError, e:
						stderr.write("File access Fail\n");
				fh.close()
				del(fh);
		except IOError, e:
			stderr.write("File access Fail\n");