From 7564a98be321e5fa007eee496083a12f9ecdf0bf Mon Sep 17 00:00:00 2001
From: David Trattnig <david@subsquare.at>
Date: Fri, 29 Jul 2022 13:45:17 +0200
Subject: [PATCH] Style(Docstring): Improve contrib src #111

---
 contrib/heartbeat-monitor/PyHeartBeat.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/contrib/heartbeat-monitor/PyHeartBeat.py b/contrib/heartbeat-monitor/PyHeartBeat.py
index b3071f7b..110fb324 100755
--- a/contrib/heartbeat-monitor/PyHeartBeat.py
+++ b/contrib/heartbeat-monitor/PyHeartBeat.py
@@ -26,7 +26,8 @@
 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-""" PyHeartBeat server: receives and tracks UDP packets from all clients.
+
+"""PyHeartBeat server: receives and tracks UDP packets from all clients.
 
 While the BeatLog thread logs each UDP packet in a dictionary, the main
 thread periodically scans the dictionary and prints the IP addresses of the
@@ -62,7 +63,7 @@ DEBUG_ENABLED = os.getenv("DEBUG", "0") == "1"
 
 
 class BeatDict:
-    "Manage heartbeat dictionary"
+    """Manage heartbeat dictionary."""
 
     def __init__(self):
         self.beatDict = {}
@@ -82,13 +83,13 @@ class BeatDict:
         return result
 
     def update(self, entry):
-        "Create or update a dictionary entry"
+        """Create or update a dictionary entry."""
         self.dictLock.acquire()
         self.beatDict[entry] = time()
         self.dictLock.release()
 
     def extractSilent(self, howPast):
-        "Returns a list of entries older than howPast"
+        """Return a list of entries older than howPast."""
         silent = []
         when = time() - howPast
         self.dictLock.acquire()
@@ -100,7 +101,7 @@ class BeatDict:
 
 
 class BeatRec(Thread):
-    "Receive UDP packets, log them in heartbeat dictionary"
+    """Receive UDP packets, log them in heartbeat dictionary."""
 
     def __init__(self, goOnEvent, updateDictFunc, port):
         Thread.__init__(self)
@@ -115,6 +116,7 @@ class BeatRec(Thread):
         return f"Heartbeat Server on port: {self.port}"
 
     def run(self):
+        """Start the beat receiver."""
         while self.goOnEvent.isSet():
             if DEBUG_ENABLED:
                 print("Waiting to receive...")
@@ -130,7 +132,7 @@ class BeatRec(Thread):
 
 
 def main():
-    "Listen to the heartbeats and detect inactive clients"
+    """Listen to the heartbeats and detect inactive clients."""
     if len(sys.argv) > 1:
         heartbeat_port = int(sys.argv[1])
     else:
-- 
GitLab