summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-10-26 21:58:54 -0500
committerDan McGee <dan@archlinux.org>2011-01-22 11:14:42 -0600
commit8f711a7181e16dd8f2ab17946a48d131b58f4cf3 (patch)
treeb1b298ac00e3effe237f203c956308e64aaf3ede
parentff96649eeb09e4bd8774bc72a8dd1a4fa5a6846b (diff)
downloadpacman-8f711a7181e16dd8f2ab17946a48d131b58f4cf3.tar.xz
pactest: pylint changes for util
Signed-off-by: Dan McGee <dan@archlinux.org>
-rwxr-xr-xtest/pacman/util.py39
1 files changed, 10 insertions, 29 deletions
diff --git a/test/pacman/util.py b/test/pacman/util.py
index be155e95..652467ae 100755
--- a/test/pacman/util.py
+++ b/test/pacman/util.py
@@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import sys
import os
import hashlib
import stat
@@ -86,11 +85,8 @@ def mkfile(name, data = ""):
path = filename
else:
path = os.path.dirname(filename)
- try:
- if path and not os.path.isdir(path):
- os.makedirs(path, 0755)
- except:
- error("mkfile: could not create directory hierarchy '%s'" % path)
+ if path and not os.path.isdir(path):
+ os.makedirs(path, 0755)
if isdir:
return
@@ -154,21 +150,19 @@ def getmd5sum(filename):
fd = open(filename, "rb")
checksum = hashlib.md5()
while 1:
- block = fd.read(1048576)
+ block = fd.read(32 * 1024)
if not block:
break
checksum.update(block)
fd.close()
- digest = checksum.digest()
- return "%02x"*len(digest) % tuple(map(ord, digest))
+ return checksum.hexdigest()
def mkmd5sum(data):
"""
"""
checksum = hashlib.md5()
checksum.update("%s\n" % data)
- digest = checksum.digest()
- return "%02x"*len(digest) % tuple(map(ord, digest))
+ return checksum.hexdigest()
#
@@ -184,12 +178,6 @@ def getmtime(filename):
st = os.stat(filename)
return st[stat.ST_ATIME], st[stat.ST_MTIME], st[stat.ST_CTIME]
-def diffmtime(mt1, mt2):
- """ORE: TBD
- """
- return not mt1 == mt2
-
-
#
# Miscellaneous
#
@@ -210,18 +198,11 @@ def grep(filename, pattern):
return True
return False
-def mkdir(dir):
- if os.path.isdir(dir):
+def mkdir(path):
+ if os.path.isdir(path):
return
- elif os.path.isfile(dir):
- raise OSError("'%s' already exists and is not a directory" % dir)
- else:
- parent, thisdir = os.path.split(dir)
- if parent: mkdir(parent) #recurse to make all parents
- vprint("making dir %s" % thisdir)
- if thisdir: os.mkdir(dir)
-
-if __name__ == "__main__":
- pass
+ elif os.path.isfile(path):
+ raise OSError("'%s' already exists and is not a directory" % path)
+ os.makedirs(path, 0755)
# vim: set ts=4 sw=4 et: