[yt-svn] commit/yt: 3 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu May 9 08:47:42 PDT 2013


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/8e0f5a9ad390/
Changeset:   8e0f5a9ad390
Branch:      yt
User:        brittonsmith
Date:        2013-05-09 02:29:29
Summary:     Making mkdir_rec respect absolute paths.
Affected #:  1 file

diff -r cbdb1ea15403843d50f48ea55e09e934b58f2a6d -r 8e0f5a9ad390339a95510e322503ec0dd5c81c6f yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -613,7 +613,10 @@
     mkdir_rec("a/b/c")
     """
     dir_list = path.split("/")
-    basedir = "."
+    if path.startswith("/"):
+        basedir = ""
+    else:
+        basedir = "."
     for dir in dir_list:
         basedir = "%s/%s" % (basedir, dir)
         if not os.path.isdir(basedir): os.mkdir(basedir)


https://bitbucket.org/yt_analysis/yt/commits/40beb2f5266b/
Changeset:   40beb2f5266b
Branch:      yt
User:        brittonsmith
Date:        2013-05-09 17:33:15
Summary:     Replacing mkdir_rec with functionality from the os module and making it parallel safe.
Affected #:  2 files

diff -r 8e0f5a9ad390339a95510e322503ec0dd5c81c6f -r 40beb2f5266b247ad3386fad7690a4b6f06bb246 yt/analysis_modules/halo_finding/halo_objects.py
--- a/yt/analysis_modules/halo_finding/halo_objects.py
+++ b/yt/analysis_modules/halo_finding/halo_objects.py
@@ -2010,8 +2010,9 @@
         >>> halos.write_out("HopAnalysis.out")
         """
         # if path denoted in filename, assure path exists
-        if len(filename.split('/')) > 1:
-            mkdir_rec('/'.join(filename.split('/')[:-1]))
+        my_dir = os.path.dirname(filename)
+        if not os.path.exists(my_dir):
+            only_on_root(os.makedirs, my_dir)
 
         f = self.comm.write_on_root(filename)
         HaloList.write_out(self, f, ellipsoid_data)
@@ -2033,8 +2034,9 @@
         >>> halos.write_particle_lists_txt("halo-parts")
         """
         # if path denoted in prefix, assure path exists
-        if len(prefix.split('/')) > 1:
-            mkdir_rec('/'.join(prefix.split('/')[:-1]))
+        my_dir = os.path.dirname(prefix)
+        if not os.path.exists(my_dir):
+            only_on_root(os.makedirs, my_dir)
 
         f = self.comm.write_on_root("%s.txt" % prefix)
         HaloList.write_particle_lists_txt(self, prefix, fp=f)
@@ -2060,8 +2062,9 @@
         >>> halos.write_particle_lists("halo-parts")
         """
         # if path denoted in prefix, assure path exists
-        if len(prefix.split('/')) > 1:
-            mkdir_rec('/'.join(prefix.split('/')[:-1]))
+        my_dir = os.path.dirname(prefix)
+        if not os.path.exists(my_dir):
+            only_on_root(os.makedirs, my_dir)
 
         fn = "%s.h5" % self.comm.get_filename(prefix)
         f = h5py.File(fn, "w")
