Repository
file doesn't need to be an attr, use 'with open()'
Parent commits : 43e073743644b429af1a392fc9e8ded5b7ad97fb,Children commits :
By Pierre-Louis Bonicoli on 2011-04-10 12:51:05
file doesn't need to be an attr, use 'with open()'
Difference with parent commit 43e073743644b429af1a392fc9e8ded5b7ad97fb
Files modified:
factorize.py
---
+++
@@ -208,20 +208,20 @@
class Log:
def __init__(s, file, opt):
- s.f = open(file, 'r')
- s.tree = FactorizedLine()
- s.line_count = 0
- s.opt = opt
- s.lines = []
-
- while 1:
- line = s.f.readline()
- if not line:
- break
- line = LogLine(line, s.opt)
- s.tree.add_line(line)
- s.line_count += 1
- s.lines.append(line)
+ with open(file, 'r') as input:
+ s.tree = FactorizedLine()
+ s.line_count = 0
+ s.opt = opt
+ s.lines = []
+
+ while 1:
+ line = input.readline()
+ if not line:
+ break
+ line = LogLine(line, s.opt)
+ s.tree.add_line(line)
+ s.line_count += 1
+ s.lines.append(line)
s.tree.build()