[yt-svn] commit/yt: MatthewTurk: Adding a catch for finding no filenames in call to

Bitbucket commits-noreply at bitbucket.org
Fri Oct 19 16:03:34 PDT 2012


1 new commit in yt:


https://bitbucket.org/yt_analysis/yt/changeset/2bc7ed50b2bb/
changeset:   2bc7ed50b2bb
branch:      yt
user:        MatthewTurk
date:        2012-10-20 00:59:17
summary:     Adding a catch for finding no filenames in call to
TimeSeriesData.from_filenames.  Only applies if TimeSeriesData is called with a
glob matching pattern.  Closes #454 .
affected #:  2 files

diff -r 6bbad7ce654ec4f2cdd21c5262160645c2255aa5 -r 2bc7ed50b2bb9533873967c29c095f0852c0e1b5 yt/data_objects/time_series.py
--- a/yt/data_objects/time_series.py
+++ b/yt/data_objects/time_series.py
@@ -258,8 +258,11 @@
 
         """
         if isinstance(filenames, types.StringTypes):
+            pattern = filenames
             filenames = glob.glob(filenames)
             filenames.sort()
+            if len(filenames) == 0:
+                raise YTNoFilenamesMatchPattern(pattern)
         obj = cls(filenames[:], parallel = parallel)
         return obj
 


diff -r 6bbad7ce654ec4f2cdd21c5262160645c2255aa5 -r 2bc7ed50b2bb9533873967c29c095f0852c0e1b5 yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -146,3 +146,11 @@
     def __str__(self):
         return "You must create an API key before uploading.  See " + \
                "https://data.yt-project.org/getting_started.html"
+
+class YTNoFilenamesMatchPattern(YTException):
+    def __init__(self, pattern):
+        self.pattern = pattern
+
+    def __str__(self):
+        return "No filenames were found to match the pattern: " + \
+               "'%s'" % (self.pattern)

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