From b211c3ff4b86040032284e283c06b5f2cf1d219c Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 21 Oct 2011 10:03:42 -0400 Subject: [PATCH] use more convenient iter() method for processing lines in files --- hours | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/hours b/hours index cbcf437..312a57f 100755 --- a/hours +++ b/hours @@ -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