use more convenient iter() method for processing lines in files

This commit is contained in:
Josh Holtrop committed 2011-10-21 10:03:42 -04:00
1 parent 230fb1ccf0
commit b211c3ff4b
1 file changed
+2 -8
+2 -8
View File
@@ -45,10 +45,7 @@ def get_adjustments():
if not os.path.isfile(ADJUSTMENTS_FILE):
return adjustments
f = open(ADJUSTMENTS_FILE, 'r')
while True:
line = f.readline()
if line == '':
break
for line in iter(f.readline, ''):
m = re.match(r'adj\s+(\S+)\s+(\S+)', line)
if m is not None:
adjustments[m.group(1)] = float(m.group(2))
@@ -113,10 +110,7 @@ def main(argv):
times.append([None, None])
f = open(LOG_FILE, 'r')
while True:
line = f.readline()
if line == '':
break
for line in iter(f.readline, ''):
if (re.search(r'gnome-screensaver.*unlocked.login.keyring', line)
or re.search(r'screen unlocked', line)):
# found a login line