Mercurial > p > roundup > code
changeset 1910:d19fd344bd1f
recalculate SHA on template files when installed tracker used as template
[SF#827510]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 11 Nov 2003 22:37:25 +0000 |
| parents | 00f0267db956 |
| children | f5c804379c85 |
| files | CHANGES.txt roundup/install_util.py |
| diffstat | 2 files changed, 27 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Tue Nov 11 22:25:37 2003 +0000 +++ b/CHANGES.txt Tue Nov 11 22:37:25 2003 +0000 @@ -27,6 +27,8 @@ (bug #821364). - Centralised conversion of user-input data to hyperdb values (bug #802405, bug #817217, rfe #816994) +- recalculate SHA on template files when installed tracker used as + template (sf bug 827510) Cleanup: - Replace curuserid attribute on Database with the extended getuid() method.
--- a/roundup/install_util.py Tue Nov 11 22:25:37 2003 +0000 +++ b/roundup/install_util.py Tue Nov 11 22:37:25 2003 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: install_util.py,v 1.8 2002-09-10 00:18:20 richard Exp $ +# $Id: install_util.py,v 1.9 2003-11-11 22:37:25 richard Exp $ __doc__ = """ Support module to generate and check fingerprints of installed files. @@ -30,6 +30,22 @@ digested_file_types = sgml_file_types + hash_file_types + slast_file_types +def extractFingerprint(lines): + # get fingerprint from last line + if lines[-1].startswith("#SHA: "): + # handle .py/.sh comment + return lines[-1][6:].strip() + elif lines[-1].startswith("<!-- SHA: "): + # handle xml/html files + fingerprint = lines[-1][10:] + fingerprint = fingerprint.replace('-->', '') + return fingerprint.strip() + elif lines[-1].startswith("/* SHA: "): + # handle css files + fingerprint = lines[-1][8:] + fingerprint = fingerprint.replace('*/', '') + return fingerprint.strip() + return None def checkDigest(filename): """Read file, check for valid fingerprint, return TRUE if ok""" @@ -38,21 +54,8 @@ lines = inp.readlines() inp.close() - # get fingerprint from last line - if lines[-1][:6] == "#SHA: ": - # handle .py/.sh comment - fingerprint = lines[-1][6:].strip() - elif lines[-1][:10] == "<!-- SHA: ": - # handle xml/html files - fingerprint = lines[-1][10:] - fingerprint = fingerprint.replace('-->', '') - fingerprint = fingerprint.strip() - elif lines[-1][:8] == "/* SHA: ": - # handle css files - fingerprint = lines[-1][8:] - fingerprint = fingerprint.replace('*/', '') - fingerprint = fingerprint.strip() - else: + fingerprint = extractFingerprint(lines) + if fingerprint is None: return 0 del lines[-1] @@ -76,6 +79,12 @@ self.file = open(self.filename, "w") def write(self, data): + lines = data.splitlines() + # if the file is coming from an installed tracker being used as a + # template, then we will want to re-calculate the SHA + fingerprint = extractFingerprint(lines) + if fingerprint is not None: + data = '\n'.join(lines[:-1]) + '\n' self.file.write(data) self.digest.update(data)
