acardona/CATMAID — pull request #800 by fzadow (2014-10-28 14:19:54+00:00)
Title: Fix imports

This reorganizes the import statements in many of the python files. The main goal is to avoid ~~lots of squiggly yellow lines in Eclipse~~ wildcard imports and "transitive" imports. After all, explicit is better then implicit [1] and makes it much easier to see where imports are actually coming from.

While at it, I corrected whitespace issues where there were 2 or 3 spaces instead of 4. (And also two typing errors in pieces of code that are probably never reached anyway)

All tests from the recently added test_common_apis [2] passed. Still, a brief check that every tool still works as expected is probably called for. (I don't have a good tracing setup here)

*Wildcard imports*:

from catmaid.models import *
from catmaid.control.authentication import *
from catmaid.control.common import *

can, for example in the case of log.py, be replaced with:

from catmaid.models import UserRole, Log
from catmaid.control.authentication import requires_user_role

*Transitive imports* are confusing. See this example:

from catmaid.control.authentication import requires_user_role, UserRole

This is not wrong, but relies on the authentication module importing UserRole [3]. UserRole is a model from catmaid.models, so that's where it should be imported from:

from catmaid.control.authentication import requires_user_role
from catmaid.models import UserRole

[1] http://legacy.python.org/dev/peps/pep-0020/
[2] acardona@edadf8c
[3] http://stackoverflow.com/questions/18722531