We'll start our refactoring by moving the existing PNG renderers into a new sub-package called renderers.png
. Create a new directory named png
within the renderers
directory, and move the title.py
, x_axis.py
, y_axis.py
, bar_series.py
and line_series.py
modules into this directory. Then, create an empty package initialization file, __init__.py
, inside the png
directory so that Python will recognize it as a package.
There is one minor change we are going to have to make to our existing PNG renderers: because each renderer module imports the constants.py
module using a relative import, we will need to update these modules so that they can still find the constants
module from their new position. To do this, edit each PNG renderer module in turn, and find the line that looks like the following:
from ..constants import *
Add an extra .
to each of these lines so that they look like this:
from ...constants import *
Our next task is to create a package to hold our PDF-format renderers...