From 4f8b59ede5a8509f0de9f226d0996abce730f9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manolo=20Mart=C3=ADnez?= Date: Fri, 22 May 2015 12:14:27 +0200 Subject: [PATCH] We should always append line, anyway. --- greg/greg.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/greg/greg.py b/greg/greg.py index a0b0b92..52b61e6 100755 --- a/greg/greg.py +++ b/greg/greg.py @@ -677,18 +677,15 @@ def edit(args): # Edits the information associated with a certain feed "results that you expect."). format(args["name"]), file=sys.stderr, flush=True) line = ' '.join(["currentdate", str(value), "\n"]) - # A dummy entry with the right date, in case we need it. + # A dummy entry with the new downloadfrom date. try: # Remove from the feed file all entries - # after or equal to downloadfrom + # after or equal to downloadfrom, then append line with open(feed_info, 'r') as previous: - current = list(filterfalse( - lambda line: value < get_date(line), previous)) - if not current or current == previous: - # i.e., if current == [] (is this the Pythonic way to - # put it?) or we haven't deleted anything (because the - # desired date is in the future.) - current.append(line) + previouslist = previous.readlines() + current = [aline for aline in previouslist if value > + get_date(aline)] + current.append(line) with open(feed_info, 'w') as currentfile: currentfile.writelines(current) except FileNotFoundError: