summaryrefslogtreecommitdiff
path: root/pactest/pmrule.py
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-02-21 06:33:13 +0000
committerAaron Griffin <aaron@archlinux.org>2007-02-21 06:33:13 +0000
commit786cd38c0a1cfeff96e5c755852a7e1c7f5e7d75 (patch)
tree3dbf7d7a1a314665602df9e1c0465afd3f2728e1 /pactest/pmrule.py
parenta8dd8d5770094ad8c925a56d47c3607c96363a51 (diff)
downloadpacman-786cd38c0a1cfeff96e5c755852a7e1c7f5e7d75.tar.xz
* Indentation changes - 4 spaces for python, we standardized this before (and
it's a PEP) * Modified some sync tests
Diffstat (limited to 'pactest/pmrule.py')
-rwxr-xr-xpactest/pmrule.py199
1 files changed, 100 insertions, 99 deletions
diff --git a/pactest/pmrule.py b/pactest/pmrule.py
index ad2e8930..43310bfd 100755
--- a/pactest/pmrule.py
+++ b/pactest/pmrule.py
@@ -22,112 +22,113 @@ from util import *
class pmrule:
- """Rule object
- """
+ """Rule object
+ """
- def __init__(self, rule):
- self.rule = rule
- self.false = 0
- self.result = 0
+ def __init__(self, rule):
+ self.rule = rule
+ self.false = 0
+ self.result = 0
- def __str__(self):
- return "rule = %s" % self.rule
+ def __str__(self):
+ return "rule = %s" % self.rule
- def check(self, root, retcode, localdb, files):
- """
- """
+ def check(self, root, retcode, localdb, files):
+ """
+ """
- success = 1
+ success = 1
- [test, args] = self.rule.split("=")
- if test[0] == "!":
- self.false = 1
- test = test.lstrip("!")
- [kind, case] = test.split("_")
- if "|" in args:
- [key, value] = args.split("|", 1)
- else:
- [key, value] = [args, None]
+ [test, args] = self.rule.split("=")
+ if test[0] == "!":
+ self.false = 1
+ test = test.lstrip("!")
+ [kind, case] = test.split("_")
+ if "|" in args:
+ [key, value] = args.split("|", 1)
+ else:
+ [key, value] = [args, None]
- if kind == "PACMAN":
- if case == "RETCODE":
- if retcode != int(key):
- success = 0
- elif case == "OUTPUT":
- if not grep(os.path.join(root, LOGFILE), key):
- success = 0
- else:
- success = -1
- elif kind == "PKG":
- newpkg = localdb.db_read(key)
- if not newpkg:
- success = 0
- else:
- dbg("newpkg.checksum : %s" % newpkg.checksum)
- dbg("newpkg.mtime : %s" % newpkg.mtime)
- if case == "EXIST":
- success = 1
- elif case == "MODIFIED":
- if not localdb.ispkgmodified(newpkg):
- success = 0
- elif case == "VERSION":
- if value != newpkg.version:
- success = 0
- elif case == "GROUPS":
- if not value in newpkg.groups:
- success = 0
- elif case == "DEPENDS":
- if not value in newpkg.depends:
- success = 0
- elif case == "REQUIREDBY":
- if not value in newpkg.requiredby:
- success = 0
- elif case == "REASON":
- if not newpkg.reason == int(value):
- success = 0
- elif case == "FILES":
- if not value in newpkg.files:
- success = 0
- elif case == "BACKUP":
- found = 0
- for f in newpkg.backup:
- name, md5sum = f.split("\t")
- if value == name:
- found = 1
- if not found:
- success = 0
- else:
- success = -1
- elif kind == "FILE":
- filename = os.path.join(root, key)
- if case == "EXIST":
- if not os.path.isfile(filename):
- success = 0
- else:
- if case == "MODIFIED":
- for f in files:
- if f.name == key:
- if not f.ismodified():
- success = 0
- elif case == "PACNEW":
- if not os.path.isfile("%s%s" % (filename, PM_PACNEW)):
- success = 0
- elif case == "PACORIG":
- if not os.path.isfile("%s%s" % (filename, PM_PACORIG)):
- success = 0
- elif case == "PACSAVE":
- if not os.path.isfile("%s%s" % (filename, PM_PACSAVE)):
- success = 0
- else:
- success = -1
- else:
- success = -1
+ if kind == "PACMAN":
+ if case == "RETCODE":
+ if retcode != int(key):
+ success = 0
+ elif case == "OUTPUT":
+ if not grep(os.path.join(root, LOGFILE), key):
+ success = 0
+ else:
+ success = -1
+ elif kind == "PKG":
+ newpkg = localdb.db_read(key)
+ if not newpkg:
+ success = 0
+ else:
+ #dbg("newpkg.checksum : %s" % newpkg.checksum)
+ #dbg("newpkg.mtime : %s" % newpkg.mtime)
+ if case == "EXIST":
+ success = 1
+ elif case == "MODIFIED":
+ if not localdb.ispkgmodified(newpkg):
+ success = 0
+ elif case == "VERSION":
+ if value != newpkg.version:
+ success = 0
+ elif case == "GROUPS":
+ if not value in newpkg.groups:
+ success = 0
+ elif case == "DEPENDS":
+ if not value in newpkg.depends:
+ success = 0
+ elif case == "REQUIREDBY":
+ if not value in newpkg.requiredby:
+ success = 0
+ elif case == "REASON":
+ if not newpkg.reason == int(value):
+ success = 0
+ elif case == "FILES":
+ if not value in newpkg.files:
+ success = 0
+ elif case == "BACKUP":
+ found = 0
+ for f in newpkg.backup:
+ name, md5sum = f.split("\t")
+ if value == name:
+ found = 1
+ if not found:
+ success = 0
+ else:
+ success = -1
+ elif kind == "FILE":
+ filename = os.path.join(root, key)
+ if case == "EXIST":
+ if not os.path.isfile(filename):
+ success = 0
+ else:
+ if case == "MODIFIED":
+ for f in files:
+ if f.name == key:
+ if not f.ismodified():
+ success = 0
+ elif case == "PACNEW":
+ if not os.path.isfile("%s%s" % (filename, PM_PACNEW)):
+ success = 0
+ elif case == "PACORIG":
+ if not os.path.isfile("%s%s" % (filename, PM_PACORIG)):
+ success = 0
+ elif case == "PACSAVE":
+ if not os.path.isfile("%s%s" % (filename, PM_PACSAVE)):
+ success = 0
+ else:
+ success = -1
+ else:
+ success = -1
- if self.false and success != -1:
- success = not success
- self.result = success
- return success
+ if self.false and success != -1:
+ success = not success
+ self.result = success
+ return success
if __name__ != "__main__":
- rule = pmrule("PKG_EXIST=dummy")
+ rule = pmrule("PKG_EXIST=dummy")
+# vim: set ts=4 sw=4 et: