Fix the memory bug for real this time + calculate color changes correctly.
This commit is contained in:
parent
c6dd9513b4
commit
ba4d33373d
1 changed files with 2 additions and 10 deletions
10
pat.py
10
pat.py
|
@ -26,20 +26,12 @@ if len(argv) == 1:
|
|||
for arg in argv[1:]:
|
||||
try:
|
||||
file = stdin if arg == "-" else open(arg, "r")
|
||||
if file.seekable():
|
||||
file_length = file.seek(0, 2)
|
||||
if file_length > bytes_to_read:
|
||||
file.seek(file_length - bytes_to_read)
|
||||
else:
|
||||
file.seek(0)
|
||||
read_result = file.read()
|
||||
else:
|
||||
read_result = file.read(bytes_to_read)
|
||||
except Exception as e:
|
||||
print("Error reading %s: %s" % (file.name, e), file=stderr)
|
||||
continue
|
||||
|
||||
changes = len(list(filter(lambda c: not c in whitespace, read_result)))
|
||||
changes = len(list(filter(lambda c: not c in whitespace, read_result))) - 1
|
||||
|
||||
step = 0 if changes == 0 else ColorInfo.AMOUNT / changes
|
||||
index = 0
|
||||
|
|
Loading…
Reference in a new issue