From defa89d34e8b98063a25af18f2ae71c0ea4019e2 Mon Sep 17 00:00:00 2001 From: Simon Nattress Date: Sat, 29 Nov 2014 13:13:49 -0800 Subject: [PATCH] Fix duplicate file name extension If a filename extension and a format are specified with the same string, we create a file with a double file extension. Ie: ```javascript py.image.save_as(figure, 'filename2.png', 'png') ``` This will produce a file named filename2.png.png. When ext and format are both present, the fix will only append format to the filename if the format is different from ext. Ie: ```javascript py.image.save_as(figure, 'filename2.png', 'pdf') ``` This will create filename2.png.pdf. --- plotly/plotly/plotly.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/plotly/plotly.py b/plotly/plotly/plotly.py index 0e374b518e1..04fa7fc6b3c 100644 --- a/plotly/plotly/plotly.py +++ b/plotly/plotly/plotly.py @@ -660,7 +660,7 @@ def save_as(cls, figure_or_data, filename, format=None, width=None, height=None) format = ext[1:] elif not ext and format: filename += '.'+format - else: + elif ext[1:].lower() != format.lower(): filename += '.'+format img = cls.get(figure_or_data, format, width, height)