degal/filesystem.py
changeset 93 d3872a673fbe
parent 85 7da934333469
child 95 3b00bd676fc9
--- a/degal/filesystem.py	Thu Jun 11 21:40:39 2009 +0300
+++ b/degal/filesystem.py	Thu Jun 11 21:46:09 2009 +0300
@@ -259,7 +259,9 @@
         """
             Returns the os.stat struct for this node.
             
-            If `soft` is given, returns None if this node doesn't exist
+            If `soft` is given, returns None if this node doesn't exist.
+
+            These stats are not cached.
 
             >>> Root('/').stat() is not None
             True
@@ -533,30 +535,32 @@
 
     def newer_than (self, file) :
         """
-            Tests if this file is newer than the given file.
-            
-            Returns True if it is, False if it isn't, or None if either file doesn't exist.
-
-            XXX: stat cache?
+            Returns True if both files exist, and this file is newer than the given file.
         """
 
-        stat_self = self.stat(soft=True)
-        stat_file = file.stat(soft=True)
+        self_stat = self.stat(soft=True)
+        file_stat = file.stat(soft=True)
 
-        if stat_self and stat_file :
-            return stat_self.st_mtime > stat_file.st_mtime
+        if self_stat and file_stat :
+            return self_stat.st_mtime > file_stat.st_mtime
 
         else :
             return None
     
     def older_than (self, file) :
         """
-            Tests if this file is older than the given file.
+            Returns True if both files exist, and this file is older than the given file.
+        """
+        
+        # mirror
+        ret = file.newer_than(self)
+        
+        # retain meaning of `None`, but invert True/False
+        if ret is None :
+            return ret
 
-            Opposite of newer_than.
-        """
-
-        return file.newer_than(self)
+        else :
+            return not ret
 
 class Directory (Node) :
     """
@@ -582,35 +586,6 @@
 
         return subdir
     
-    def test_subdir (self, name, create=False) :
-        """
-            Test for the presence of a subdir with the given name, and possibly return it, or None.
-
-            Returns a (exists, created, dir) tuple.
-            
-            XXX: ugly, not used
-        """
-
-        subdir = Directory(self, name=name)
-        
-        # already exists?
-        if subdir.is_dir() :
-            if create :
-                # create it!
-                subdir.mkdir()
-                
-                # didn't exist, did create
-                return True, True, subdir
-            
-            else :
-                # doesn't exist, don't create
-                return False, False, subdir
-
-        else :
-            # already existing
-            return True, False, subdir
-
-
     def subfile (self, name) :
         """
             Returns a File object representing the name underneath this dir