8000 Use tempfile.mkdtemp for animation.FileMovieWriter. by anntzer · Pull Request #3536 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Use tempfile.mkdtemp for animation.FileMovieWriter. #3536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix silly typo.
  • Loading branch information
anntzer committed Sep 19, 2014
commit f20472dae26b9ed715475bcca86300fe6148b30f
18 changes: 10 additions & 8 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def setup(self, *args, **kwargs):
mplDeprecation)
self._setup(*args, **kwargs)

def _setup(self, outfile, dpi):
def _setup(self, fig, outfile, dpi):
self.outfile = outfile
self.fig = fig
self.dpi = dpi
Expand Down Expand Up @@ -204,8 +204,9 @@ def _run(self):

def finish(self):
'Finish any processing for writing the movie.'
warnings.warn('finish interacts poorly with the saving context-manager',
mplDeprecation)
warnings.warn(
'finish interacts poorly with the saving context-manager',
mplDeprecation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this even valid? Doesn't there have to at least be a "pass" statement? Plus, I don't like the idea of a function that is documented to finish something actually not do anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is valid(!) Moreover it is not that easy to write code with the proper behavior without making this change (because in case of failure you want to call cleanup without calling finish).
In my opinion the finish and cleanup methods should be private anyways. I can also rename the new ones _finish and _cleanup, have the saving contextmanager just call the private methods, and deprecate the wrappers finish and cleanup which keep the previous behavior... What do you think?

self.cleanup()

def _finish(self):
Expand Down Expand Up @@ -241,8 +242,9 @@ def _args(self):

def cleanup(self):
'Clean-up and collect the process used to write the movie file.'
warnings.warn('cleanup interacts poorly with the saving context-manager',
mplDeprecation)
warnings.warn(
'cleanup interacts poorly with the saving context-manager',
mplDeprecation)
self._cleanup()

def _cleanup(self):
Expand Down Expand Up @@ -287,7 +289,7 @@ def __init__(self, *args, **kwargs):
self.frame_format = rcParams['animation.frame_format']

def _setup(self, fig, outfile, dpi, frame_prefix='_tmp', clear_temp=True,
tmpdir=None):
tmpdir=None):
'''
Perform setup for writing the movie file.

Expand Down Expand Up @@ -400,9 +402,9 @@ def _finish(self):
def _cleanup(self):
MovieWriter._cleanup(self)

#Delete temporary files
# Delete temporary files
if self.clear_temp:
if self._temp_names is None: # tmpdir created with mkdtemp
if self._temp_names is None: # tmpdir created with mkdtemp
verbose.report(
'MovieWriter: clearing temporary fnames=%s' % self._tmpdir,
level='debug')
Expand Down
0