[yt-svn] commit/yt: ngoldbaum: PlotWindow save now accepts paths to directories. Closes 639.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Aug 27 06:28:18 PDT 2013


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/eda3e58c7980/
Changeset:   eda3e58c7980
Branch:      yt
User:        ngoldbaum
Date:        2013-08-27 02:29:28
Summary:     PlotWindow save now accepts paths to directories. Closes 639.
Affected #:  1 file

diff -r 43940c6b177b36e0a69377f34cefad8ef6c6335c -r eda3e58c798068cdb94ecb0b2b172713fb52dd8f yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -29,6 +29,7 @@
 import matplotlib
 import cStringIO
 import types
+import os
 import __builtin__
 
 from matplotlib.mathtext import MathTextParser
@@ -1056,8 +1057,8 @@
         Parameters
         ----------
         name : string
-           the base of the filename.  If not set the filename of
-           the parameter file is used
+           The base of the filename.  If name is a directory or if name is not
+           set, the filename of the dataset is used.
         mpl_kwargs : dict
            A dict of keyword arguments to be passed to matplotlib.
 
@@ -1068,6 +1069,11 @@
         if mpl_kwargs is None: mpl_kwargs = {}
         if name is None:
             name = str(self.pf)
+        name = os.path.expanduser(name)
+        if name[-1] == os.sep and not os.path.isdir(name):
+            os.mkdir(name)
+        if os.path.isdir(name):
+            name = name + (os.sep if name[-1] != os.sep else '') + str(self.pf)
         suffix = get_image_suffix(name)
         if suffix != '':
             for k, v in self.plots.iteritems():

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list