1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-01-08 12:28:00 -05:00

pactest: pylint changes for pmdb

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2010-10-26 22:08:52 -05:00
parent 8f711a7181
commit 2a3b5e40bc

View File

@ -17,13 +17,10 @@
import os import os
import tempfile
import shutil
import tarfile import tarfile
import pmpkg import pmpkg
from util import * import util
def _mkfilelist(files): def _mkfilelist(files):
"""Generate a list of files from the list supplied as an argument. """Generate a list of files from the list supplied as an argument.
@ -38,19 +35,19 @@ def _mkfilelist(files):
usr/local/bin/ usr/local/bin/
usr/local/bin/dummy usr/local/bin/dummy
""" """
file_list = set() file_set = set()
for f in files: for f in files:
dir = getfilename(f) name = util.getfilename(f)
file_list.add(dir) file_set.add(name)
while "/" in dir: while "/" in name:
[dir, tmp] = dir.rsplit("/", 1) [name, tmp] = name.rsplit("/", 1)
file_list.add(dir + "/") file_set.add(name + "/")
return sorted(file_list) return sorted(file_set)
def _mkbackuplist(backup): def _mkbackuplist(backup):
""" """
""" """
return ["%s\t%s" % (getfilename(i), mkmd5sum(i)) for i in backup] return ["%s\t%s" % (util.getfilename(i), util.mkmd5sum(i)) for i in backup]
def _getsection(fd): def _getsection(fd):
""" """
@ -84,10 +81,10 @@ class pmdb:
self.pkgs = [] self.pkgs = []
self.option = {} self.option = {}
if self.treename == "local": if self.treename == "local":
self.dbdir = os.path.join(root, PM_DBPATH, treename) self.dbdir = os.path.join(root, util.PM_DBPATH, treename)
else: else:
self.dbdir = os.path.join(root, PM_SYNCDBPATH, treename) self.dbdir = os.path.join(root, util.PM_SYNCDBPATH, treename)
self.dbfile = os.path.join(root, PM_SYNCDBPATH, treename + ".db") self.dbfile = os.path.join(root, util.PM_SYNCDBPATH, treename + ".db")
def __str__(self): def __str__(self):
return "%s" % self.treename return "%s" % self.treename
@ -102,7 +99,6 @@ class pmdb:
def db_read(self, name): def db_read(self, name):
""" """
""" """
path = self.dbdir path = self.dbdir
if not os.path.isdir(path): if not os.path.isdir(path):
return None return None
@ -165,8 +161,8 @@ class pmdb:
elif line == "%PROVIDES%": elif line == "%PROVIDES%":
pkg.provides = _getsection(fd) pkg.provides = _getsection(fd)
fd.close() fd.close()
pkg.checksum["desc"] = getmd5sum(filename) pkg.checksum["desc"] = util.getmd5sum(filename)
pkg.mtime["desc"] = getmtime(filename) pkg.mtime["desc"] = util.getmtime(filename)
# files # files
filename = os.path.join(path, "files") filename = os.path.join(path, "files")
@ -187,14 +183,14 @@ class pmdb:
if line == "%BACKUP%": if line == "%BACKUP%":
pkg.backup = _getsection(fd) pkg.backup = _getsection(fd)
fd.close() fd.close()
pkg.checksum["files"] = getmd5sum(filename) pkg.checksum["files"] = util.getmd5sum(filename)
pkg.mtime["files"] = getmtime(filename) pkg.mtime["files"] = util.getmtime(filename)
# install # install
filename = os.path.join(path, "install") filename = os.path.join(path, "install")
if os.path.isfile(filename): if os.path.isfile(filename):
pkg.checksum["install"] = getmd5sum(filename) pkg.checksum["install"] = util.getmd5sum(filename)
pkg.mtime["install"] = getmtime(filename) pkg.mtime["install"] = util.getmtime(filename)
return pkg return pkg
@ -204,9 +200,8 @@ class pmdb:
def db_write(self, pkg): def db_write(self, pkg):
""" """
""" """
path = os.path.join(self.dbdir, pkg.fullname()) path = os.path.join(self.dbdir, pkg.fullname())
mkdir(path) util.mkdir(path)
# desc # desc
# for local db entries: name, version, desc, groups, url, license, # for local db entries: name, version, desc, groups, url, license,
@ -256,9 +251,9 @@ class pmdb:
if data: if data:
data.append("") data.append("")
filename = os.path.join(path, "desc") filename = os.path.join(path, "desc")
mkfile(filename, "\n".join(data)) util.mkfile(filename, "\n".join(data))
pkg.checksum["desc"] = getmd5sum(filename) pkg.checksum["desc"] = util.getmd5sum(filename)
pkg.mtime["desc"] = getmtime(filename) pkg.mtime["desc"] = util.getmtime(filename)
# files # files
# for local entries, fields are: files, backup # for local entries, fields are: files, backup
@ -272,9 +267,9 @@ class pmdb:
if data: if data:
data.append("") data.append("")
filename = os.path.join(path, "files") filename = os.path.join(path, "files")
mkfile(filename, "\n".join(data)) util.mkfile(filename, "\n".join(data))
pkg.checksum["files"] = getmd5sum(filename) pkg.checksum["files"] = util.getmd5sum(filename)
pkg.mtime["files"] = getmtime(filename) pkg.mtime["files"] = util.getmtime(filename)
# install # install
if self.treename == "local": if self.treename == "local":
@ -284,9 +279,9 @@ class pmdb:
empty = 0 empty = 0
if not empty: if not empty:
filename = os.path.join(path, "install") filename = os.path.join(path, "install")
mkinstallfile(filename, pkg.install) util.mkinstallfile(filename, pkg.install)
pkg.checksum["install"] = getmd5sum(filename) pkg.checksum["install"] = util.getmd5sum(filename)
pkg.mtime["install"] = getmtime(filename) pkg.mtime["install"] = util.getmtime(filename)
def gensync(self): def gensync(self):
""" """
@ -315,8 +310,8 @@ class pmdb:
if not oldpkg: if not oldpkg:
return 0 return 0
vprint("\toldpkg.checksum : %s" % oldpkg.checksum) util.vprint("\toldpkg.checksum : %s" % oldpkg.checksum)
vprint("\toldpkg.mtime : %s" % oldpkg.mtime) util.vprint("\toldpkg.mtime : %s" % oldpkg.mtime)
for key in pkg.mtime.keys(): for key in pkg.mtime.keys():
if key == "install" \ if key == "install" \