1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

pactest: pylint changes for util

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2010-10-26 21:58:54 -05:00
parent ff96649eeb
commit 8f711a7181

View File

@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import os import os
import hashlib import hashlib
import stat import stat
@ -86,11 +85,8 @@ def mkfile(name, data = ""):
path = filename path = filename
else: else:
path = os.path.dirname(filename) path = os.path.dirname(filename)
try:
if path and not os.path.isdir(path): if path and not os.path.isdir(path):
os.makedirs(path, 0755) os.makedirs(path, 0755)
except:
error("mkfile: could not create directory hierarchy '%s'" % path)
if isdir: if isdir:
return return
@ -154,21 +150,19 @@ def getmd5sum(filename):
fd = open(filename, "rb") fd = open(filename, "rb")
checksum = hashlib.md5() checksum = hashlib.md5()
while 1: while 1:
block = fd.read(1048576) block = fd.read(32 * 1024)
if not block: if not block:
break break
checksum.update(block) checksum.update(block)
fd.close() fd.close()
digest = checksum.digest() return checksum.hexdigest()
return "%02x"*len(digest) % tuple(map(ord, digest))
def mkmd5sum(data): def mkmd5sum(data):
""" """
""" """
checksum = hashlib.md5() checksum = hashlib.md5()
checksum.update("%s\n" % data) checksum.update("%s\n" % data)
digest = checksum.digest() return checksum.hexdigest()
return "%02x"*len(digest) % tuple(map(ord, digest))
# #
@ -184,12 +178,6 @@ def getmtime(filename):
st = os.stat(filename) st = os.stat(filename)
return st[stat.ST_ATIME], st[stat.ST_MTIME], st[stat.ST_CTIME] return st[stat.ST_ATIME], st[stat.ST_MTIME], st[stat.ST_CTIME]
def diffmtime(mt1, mt2):
"""ORE: TBD
"""
return not mt1 == mt2
# #
# Miscellaneous # Miscellaneous
# #
@ -210,18 +198,11 @@ def grep(filename, pattern):
return True return True
return False return False
def mkdir(dir): def mkdir(path):
if os.path.isdir(dir): if os.path.isdir(path):
return return
elif os.path.isfile(dir): elif os.path.isfile(path):
raise OSError("'%s' already exists and is not a directory" % dir) raise OSError("'%s' already exists and is not a directory" % path)
else: os.makedirs(path, 0755)
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
# vim: set ts=4 sw=4 et: # vim: set ts=4 sw=4 et: