Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
6638beb1
Commit
6638beb1
authored
Oct 09, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move priority to its own Command class.
parent
b5a3dfea
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
17 deletions
+27
-17
Main.py
Main.py
+4
-17
PriorityCommand.py
PriorityCommand.py
+23
-0
No files found.
Main.py
View file @
6638beb1
#!/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
)
...
...
PriorityCommand.py
0 → 100644
View file @
6638beb1
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment