comparison roundup/install_util.py @ 4089:eddb82d0964c

Add compatibility package to allow us to deal with Python versions 2.3..2.6. Outstanding issues noted in roundup/anypy/TODO.txt
author Richard Jones <richard@users.sourceforge.net>
date Thu, 12 Mar 2009 02:52:56 +0000
parents 4ee255777c25
children 6e3e4f24c753
comparison
equal deleted inserted replaced
4088:34434785f308 4089:eddb82d0964c
19 19
20 """Support module to generate and check fingerprints of installed files. 20 """Support module to generate and check fingerprints of installed files.
21 """ 21 """
22 __docformat__ = 'restructuredtext' 22 __docformat__ = 'restructuredtext'
23 23
24 import os, sha, shutil 24 import os, shutil
25 from roundup.anypy.hashlib_ import sha1
25 26
26 sgml_file_types = [".xml", ".ent", ".html"] 27 sgml_file_types = [".xml", ".ent", ".html"]
27 hash_file_types = [".py", ".sh", ".conf", ".cgi"] 28 hash_file_types = [".py", ".sh", ".conf", ".cgi"]
28 slast_file_types = [".css"] 29 slast_file_types = [".css"]
29 30
57 if fingerprint is None: 58 if fingerprint is None:
58 return 0 59 return 0
59 del lines[-1] 60 del lines[-1]
60 61
61 # calculate current digest 62 # calculate current digest
62 digest = sha.new() 63 digest = sha1()
63 for line in lines: 64 for line in lines:
64 digest.update(line) 65 digest.update(line)
65 66
66 # compare current to stored digest 67 # compare current to stored digest
67 return fingerprint == digest.hexdigest() 68 return fingerprint == digest.hexdigest()
72 and writes a SHA digest to the target file. 73 and writes a SHA digest to the target file.
73 """ 74 """
74 75
75 def __init__(self, filename): 76 def __init__(self, filename):
76 self.filename = filename 77 self.filename = filename
77 self.digest = sha.new() 78 self.digest = sha1()
78 self.file = open(self.filename, "w") 79 self.file = open(self.filename, "w")
79 80
80 def write(self, data): 81 def write(self, data):
81 lines = data.splitlines() 82 lines = data.splitlines()
82 # if the file is coming from an installed tracker being used as a 83 # if the file is coming from an installed tracker being used as a

Roundup Issue Tracker: http://roundup-tracker.org/