Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible with Python 3.7 #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ Supports
Guide
=====
1. Export from toodledo as XML
2. Install python and BeautifulSoup python module
2. Install python 3.7 and required modules:
- BeautifulSoup: `pip install BeautifulSoup`
- lxml: `pip install lxml`

On Windows, download from https://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml and then use `pip install <path to whl file>`.
3. Run toodledo_to_todoist.py <xml_filename>
4. Create a project in Todoist
5. From the project screen, click the gear in the top right corner
Expand Down
32 changes: 16 additions & 16 deletions toodledo_to_todoist.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ def export(self):

self.outFile = codecs.open('__text_tasks.txt','w+','utf-8')

print 'all folders...'
print('all folders...')
for folder in self.folders:
self.outFile.write( folder.name + '\n' )

indent = ' '
for (task_id, task) in folder.tasks.iteritems():
for (task_id, task) in folder.tasks.items():

#if task.folderMismatch:
# self.outFile.write( indent + ' '.join(('folder mismatch', task.id, task.title, '(', task.folder.name, ')', '\n')))
Expand Down Expand Up @@ -134,14 +134,14 @@ def export(self):
fileCount = 1

# only print top level items. parented items will be nested
for task in folder.tasks.itervalues():
for task in folder.tasks.values():
if task.parent == None:

nextCount = task.count()
if(nextCount + n > self.TASK_LIMIT):
# SPLIT THE FILE
n = 0
print "Warning: splitting tasks %s" % (folder.name)
print("Warning: splitting tasks %s" % (folder.name))
f.close
fileCount += 1
filename = '__%s__part_%d_[00000].txt' % (folder.name, fileCount)
Expand All @@ -152,7 +152,7 @@ def export(self):
n += nextCount

if self.count > self.TASK_LIMIT:
print "Error: project has more than %d items: %s (%d)" % (self.TASK_LIMIT, folder.name, self.count)
print("Error: project has more than %d items: %s (%d)" % (self.TASK_LIMIT, folder.name, self.count))

f.close()
f = None
Expand Down Expand Up @@ -213,12 +213,12 @@ def __init__(self):


def parseXML(self,filename):
print 'opening file:', filename
f = open(filename,'r')
xml = file.read(f)
print('opening file:', filename)
f = open(filename,'r', encoding='UTF-8')
xml = f.read()

print 'cooking soup...'
soup = BeautifulSoup(xml)
print('cooking soup...')
soup = BeautifulSoup(xml, 'lxml')

# HACK: test only the export test folder
if FOLDER_FILTER != None:
Expand All @@ -232,7 +232,7 @@ def parseXML(self,filename):
outf.write( soup.prettify() )
outf.close()

print 'parsing...'
print('parsing...')
for item in soup.find_all('item'):

# get the folder name, or replace with NOFOLDER for
Expand Down Expand Up @@ -300,9 +300,9 @@ def parseXML(self,filename):
self.tasks[task.id] = task

if len(sys.argv) < 2:
print ''
print ' Usage: python toodledo_to_todoist.py <xml_filename>'
print ''
print('')
print(' Usage: python toodledo_to_todoist.py <xml_filename>')
print('')
exit(1)

filename = sys.argv[1]
Expand All @@ -312,11 +312,11 @@ def parseXML(self,filename):
toodledo.parseXML(filename)

# export to a text file
print "exporting text..."
print("exporting text...")
textexport = TextExport(toodledo)
textexport.export()

# export for Todoist
print "exporting todoist..."
print("exporting todoist...")
todoist = TodoistExport(toodledo)
todoist.export()