summaryrefslogtreecommitdiff
path: root/test/pacman/pmfile.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-22 14:39:50 -0500
committerDan McGee <dan@archlinux.org>2011-06-24 01:36:48 -0500
commit3ace8ceb2343621ada4a72fc60e8e03a570fd389 (patch)
treea57b73f64624d9ec21ae4de89ac30170b0c7d7ef /test/pacman/pmfile.py
parent11d8418737d9d9c12584c6eed83bc6cea46ef3e9 (diff)
pactest: make pmfile a bit more pythonic
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'test/pacman/pmfile.py')
-rw-r--r--test/pacman/pmfile.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/test/pacman/pmfile.py b/test/pacman/pmfile.py
index bd03a24e..638b451e 100644
--- a/test/pacman/pmfile.py
+++ b/test/pacman/pmfile.py
@@ -17,38 +17,44 @@
import os
+import stat
import util
-class pmfile(object):
+class PacmanFile(object):
"""File object
"""
def __init__(self, root, name):
- self.name = name
self.root = root
+ self.name = name
self.filename = os.path.join(self.root, self.name)
self.checksum = util.getmd5sum(self.filename)
- self.mtime = util.getmtime(self.filename)
+ self.mtime = self.getmtime()
def __str__(self):
return "%s (%s / %lu)" % (self.name, self.checksum, self.mtime)
+ def getmtime(self):
+ if not os.path.exists(self.filename):
+ return None, None
+ statbuf = os.lstat(self.filename)
+ return (statbuf[stat.ST_MTIME], statbuf[stat.ST_CTIME])
+
def ismodified(self):
- """
- """
checksum = util.getmd5sum(self.filename)
- mtime = util.getmtime(self.filename)
+ mtime = self.getmtime()
util.vprint("\tismodified(%s)" % self.name)
util.vprint("\t\told: %s / %s" % (self.checksum, self.mtime))
util.vprint("\t\tnew: %s / %s" % (checksum, mtime))
if self.checksum != checksum \
- or (self.mtime[1], self.mtime[2]) != (mtime[1], mtime[2]):
- return 1
+ or self.mtime[0] != mtime[0] \
+ or self.mtime[1] != mtime[1]:
+ return True
- return 0
+ return False
# vim: set ts=4 sw=4 et: