summaryrefslogtreecommitdiff
path: root/test/pacman/pmfile.py
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2015-10-16 20:28:30 -0400
committerAllan McRae <allan@archlinux.org>2015-10-18 10:59:24 +1000
commitb76409609c051e236a849746db79bd438e353b60 (patch)
treeb478973be0331bec655ac59fd25fd336e7d9a6e8 /test/pacman/pmfile.py
parent4ceb1c5bf91dea2453d9b888138c40e4f97d408d (diff)
pactest: add hook/script support
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'test/pacman/pmfile.py')
-rw-r--r--test/pacman/pmfile.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/test/pacman/pmfile.py b/test/pacman/pmfile.py
index 7f96f6ca..417550d6 100644
--- a/test/pacman/pmfile.py
+++ b/test/pacman/pmfile.py
@@ -20,7 +20,32 @@ import stat
import util
-class PacmanFile(object):
+class pmfile(object):
+ def __init__(self, path, content, mode=0o644):
+ self.path = path
+ self.content = content
+ self.mode = mode
+
+ def mkfile(self, root):
+ path = os.path.join(root, self.path)
+
+ dir_path = os.path.dirname(path)
+ if dir_path and not os.path.isdir(dir_path):
+ os.makedirs(dir_path, 0o755)
+
+ fd = open(path, "w")
+ if self.content:
+ fd.write(self.content)
+ if self.content[-1] != "\n":
+ fd.write("\n")
+ fd.close()
+
+ os.chmod(path, self.mode)
+
+ return path
+
+
+class snapshot(object):
"""File object
"""