Commit 738b1a04 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Add convenience function to check priority validity.

parent 6638beb1
import re
import Command
from Utils import convert_todo_number
from Utils import convert_todo_number, is_valid_priority
class PriorityCommand(Command.Command):
def __init__(self, p_args, p_todolist):
......@@ -11,7 +9,7 @@ class PriorityCommand(Command.Command):
self.priority = self.argument(1)
def execute(self):
if re.match('^[A-Z]$', self.priority):
if is_valid_priority(self.priority):
old_priority = self.todo.priority()
self.todolist.set_priority(self.number, self.priority)
......
......@@ -6,6 +6,7 @@ from datetime import date
import re
import TodoParser
from Utils import is_valid_priority
class TodoBase(object):
"""
......@@ -116,7 +117,7 @@ class TodoBase(object):
"""
if not self.is_completed() and \
(p_priority == None or re.match('^[A-Z]$', p_priority)):
(p_priority == None or is_valid_priority(p_priority)):
self.fields['priority'] = p_priority
......
......@@ -35,3 +35,5 @@ def convert_todo_number(p_number):
return p_number
def is_valid_priority(p_priority):
return re.match(r'^[A-Z]$', p_priority) != None
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