Browse Source

use "with" to handle files

master
Ben Savage 7 years ago
parent
commit
d3b8668801
  1. 9
      stanza

9
stanza

@ -36,12 +36,9 @@ def debug(line):
debug(pformat(args))
# Set up the file handle, <file> or stdin
if cmd.filename:
handle=open(cmd.filename)
else:
handle=sys.stdin
# Go over the handle, line by line
for line in handle:
with open(cmd.filename,'r') if cmd.filename else sys.stdin as handle:
# Go over the handle, line by line
for line in handle:
# Start buffering if we hit the start regex
if re.search(start,line):
buffering=True

Loading…
Cancel
Save