mpastell/Pweave — pull request #13 by g2boojum (2014-05-23 18:09:09+00:00)
Title: Minor changes

Thanks for the awesome package. I use Pweave a fair amount.

I'm now at the point where I can do a lot of my work using python3. I tend to do the real work in an ipython notebook (or often several different notebooks), but when it comes to writing reports I'd prefer to use Pweave. That has the potential to be a bit awkward, since Pweave is still python2 only.

I've fixed up the easy stuff (print functions, replacing has_key, and relative imports). With the relative imports I had to work around the import loop of pweb importing processors which imports pweb. I cheated, and passed a Pweb instance to the processor constructors, which could then be used to access the Pweb global variables. My guess is that it would be better to move those globals into the __init__.py file, since they are really package globals, but that's a more significant refactoring, and this is your baby! In any event, with these patches Pweave still works for me with python 2.7. I don't know if you need it to work with anything older, but I haven't tested it on 2.6 or 2.5.

What remains to be done is the unicode-by-default conversion. It doesn't look like it should be terribly difficult:

* `from __future__ import unicode_literals`
* use `io.open(file, 'r', encoding='utf-8')` to read in unicode
* For `== str` comparisons, use `== text_type` instead, where `text_type` is `str` for PY3 and `unicode` for PY2.
* Fix all the stuff that's still broken (obviously, I haven't finished this yet)

However, I'm probably not going to get to any of that anytime soon.

Best regards,
g2boojum