@@ -2097,8 +2100,9 @@
         >>> halos.dump("MyHalos")
         """
         # if path denoted in basename, assure path exists
-        if len(basename.split('/')) > 1:
-            mkdir_rec('/'.join(basename.split('/')[:-1]))
+        my_dir = os.path.dirname(basename)
+        if not os.path.exists(my_dir):
+            only_on_root(os.makedirs, my_dir)
 
         self.write_out("%s.out" % basename, ellipsoid_data)
         self.write_particle_lists(basename)

diff -r 8e0f5a9ad390339a95510e322503ec0dd5c81c6f -r 40beb2f5266b247ad3386fad7690a4b6f06bb246 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -602,21 +602,3 @@
 def get_image_suffix(name):
     suffix = os.path.splitext(name)[1]
     return suffix if suffix in ['.png', '.eps', '.ps', '.pdf'] else ''
-
-def mkdir_rec(path):
-    """
-    Recursive mkdir, so that if you mkdir two levels deep and the first 
-    one doesn't exist, it creates the first, and then any subsequent dirs.
-
-    Examples
-    --------
-    mkdir_rec("a/b/c")
-    """
-    dir_list = path.split("/")
-    if path.startswith("/"):
-        basedir = ""
-    else:
-        basedir = "."
-    for dir in dir_list:
-        basedir = "%s/%s" % (basedir, dir)
-        if not os.path.isdir(basedir): os.mkdir(basedir)


https://bitbucket.org/yt_analysis/yt/commits/c2bb4cf6028a/
Changeset:   c2bb4cf6028a
Branch:      yt
User:        MatthewTurk
Date:        2013-05-09 17:47:36
Summary:     Merged in brittonsmith/yt (pull request #497)

Replacing mkdir_rec with functionality from os module.
Affected #:  2 files

diff -r c27c264ed585c6406269737053dac0da51af195d -r c2bb4cf6028a62b8ae174a19f46803764cc6842d yt/analysis_modules/halo_finding/halo_objects.py
--- a/yt/analysis_modules/halo_finding/halo_objects.py
+++ b/yt/analysis_modules/halo_finding/halo_objects.py
@@ -2010,8 +2010,9 @@
         >>> halos.write_out("HopAnalysis.out")
         """
         # if path denoted in filename, assure path exists
-        if len(filename.split('/')) > 1:
-            mkdir_rec('/'.join(filename.split('/')[:-1]))
+        my_dir = os.path.dirname(filename)
+        if not os.path.exists(my_dir):
+            only_on_root(os.makedirs, my_dir)
 
         f = self.comm.write_on_root(filename)
         HaloList.write_out(self, f, ellipsoid_data)
@@ -2033,8 +2034,9 @@
         >>> halos.write_particle_lists_txt("halo-parts")
         """
         # if path denoted in prefix, assure path exists
-        if len(prefix.split('/')) > 1:
-            mkdir_rec('/'.join(prefix.split('/')[:-1]))
+        my_dir = os.path.dirname(prefix)
+        if not os.path.exists(my_dir):
+            only_on_root(os.makedirs, my_dir)
 
         f = self.comm.write_on_root("%s.txt" % prefix)
         HaloList.write_particle_lists_txt(self, prefix, fp=f)
@@ -2060,8 +2062,9 @@
         >>> halos.write_particle_lists("halo-parts")
         """
         # if path denoted in prefix, assure path exists
-        if len(prefix.split('/')) > 1:
-            mkdir_rec('/'.join(prefix.split('/')[:-1]))
+        my_dir = os.path.dirname(prefix)
+        if not os.path.exists(my_dir):
+            only_on_root(os.makedirs, my_dir)
 
         fn = "%s.h5" % self.comm.get_filename(prefix)
         f = h5py.File(fn, "w")
@@ -2097,8 +2100,9 @@
         >>> halos.dump("MyHalos")
         """
         # if path denoted in basename, assure path exists
-        if len(basename.split('/')) > 1:
-            mkdir_rec('/'.join(basename.split('/')[:-1]))
+        my_dir = os.path.dirname(basename)
+        if not os.path.exists(my_dir):
+            only_on_root(os.makedirs, my_dir)
 
         self.write_out("%s.out" % basename, ellipsoid_data)
         self.write_particle_lists(basename)

diff -r c27c264ed585c6406269737053dac0da51af195d -r c2bb4cf6028a62b8ae174a19f46803764cc6842d yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -602,18 +602,3 @@
 def get_image_suffix(name):
     suffix = os.path.splitext(name)[1]
     return suffix if suffix in ['.png', '.eps', '.ps', '.pdf'] else ''
-
-def mkdir_rec(path):
-    """
-    Recursive mkdir, so that if you mkdir two levels deep and the first 
-    one doesn't exist, it creates the first, and then any subsequent dirs.
-
-    Examples
-    --------
-    mkdir_rec("a/b/c")
-    """
-    dir_list = path.split("/")
-    basedir = "."
-    for dir in dir_list:
-        basedir = "%s/%s" % (basedir, dir)
-        if not os.path.isdir(basedir): os.mkdir(basedir)

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