diff options
Diffstat (limited to 'test/pacman/pmfile.py')
-rw-r--r-- | test/pacman/pmfile.py | 24 |
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: |