jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/820689 )

Change subject: [IMPR] Simplify loop with itertools.pairwise
......................................................................

[IMPR] Simplify loop with itertools.pairwise

Change-Id: Ifee03724cd8fa194a463b8beda8e809e43696aa7
---
M scripts/archivebot.py
1 file changed, 4 insertions(+), 5 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index 69fa1d6..6c73eca 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -114,6 +114,7 @@
 # Distributed under the terms of the MIT license.
 #
 import datetime
+import itertools
 import locale
 import os
 import re
@@ -393,12 +394,10 @@
                 cur_thread.feed_line(line)
             self.threads.append(cur_thread)

-        if self.keep and len(self.threads) > 1:
+        if self.keep:
             # set the timestamp to the previous if the current is lower
-            prev = self.threads[0].timestamp
-            for thread in self.threads:
-                thread.timestamp = self.max(prev, thread.timestamp)
-                prev = thread.timestamp
+            for first, second in itertools.pairwise(self.threads):
+                second.timestamp = self.max(first.timestamp, second.timestamp)

         # This extra info is not desirable when run under the unittest
         # framework, which may be run either directly or via setup.py

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/820689
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ifee03724cd8fa194a463b8beda8e809e43696aa7
Gerrit-Change-Number: 820689
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to