I appreciate the docstring here, though it seems like a <b>lot</b> to squeeze into a single function IMHO.  Since you're input parameters for the whole thing are static, what do you think about using a simple class, w/ methods for each step?  Just an optional suggestion.