diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-07-18 06:16:08 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-07-18 06:16:08 (GMT) |
commit | 182b5aca27d376b08a2904bed42b751496f932f3 (patch) | |
tree | df13115820dbc879c0fe2eae488c9f8c0215a7da /Mac/Demo/example0 | |
parent | e6ddc8b20b493fef2e7cffb2e1351fe1d238857e (diff) | |
download | cpython-182b5aca27d376b08a2904bed42b751496f932f3.zip cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.gz cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.bz2 |
Whitespace normalization, via reindent.py.
Diffstat (limited to 'Mac/Demo/example0')
-rw-r--r-- | Mac/Demo/example0/checktext.py | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/Mac/Demo/example0/checktext.py b/Mac/Demo/example0/checktext.py index a5943a6..25f71e4 100644 --- a/Mac/Demo/example0/checktext.py +++ b/Mac/Demo/example0/checktext.py @@ -5,33 +5,31 @@ import EasyDialogs import string def main(): - pathname = EasyDialogs.AskFileForOpen(message='File to check end-of-lines in:') - if not pathname: - sys.exit(0) - fp = open(pathname, 'rb') - try: - data = fp.read() - except MemoryError: - EasyDialogs.Message('Sorry, file is too big.') - sys.exit(0) - if len(data) == 0: - EasyDialogs.Message('File is empty.') - sys.exit(0) - number_cr = string.count(data, '\r') - number_lf = string.count(data, '\n') - if number_cr == number_lf == 0: - EasyDialogs.Message('File contains no lines.') - if number_cr == 0: - EasyDialogs.Message('File has unix-style line endings') - elif number_lf == 0: - EasyDialogs.Message('File has mac-style line endings') - elif number_cr == number_lf: - EasyDialogs.Message('File probably has MSDOS-style line endings') - else: - EasyDialogs.Message('File has no recognizable line endings (binary file?)') - sys.exit(0) - + pathname = EasyDialogs.AskFileForOpen(message='File to check end-of-lines in:') + if not pathname: + sys.exit(0) + fp = open(pathname, 'rb') + try: + data = fp.read() + except MemoryError: + EasyDialogs.Message('Sorry, file is too big.') + sys.exit(0) + if len(data) == 0: + EasyDialogs.Message('File is empty.') + sys.exit(0) + number_cr = string.count(data, '\r') + number_lf = string.count(data, '\n') + if number_cr == number_lf == 0: + EasyDialogs.Message('File contains no lines.') + if number_cr == 0: + EasyDialogs.Message('File has unix-style line endings') + elif number_lf == 0: + EasyDialogs.Message('File has mac-style line endings') + elif number_cr == number_lf: + EasyDialogs.Message('File probably has MSDOS-style line endings') + else: + EasyDialogs.Message('File has no recognizable line endings (binary file?)') + sys.exit(0) + if __name__ == '__main__': - main() - - + main() |