Commit 6638beb1 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Move priority to its own Command class.

parent b5a3dfea
#!/usr/bin/env python
""" Entry file for the Python todo.txt CLI. """
import re
import sys
from AddCommand import AddCommand
from AppendCommand import AppendCommand
from DepCommand import DepCommand
from DoCommand import DoCommand
import Config
from DoCommand import DoCommand
import Filter
from PrettyPrinter import pretty_print
from PriorityCommand import PriorityCommand
import Sorter
import TodoFile
import TodoList
......@@ -82,21 +82,8 @@ class Application(object): # TODO: rename to CLIApplication
command.execute()
def pri(self):
number = convert_todo_number(argument(2))
priority = argument(3)
if re.match('^[A-Z]$', priority):
todo = self.todolist.todo(number)
if todo:
old_priority = todo.priority()
todo.set_priority(priority)
print "Priority changed from %s to %s" \
% (old_priority, priority)
self.print_todo(number)
else:
error("Invalid priority given.")
command = PriorityCommand(arguments(), self.todolist)
command.execute()
def list(self):
sorter = Sorter.Sorter(Config.SORT_STRING)
......
import re
import Command
from Utils import convert_todo_number
class PriorityCommand(Command.Command):
def __init__(self, p_args, p_todolist):
super(PriorityCommand, self).__init__(p_args, p_todolist)
self.number = convert_todo_number(self.argument(0))
self.todo = self.todolist.todo(self.number)
self.priority = self.argument(1)
def execute(self):
if re.match('^[A-Z]$', self.priority):
old_priority = self.todo.priority()
self.todolist.set_priority(self.number, self.priority)
print "Priority changed from %s to %s" \
% (old_priority, self.priority) # FIXME
# self.print_todo(number) # FIXME
else:
# error("Invalid priority given.") # TODO
pass
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