finance: Fixed making directories for explicit cachename #1834

Merged
merged 2 commits into from Mar 18, 2013

2 participants

@mgiuca-google

In finance.fetch_historical_yahoo, if an explicit cachename is supplied, the code still attempts to create a directory in the usual cache location (which is not necessary), and fails to create directories required for the supplied cache directory.

I have patched it so that it creates the necessary directories leading up to cachename.

As an aside, I also fixed it so that it explicitly closes the URL object opened by urlopen and uses the modern with style context managers.

mgiuca-google added some commits Mar 18, 2013
@mgiuca-google mgiuca-google finance.fetch_historical_yahoo: Create directories leading up to cach…
…ename.

Previously, if cachename was specified, it would create the directories to
cachedir instead, resulting in OSError if the directories leading up to
cachename were not specified.
ae3195f
@mgiuca-google mgiuca-google finance: Use context manager to close files.
Previously, the urllib object opened in fetch_historical_yahoo was not
explicitly closed.
87dff9c
@pelson
Matplotlib Developers member

👍 Thanks @mgiuca-google

@pelson pelson merged commit 0c417e0 into matplotlib:master Mar 18, 2013

1 check passed

Details default The Travis build passed
@mgiuca-google mgiuca-google deleted the mgiuca-google:finance-cachename branch Mar 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment