From 47f75fb4659a3fef118d2ef3f939cba68432eca2 Mon Sep 17 00:00:00 2001 From: M Pacer Date: Sun, 8 Apr 2018 16:38:38 -0700 Subject: [PATCH] change check_age to paper_too_young and check_queue to paper_in_queue also make the code pattern nicer --- procbuild/listener.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/procbuild/listener.py b/procbuild/listener.py index db66582..1a0eda0 100644 --- a/procbuild/listener.py +++ b/procbuild/listener.py @@ -58,7 +58,7 @@ async def listen(self): self.dont_build.add(paper_to_build) await self.queue.put(paper_to_build) - def check_age(self, nr): + def paper_too_young(self, nr): """Check the age of a PR's status_file based on its number. Parameters @@ -68,13 +68,12 @@ def check_age(self, nr): """ age = file_age(status_file(nr)) min_wait = 0.5 - too_young = False - if age is not None and age <= min_wait: + too_young = age is not None and age <= min_wait + if too_young: log(f"Did not build paper {nr}--recently built.") - too_young = True return too_young - def check_queue(self, nr): + def paper_in_queue(self, nr): """Check whether the queue currently contains a build request for a PR. Parameters @@ -82,10 +81,9 @@ def check_queue(self, nr): nr : int the number of the PR to check """ - in_queue = False - if nr in self.dont_build: + in_queue = nr in self.dont_build + if in_queue: log(f"Did not queue paper {nr}--already in queue.") - in_queue = True return in_queue def report_status(self, nr):