pattern3 / pattern

Goal: make Pattern compatible with Python 3.
http://www.clips.ua.ac.be/pages/pattern
BSD 3-Clause "New" or "Revised" License
59 stars 35 forks source link

Future stage1 python3 #4

Closed hayd closed 9 years ago

hayd commented 9 years ago

This is on the top of the previous travis PR. This converts some code to python 3 syntax (which works on python 2 with __future__), mostly this is print statements.

Python 3 is still not running, so I think next up ought to be imports (absolute don't seem to work in stage1 which is weird ?) see 3.4 build then comes the actual hard work: string / btyes (probably this needs six)...

Note the warning from the future --stage1:

RefactoringTool: Warnings/messages while refactoring:
RefactoringTool: ### In file examples/05-vector/07-slp.py ###
RefactoringTool: Line 101: Calls to builtin next() possibly shadowed by global binding
RefactoringTool: ### In file pattern/server/cherrypy/cherrypy/_cpcompat.py ###
RefactoringTool: Line 324: Calls to builtin next() possibly shadowed by global binding
RefactoringTool: ### In file pattern/server/cherrypy/cherrypy/_cpcompat.py ###
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid
RefactoringTool: Line 165: could not convert: from urllib2 import parse_http_list, parse_keqv_list
RefactoringTool: All module elements are invalid

I tried running stage 2 but tbh it was a mess.

Have a new error on test_crawler_delay not sure what it should be (https://travis-ci.org/hayd/pattern/jobs/39313093), again I think this needs looking at from someone who knows the codebase!

waylonflinn commented 9 years ago

Noted this in the merge commit. I'll put it here, too.

Files to remember to fix for later:

These appear to have placeholder variables.

hayd commented 9 years ago

FYI these (pdfminer and simplejson) are ripped out in the next PR (as dependancies) anyway, as is cherrypy. I think I've also fixed the urllib2 import complaint. Thanks for looking at/merging these!

waylonflinn commented 9 years ago

Awesome! Glad you did that.

Unbundling stuff that we don't need anymore or already has the compatibility we need as an external library seems like a good idea.

hayd commented 9 years ago

Discussed in the TODO list: https://github.com/pattern3/pattern/issues/5#issuecomment-60876270

I think the only remaining one is pywordnet (which is in nltk now, but that's a rather large dependancy)... Hopefully we're able to leave that as is (for now).. Also, the pdfminer is kinda flaky (both pdfminer and pdfminer3k export as pdfminer, so whichever was installed last wins!).