comparison roundup/install_util.py @ 6068:7ada5d44b21d

flake8 whitespace fixes.
author John Rouillard <rouilj@ieee.org>
date Mon, 20 Jan 2020 21:02:55 -0500
parents 88cf5614e0f4
children 050bcfc801c3
comparison
equal deleted inserted replaced
6067:289cee42cc19 6068:7ada5d44b21d
29 hash_file_types = [".py", ".sh", ".conf", ".cgi"] 29 hash_file_types = [".py", ".sh", ".conf", ".cgi"]
30 slast_file_types = [".css"] 30 slast_file_types = [".css"]
31 31
32 digested_file_types = sgml_file_types + hash_file_types + slast_file_types 32 digested_file_types = sgml_file_types + hash_file_types + slast_file_types
33 33
34
34 def extractFingerprint(lines): 35 def extractFingerprint(lines):
35 # get fingerprint from last line 36 # get fingerprint from last line
36 if lines[-1].startswith(b"#SHA: "): 37 if lines[-1].startswith(b"#SHA: "):
37 # handle .py/.sh comment 38 # handle .py/.sh comment
38 return lines[-1][6:].strip() 39 return lines[-1][6:].strip()
45 # handle css files 46 # handle css files
46 fingerprint = lines[-1][8:] 47 fingerprint = lines[-1][8:]
47 fingerprint = fingerprint.replace(b'*/', b'') 48 fingerprint = fingerprint.replace(b'*/', b'')
48 return fingerprint.strip() 49 return fingerprint.strip()
49 return None 50 return None
51
50 52
51 def checkDigest(filename): 53 def checkDigest(filename):
52 """Read file, check for valid fingerprint, return TRUE if ok""" 54 """Read file, check for valid fingerprint, return TRUE if ok"""
53 # open and read file 55 # open and read file
54 inp = open(filename, "rb") 56 inp = open(filename, "rb")
91 93
92 def close(self): 94 def close(self):
93 file, ext = os.path.splitext(self.filename) 95 file, ext = os.path.splitext(self.filename)
94 96
95 if ext in sgml_file_types: 97 if ext in sgml_file_types:
96 self.file.write(s2b("<!-- SHA: %s -->\n" % (self.digest.hexdigest(),))) 98 self.file.write(s2b("<!-- SHA: %s -->\n" %
99 (self.digest.hexdigest(),)))
97 elif ext in hash_file_types: 100 elif ext in hash_file_types:
98 self.file.write(s2b("#SHA: %s\n" % (self.digest.hexdigest(),))) 101 self.file.write(s2b("#SHA: %s\n" % (self.digest.hexdigest(),)))
99 elif ext in slast_file_types: 102 elif ext in slast_file_types:
100 self.file.write(s2b("/* SHA: %s */\n" % (self.digest.hexdigest(),))) 103 self.file.write(s2b("/* SHA: %s */\n" %
104 (self.digest.hexdigest(),)))
101 105
102 self.file.close() 106 self.file.close()
103 107
104 108
105 def copyDigestedFile(src, dst, copystat=1): 109 def copyDigestedFile(src, dst, copystat=1):

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