diff options
author | Dan McGee <dan@archlinux.org> | 2011-06-22 22:11:56 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-06-24 08:36:48 +0200 |
commit | 63335859d1b1c77222c31229fe499c031a76361d (patch) | |
tree | 907754a7edd4e8c18e1b518d78b5700459c57e0a | |
parent | f15cce1d414cb497ee804d50c25c6d3d717240bd (diff) | |
download | pacman-63335859d1b1c77222c31229fe499c031a76361d.tar.gz pacman-63335859d1b1c77222c31229fe499c031a76361d.tar.xz |
pactest: refactor install file creation
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | test/pacman/pmdb.py | 6 | ||||
-rw-r--r-- | test/pacman/pmpkg.py | 10 | ||||
-rw-r--r-- | test/pacman/util.py | 8 |
3 files changed, 10 insertions, 14 deletions
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py index 72f6dc45..d5f9e618 100644 --- a/test/pacman/pmdb.py +++ b/test/pacman/pmdb.py @@ -72,15 +72,11 @@ class pmdb(object): return "Never" def getpkg(self, name): - """ - """ for pkg in self.pkgs: if name == pkg.name: return pkg def db_read(self, name): - """ - """ path = self.dbdir if not os.path.isdir(path): return None @@ -226,7 +222,7 @@ class pmdb(object): if any(pkg.install.values()): filename = os.path.join(path, "install") - util.mkinstallfile(filename, pkg.install) + util.mkfile(filename, pkg.installfile()) def gensync(self): if not self.dbfile: diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py index 43edd8f0..e9721310 100644 --- a/test/pacman/pmpkg.py +++ b/test/pacman/pmpkg.py @@ -147,7 +147,7 @@ class pmpkg(object): # .INSTALL if any(self.install.values()): - util.mkinstallfile(".INSTALL", self.install) + util.mkfile(".INSTALL", self.installfile()) # safely create the dir util.mkdir(os.path.dirname(self.path)) @@ -186,4 +186,12 @@ class pmpkg(object): def local_backup_entries(self): return ["%s\t%s" % (self.parse_filename(i), util.mkmd5sum(i)) for i in self.backup] + def installfile(self): + data = [] + for key, value in self.install.iteritems(): + if value: + data.append("%s() {\n%s\n}" % (key, value)) + + return "\n".join(data) + # vim: set ts=4 sw=4 et: diff --git a/test/pacman/util.py b/test/pacman/util.py index 5e8d3dbc..0cf0eabe 100644 --- a/test/pacman/util.py +++ b/test/pacman/util.py @@ -91,14 +91,6 @@ def mkfile(name, data = ""): if setperms: os.chmod(filename, int(perms, 8)) -def mkinstallfile(filename, install): - data = [] - for key, value in install.iteritems(): - if value: - data.append("%s() {\n%s\n}" % (key, value)) - - mkfile(filename, "\n".join(data)) - def mkcfgfile(filename, root, option, db): # Options data = ["[options]"] |