Use 'open' instead of 'file'

since the later doesn't exist in python3
Don't run apt_pkg tests if apt_pkg is not installed
Use 'next(iter)' instead of 'iter.next()'

since the former works with python 2 and 3
Use 'in' instead of 'has_key'

which doesn't exit in Python3
Use loops instead of list comprehension

since 2to3 would recommend this anyway
Use print as function

to make python3 happy
Use python3 friendly file mode
Add tox.ini

To allow testing different python versions