diff options
| author | 2018-04-03 06:50:04 +0200 | |
|---|---|---|
| committer | 2018-04-03 06:50:04 +0200 | |
| commit | dc580be8f9ef38a1c0903820b04e1b5c7217da16 (patch) | |
| tree | 4a214d88d3e094efdb9e4ff70920537a4d33ae9b /minidinstall/SignedFile.py | |
| parent | 23ac25c0b388b5ffebf66154b12a3950b89b977a (diff) | |
Various improvements in coding style.
Diffstat (limited to 'minidinstall/SignedFile.py')
| -rwxr-xr-x | minidinstall/SignedFile.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/minidinstall/SignedFile.py b/minidinstall/SignedFile.py index efc4730..5a1f7f6 100755 --- a/minidinstall/SignedFile.py +++ b/minidinstall/SignedFile.py @@ -1,9 +1,10 @@ +#!/usr/bin/python3 # SignedFile -*- mode: python; coding: utf-8 -*- # SignedFile offers a subset of file object operations, and is # designed to transparently handle files with PGP signatures. -# Copyright © 2002 Colin Walters <walters@gnu.org> +# Copyright (c) 2002 Colin Walters <walters@gnu.org> # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -19,23 +20,22 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -import re,string - class SignedFile: _stream = None - _eof = 0 - _signed = 0 + _eof = False + _signed = False _signature = None _signatureversion = None _initline = None + def __init__(self, stream): self._stream = stream line = stream.readline() - if (line == "-----BEGIN PGP SIGNED MESSAGE-----\n"): - self._signed = 1 + if line == "-----BEGIN PGP SIGNED MESSAGE-----\n": + self._signed = True while True: line = stream.readline() - if (len(line) == 0 or line == '\n'): + if not line or line == '\n': break else: self._initline = line @@ -51,13 +51,13 @@ class SignedFile: if not self._signed: return line elif line == "-----BEGIN PGP SIGNATURE-----\n": - self._eof = 1 + self._eof = True self._signature = [] self._signatureversion = self._stream.readline() self._stream.readline() # skip blank line while True: line = self._stream.readline() - if len(line) == 0 or line == "-----END PGP SIGNATURE-----\n": + if not line or line == "-----END PGP SIGNATURE-----\n": break self._signature.append(line) self._signature = ''.join(self._signature) @@ -68,7 +68,7 @@ class SignedFile: ret = [] while True: line = self.readline() - if (line != ''): + if line: ret.append(line) else: break @@ -86,22 +86,22 @@ class SignedFile: def getSignatureVersion(self): return self._signatureversion -if __name__=="__main__": +if __name__ == "__main__": import sys - if len(sys.argv) == 0: + if not sys.argv: print("Need one file as an argument") sys.exit(1) filename = sys.argv[1] - f=SignedFile(open(filename)) + f = SignedFile(open(filename)) if f.getSigned(): print("**** SIGNED ****") else: print("**** NOT SIGNED ****") - lines=f.readlines() + lines = f.readlines() print(lines) if not f.getSigned(): assert(len(lines) == len(actuallines)) else: - print("Signature: %s" % (f.getSignature())) + print("Signature: %s" % f.getSignature()) # vim:ts=4:sw=4:et: |
