8000 Update deprecation message; use super(). · matplotlib/matplotlib@6ffb7bc · GitHub
[go: up one dir, main page]

Skip to content

Commit 6ffb7bc

Browse files
committed
Update deprecation message; use super().
1 parent f20472d commit 6ffb7bc

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/matplotlib/animation.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ def __getitem__(self, name):
7676
writers = MovieWriterRegistry()
7777

7878

79+
def _deprecation_message(name):
80+
return ('MovieWriter.%s interacts poorly with the saving context-manager '
81+
'and has been deprecated in 1.5. This method will be removed in '
82+
'1.6, please use `with writer.saving(...):` instead' % name)
83+
84+
7985
class MovieWriter(object):
8086
'''
8187
Base class for writing movies. Fundamentally, what a MovieWriter does is
@@ -159,8 +165,7 @@ def setup(self, *args, **kwargs):
159165
The DPI (or resolution) for the file. This controls the size
160166
in pixels of the resulting movie file.
161167
'''
162-
warnings.warn('setup interacts poorly with the saving context-manager',
163-
mplDeprecation)
168+
warnings.warn(_deprecation_message('setup'), mplDeprecation)
164169
self._setup(*args, **kwargs)
165170

166171
def _setup(self, fig, outfile, dpi):
@@ -204,9 +209,7 @@ def _run(self):
204209

205210
def finish(self):
206211
'Finish any processing for writing the movie.'
207-
warnings.warn(
208-
'finish interacts poorly with the saving context-manager',
209-
mplDeprecation)
212+
warnings.warn(_deprecation_message('finish'), mplDeprecation)
210213
self.cleanup()
211214

212215
def _finish(self):
@@ -242,9 +245,7 @@ def _args(self):
242245

243246
def cleanup(self):
244247
'Clean-up and collect the process used to write the movie file.'
245-
warnings.warn(
246-
'cleanup interacts poorly with the saving context-manager',
247-
mplDeprecation)
248+
warnings.warn(_deprecation_message('cleanup'), mplDeprecation)
248249
self._cleanup()
249250

250251
def _cleanup(self):
@@ -285,7 +286,7 @@ def isAvailable(cls):
285286
class FileMovieWriter(MovieWriter):
286287
'`MovieWriter` subclass that handles writing to a file.'
287288
def __init__(self, *args, **kwargs):
288-
MovieWriter.__init__(self, *args, **kwargs)
289+
super(FileMovieWriter, self).__init__(*args, **kwargs)
289290
self.frame_format = rcParams['animation.frame_format']
290291

291292
def _setup(self, fig, outfile, dpi, frame_prefix='_tmp', clear_temp=True,
@@ -390,7 +391,7 @@ def _finish(self):
390391
# Call run here now that all frame grabbing is done. All temp files
391392
# are available to be assembled.
392393
self._run()
393-
MovieWriter._finish(self)
394+
super(FileMovieWriter, self)._finish()
394395

395396
# Check error code for creating file here, since we just run
396397
# the process here, rather than having an open pipe.
@@ -400,7 +401,7 @@ def _finish(self):
400401
+ ' Try running with --verbose-debug')
401402

402403
def _cleanup(self):
403-
MovieWriter._cleanup(self)
404+
super(FileMovieWriter, self)._cleanup()
404405

405406
# Delete temporary files
406407
if self.clear_temp:

0 commit comments

Comments
 (0)
0