@@ -2081,27 +2081,25 @@ def get_supported_filetypes_grouped(cls):
20812081 groupings [name ].sort ()
20822082 return groupings
20832083
2084- def _get_output_canvas (self , format ):
2085- """Return a canvas that is suitable for saving figures to a specified
2086- file format. If necessary, this function will switch to a registered
2087- backend that supports the format.
2084+ def _get_output_canvas (self , fmt ):
20882085 """
2089- method_name = 'print_%s' % format
2086+ Return a canvas suitable for saving figures to a specified file format.
20902087
2091- # check if this canvas supports the requested format
2088+ If necessary, this function will switch to a registered backend that
2089+ supports the format.
2090+ """
2091+ method_name = 'print_%s' % fmt
2092+ # Return the current canvas if it supports the requested format.
20922093 if hasattr (self , method_name ):
20932094 return self
2094-
2095- # check if there is a default canvas for the requested format
2096- canvas_class = get_registered_canvas_class (format )
2095+ # Return a default canvas for the requested format, if it exists.
2096+ canvas_class = get_registered_canvas_class (fmt )
20972097 if canvas_class :
20982098 return self .switch_backends (canvas_class )
2099-
2100- # else report error for unsupported format
2101- formats = sorted (self .get_supported_filetypes ())
2102- raise ValueError ('Format "%s" is not supported.\n '
2103- 'Supported formats: '
2104- '%s.' % (format , ', ' .join (formats )))
2099+ # Else report error for unsupported format.
2100+ raise ValueError (
2101+ "Format {!r} is not supported (supported formats: {})"
2102+ .format (fmt , ", " .join (sorted (self .get_supported_filetypes ()))))
21052103
21062104 def print_figure (self , filename , dpi = None , facecolor = None , edgecolor = None ,
21072105 orientation = 'portrait' , format = None , ** kwargs ):
0 commit comments