@@ -2084,27 +2084,25 @@ def get_supported_filetypes_grouped(cls):
20842084 groupings [name ].sort ()
20852085 return groupings
20862086
2087- def _get_output_canvas (self , format ):
2088- """Return a canvas that is suitable for saving figures to a specified
2089- file format. If necessary, this function will switch to a registered
2090- backend that supports the format.
2087+ def _get_output_canvas (self , fmt ):
20912088 """
2092- method_name = 'print_%s' % format
2089+ Return a canvas suitable for saving figures to a specified file format.
20932090
2094- # check if this canvas supports the requested format
2091+ If necessary, this function will switch to a registered backend that
2092+ supports the format.
2093+ """
2094+ method_name = 'print_%s' % fmt
2095+ # Return the current canvas if it supports the requested format.
20952096 if hasattr (self , method_name ):
20962097 return self
2097-
2098- # check if there is a default canvas for the requested format
2099- canvas_class = get_registered_canvas_class (format )
2098+ # Return a default canvas for the requested format, if it exists.
2099+ canvas_class = get_registered_canvas_class (fmt )
21002100 if canvas_class :
21012101 return self .switch_backends (canvas_class )
2102-
2103- # else report error for unsupported format
2104- formats = sorted (self .get_supported_filetypes ())
2105- raise ValueError ('Format "%s" is not supported.\n '
2106- 'Supported formats: '
2107- '%s.' % (format , ', ' .join (formats )))
2102+ # Else report error for unsupported format.
2103+ raise ValueError (
2104+ "Format {!r} is not supported (supported formats: {})"
2105+ .format (fmt , ", " .join (sorted (self .get_supported_filetypes ()))))
21082106
21092107 def print_figure (self , filename , dpi = None , facecolor = None , edgecolor = None ,
21102108 orientation = 'portrait' , format = None , ** kwargs ):
0 commit comments