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
56104e70
Commit
56104e70
authored
Jun 13, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do the parsing of the todo strings in the TodoList.
parent
9bc283b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
16 deletions
+10
-16
TodoFile.py
TodoFile.py
+3
-8
TodoList.py
TodoList.py
+7
-8
No files found.
TodoFile.py
View file @
56104e70
...
...
@@ -2,8 +2,6 @@
This module deals with todo.txt files.
"""
import
TodoBase
class
TodoFile
(
object
):
"""
This class represents a todo.txt file, which can be read from or written
...
...
@@ -16,14 +14,11 @@ class TodoFile(object):
def
read
(
self
):
""" Reads the todo.txt file and returns a list of todo items. """
todos
=
[]
todofile
=
open
(
self
.
path
,
'r'
)
for
line
in
todofile
:
todos
.
append
(
TodoBase
.
TodoBase
(
line
))
todos
=
todofile
.
readlines
()
todofile
.
close
()
return
todos
def
write
(
self
,
p_todos
):
...
...
@@ -34,6 +29,6 @@ class TodoFile(object):
todofile
=
open
(
self
.
path
,
'w'
)
for
todo
in
p_todos
:
todofile
.
write
(
todo
.
src
+
"
\
n
"
)
todofile
.
write
(
"%s"
%
todo
)
todofile
.
close
()
TodoList.py
View file @
56104e70
...
...
@@ -2,6 +2,8 @@
A list of todo items.
"""
import
Todo
class
TodoList
(
object
):
"""
Provides operations for a todo list, such as adding items, removing them,
...
...
@@ -12,12 +14,13 @@ class TodoList(object):
"""
_todos
=
[]
def
__init__
(
self
,
todo
s
):
def
__init__
(
self
,
p_todostring
s
):
"""
Should be given a list of
Todo objects (already read and parsed from
file or standard input
.
Should be given a list of
strings, each element a single todo string.
The string will be parsed
.
"""
self
.
_todos
=
todos
for
string
in
p_todostrings
:
self
.
_todos
.
append
(
Todo
.
Todo
(
string
))
def
todo
(
self
,
p_number
):
"""
...
...
@@ -33,10 +36,6 @@ class TodoList(object):
return
result
def
todos
(
self
):
""" Returns the list of all todos. """
return
self
.
_todos
def
add
(
self
,
p_item
):
"""
Given a Todo(Base) item, add it to the end of the list.
...
...
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