Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
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
parent11d8418737d9d9c12584c6eed83bc6cea46ef3e9 (diff)
pactest: make pmfile a bit more pythonic
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--test/pacman/pmfile.py24
-rw-r--r--test/pacman/pmtest.py2
-rw-r--r--test/pacman/util.py13
3 files changed, 16 insertions, 23 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:
diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
index 64e56da7..105a841c 100644
--- a/test/pacman/pmtest.py
+++ b/test/pacman/pmtest.py
@@ -188,7 +188,7 @@ class pmtest(object):
for roots, dirs, files in os.walk(self.root):
for i in files:
filename = os.path.join(roots, i)
- f = pmfile.pmfile(self.root, filename.replace(self.root + "/", ""))
+ f = pmfile.PacmanFile(self.root, filename.replace(self.root + "/", ""))
self.files.append(f)
vprint("\t%s" % f.name)
diff --git a/test/pacman/util.py b/test/pacman/util.py
index bc8e3500..f971afd1 100644
--- a/test/pacman/util.py
+++ b/test/pacman/util.py
@@ -19,7 +19,6 @@
import os
import re
import hashlib
-import stat
# ALPM
@@ -157,18 +156,6 @@ def mkmd5sum(data):
#
-# Mtime helpers
-#
-
-def getmtime(filename):
- """
- """
- if not os.path.exists(filename):
- return None, None, None
- st = os.lstat(filename)
- return st[stat.ST_ATIME], st[stat.ST_MTIME], st[stat.ST_CTIME]
-
-#
# Miscellaneous
#