pep8ify if blocks
This commit is contained in:
parent
973f8b4ca6
commit
e537adfd08
|
@ -316,12 +316,17 @@ def generate_tokens(readline):
|
||||||
if not line: break
|
if not line: break
|
||||||
column = 0
|
column = 0
|
||||||
while pos < max: # measure leading whitespace
|
while pos < max: # measure leading whitespace
|
||||||
if line[pos] == ' ': column = column + 1
|
if line[pos] == ' ':
|
||||||
elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize
|
column = column + 1
|
||||||
elif line[pos] == '\f': column = 0
|
elif line[pos] == '\t':
|
||||||
else: break
|
column = (column/tabsize + 1)*tabsize
|
||||||
|
elif line[pos] == '\f':
|
||||||
|
column = 0
|
||||||
|
else:
|
||||||
|
break
|
||||||
pos = pos + 1
|
pos = pos + 1
|
||||||
if pos == max: break
|
if pos == max:
|
||||||
|
break
|
||||||
|
|
||||||
if line[pos] in '#\r\n': # skip comments or blank lines
|
if line[pos] in '#\r\n': # skip comments or blank lines
|
||||||
if line[pos] == '#':
|
if line[pos] == '#':
|
||||||
|
@ -397,8 +402,10 @@ def generate_tokens(readline):
|
||||||
elif initial == '\\': # continued stmt
|
elif initial == '\\': # continued stmt
|
||||||
continued = 1
|
continued = 1
|
||||||
else:
|
else:
|
||||||
if initial in '([{': parenlev = parenlev + 1
|
if initial in '([{':
|
||||||
elif initial in ')]}': parenlev = parenlev - 1
|
parenlev = parenlev + 1
|
||||||
|
elif initial in ')]}':
|
||||||
|
parenlev = parenlev - 1
|
||||||
yield (OP, token, spos, epos, line)
|
yield (OP, token, spos, epos, line)
|
||||||
else:
|
else:
|
||||||
yield (ERRORTOKEN, line[pos],
|
yield (ERRORTOKEN, line[pos],
|
||||||
|
@ -411,5 +418,7 @@ def generate_tokens(readline):
|
||||||
|
|
||||||
if __name__ == '__main__': # testing
|
if __name__ == '__main__': # testing
|
||||||
import sys
|
import sys
|
||||||
if len(sys.argv) > 1: tokenize(open(sys.argv[1]).readline)
|
if len(sys.argv) > 1:
|
||||||
else: tokenize(sys.stdin.readline)
|
tokenize(open(sys.argv[1]).readline)
|
||||||
|
else:
|
||||||
|
tokenize(sys.stdin.readline)
|
||||||
|
|
Loading…
Reference in New Issue