Mercurial > p > roundup > code
comparison roundup/install_util.py @ 384:a72ad731b2cb
Handle all the various file formats in roundup
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 12 Nov 2001 22:37:13 +0000 |
| parents | a213e2a90364 |
| children | 66e18fd9f5a2 |
comparison
equal
deleted
inserted
replaced
| 383:a213e2a90364 | 384:a72ad731b2cb |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: install_util.py,v 1.1 2001-11-12 22:26:32 jhermann Exp $ | 18 # $Id: install_util.py,v 1.2 2001-11-12 22:37:13 richard Exp $ |
| 19 | 19 |
| 20 import os, sha | 20 import os, sha |
| 21 | 21 |
| 22 | 22 |
| 23 def checkDigest(filename): | 23 def checkDigest(filename): |
| 30 # get fingerprint from last line | 30 # get fingerprint from last line |
| 31 if lines[-1][:6] == "#SHA: ": | 31 if lines[-1][:6] == "#SHA: ": |
| 32 # handle .py/.sh comment | 32 # handle .py/.sh comment |
| 33 fingerprint = lines[-1][6:].strip() | 33 fingerprint = lines[-1][6:].strip() |
| 34 elif lines[-1][:10] == "<!-- SHA: ": | 34 elif lines[-1][:10] == "<!-- SHA: ": |
| 35 # handle xml files | 35 # handle xml/html files |
| 36 fingerprint = lines[-1][10:] | 36 fingerprint = lines[-1][10:] |
| 37 fingerprint = fingerprint.replace('-->', '') | 37 fingerprint = fingerprint.replace('-->', '') |
| 38 fingerprint = fingerprint.strip() | |
| 39 elif lines[-1][:8] == "/* SHA: ": | |
| 40 fingerprint = lines[-1][8:] | |
| 41 fingerprint = fingerprint.replace('*/', '') | |
| 38 fingerprint = fingerprint.strip() | 42 fingerprint = fingerprint.strip() |
| 39 else: | 43 else: |
| 40 return 0 | 44 return 0 |
| 41 del lines[-1] | 45 del lines[-1] |
| 42 | 46 |
| 64 self.digest.update(data) | 68 self.digest.update(data) |
| 65 | 69 |
| 66 def close(self): | 70 def close(self): |
| 67 file, ext = os.path.splitext(self.filename) | 71 file, ext = os.path.splitext(self.filename) |
| 68 | 72 |
| 69 if ext in [".xml", ".ent"]: | 73 # ".filter", ".index", ".item" are roundup-specific |
| 74 if ext in [".xml", ".ent", ".html", ".filter", ".index", ".item"]: | |
| 70 self.file.write("<!-- SHA: %s -->\n" % (self.digest.hexdigest(),)) | 75 self.file.write("<!-- SHA: %s -->\n" % (self.digest.hexdigest(),)) |
| 71 elif ext in [".py", ".sh", ".conf", '']: | 76 elif ext in [".py", ".sh", ".conf", ".cgi", '']: |
| 72 self.file.write("#SHA: %s\n" % (self.digest.hexdigest(),)) | 77 self.file.write("#SHA: %s\n" % (self.digest.hexdigest(),)) |
| 78 elif ext in [".css"]: | |
| 79 self.file.write("/* SHA: %s %/\n" % (self.digest.hexdigest(),)) | |
| 73 | 80 |
| 74 self.file.close() | 81 self.file.close() |
| 75 | 82 |
| 76 | 83 |
| 77 def test(): | 84 def test(): |
| 99 if __name__ == '__main__': | 106 if __name__ == '__main__': |
| 100 test() | 107 test() |
| 101 | 108 |
| 102 # | 109 # |
| 103 # $Log: not supported by cvs2svn $ | 110 # $Log: not supported by cvs2svn $ |
| 111 # Revision 1.1 2001/11/12 22:26:32 jhermann | |
| 112 # Added install utils (digest calculation) | |
| 113 # | |
| 104 | 114 |
