Skip to content

Commit

Permalink
add .path.newer to compare to files' mtime
Browse files Browse the repository at this point in the history
  • Loading branch information
olt committed Nov 7, 2009
1 parent 8162080 commit f3a1ecd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/modules/path.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Querying the filesystem
.. automethod:: path.atime()
.. automethod:: path.mtime()
.. automethod:: path.ctime()
.. automethod:: path.newer
.. automethod:: path.size()
.. automethod:: path.access
.. automethod:: path.stat
Expand Down
4 changes: 4 additions & 0 deletions scriptine/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,10 @@ def read_md5(self, hex=False):
atime = os.path.getatime
mtime = os.path.getmtime
ctime = os.path.getctime

def newer(self, other):
return self.mtime > other.mtime

size = os.path.getsize

if hasattr(os, 'access'):
Expand Down
4 changes: 4 additions & 0 deletions test/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ def testTouch(self):
fobj.close()

time.sleep(sleep_time)

f_new = d / 'test_new.txt'
f_new.touch()
self.assert_(f_new.newer(f))
t2 = time.time() - sleep_time / 2
f.touch()
t3 = time.time() + sleep_time / 2
Expand Down

0 comments on commit f3a1ecd

Please sign in to comment.