Created
May 6, 2016 07:26
-
-
Save arwer13/2d7399a10f591b536d58d4fb0956c45c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is just a little draft with two rather obvious classes you might need to have at the beginning. | |
# | |
# | |
# At first glance I see three ways of implementing TodoEntry class, | |
# speaking about how field are stored in it | |
# It seams this class would not have much functionality, | |
# mostly just storing fields, marking entry completed autoinsresting 'completedData', | |
# something more, and not much data integrity checking, | |
# so I prefer the last variant, it's faster and seams more attractive (for me) to implement | |
class TodoEntry: | |
""" Some internal todo entry storage format, independent of todo system """ | |
def __init__(self): | |
self.data = { | |
'id': None, | |
'title': None, | |
'createdDate': None | |
} | |
# or shorter | |
self.data = {} | |
default_fields = ['id', 'title', 'createdData'] | |
for field in default_fields: | |
self.data[field] = None | |
def mark_done(self): | |
pass | |
def __str__(self): | |
# some to str convertion for developer's needs | |
pass | |
# OR | |
class TodoEntry: | |
def __init__(self): | |
self.id = None | |
self.title = None | |
self.createdData = None | |
# OR | |
class TodoEntry(dict): | |
pass | |
class TodoList: | |
def __init__(self): | |
self.entries = [] | |
def import_from_todo_txt(text): | |
pass | |
def import_from_orgmode(text): | |
pass | |
def export_to_todo_txt(): | |
pass | |
def export_to_orgmode(): | |
pass | |
if __name__ == '__main__': | |
todo = TodoList() | |
with open('todo.txt') as ff: | |
todo.import_from_todo_txt(ff.read()) | |
with open('todo.org', 'w') as ff: | |
ff.write(todo.export_to_orgmode()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment