Adding Polish language translation, thanks!
[pacman.git] / pactest / pmfile.py
blob99b14a8b8b267d1b26926c4c06ed72f7a6deafc5
1 #! /usr/bin/python
3 # Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 # USA.
21 import os
23 from util import *
26 class pmfile:
27 """File object
28 """
30 def __init__(self, root, name):
31 self.name = name
32 self.root = root
34 filename = os.path.join(self.root, self.name)
35 self.checksum = getmd5sum(filename)
36 self.mtime = getmtime(filename)
38 def __str__(self):
39 return "%s (%s / %lu)" % (self.name, self.checksum, self.mtime)
41 def ismodified(self):
42 """
43 """
45 retval = 0
47 filename = os.path.join(self.root, self.name)
48 checksum = getmd5sum(filename)
49 mtime = getmtime(filename)
51 vprint("\tismodified(%s)" % self.name)
52 vprint("\t\told: %s / %s" % (self.checksum, self.mtime))
53 vprint("\t\tnew: %s / %s" % (checksum, mtime))
55 if self.checksum != checksum \
56 or (self.mtime[1], self.mtime[2]) != (mtime[1], mtime[2]):
57 retval = 1
59 return retval
62 if __name__ == "__main__":
63 f = pmfile("/tmp", "foobar")
64 print f
65 # vim: set ts=4 sw=4 et: