comments for timer
authorTomas Musil <tomik.musil@gmail.com>
Tue, 24 Jun 2014 14:57:02 +0000 (16:57 +0200)
committerTomas Musil <tomik.musil@gmail.com>
Tue, 24 Jun 2014 14:57:02 +0000 (16:57 +0200)
imago_pack/capture.py
imago_pack/timer.py

index 3971af5..dd7f47f 100755 (executable)
@@ -2,7 +2,7 @@
 
 """Go image capture.
 
-This module defines an UI for capturing images with a (web)camera and imediately
+This module defines a UI for capturing images with a (web)camera and imediately
 proccessing them with Imago.
 """
 
index b5ec3fb..2419563 100755 (executable)
@@ -1,6 +1,12 @@
 #!/usr/bin/env python
 
-"""Go timer"""
+"""Go timer.
+
+This module defines a UI that combines game clock with automatic game recording.
+When player presses the clock, an image of the board is taken. The sequence of
+images can later be analysed by Imago to produce a game record in abstract
+notation.
+"""
 
 import os
 import sys
@@ -11,6 +17,7 @@ import subprocess
 import pygame
 
 class Timer:
+    """Keeps track of time remaining one player."""
     def __init__(self, main_time, byop, byot):
         self._last = 0
         self._elapsed = 0.
@@ -21,6 +28,7 @@ class Timer:
         self._byo = False
 
     def get_time(self):
+        """Return string representation of remaining time."""
         if self._last > 0: # when running:
             r_time = self._main_t - (time.time() - self._last + self._elapsed)
             if (r_time - int(r_time)) < 0.75:
@@ -47,19 +55,24 @@ class Timer:
         return "{0:0>2}".format(int(r_time / 60)) + sep + "{0:0>2}".format(int(r_time % 60))
 
     def start(self):
+        """Start the clock."""
         self._last = time.time()
 
     def stop(self):
+        """Stop the clock."""
         self._elapsed += time.time() - self._last
         self._last = 0
 
     def is_running(self):
+        """Return True if the clock is running."""
         if self._last > 0:
             return True
         else:
             return False
 
 def main():
+    """Parse the arguments and run the clock."""
+    # TODO refactor into smaller functions
     parser = argparse.ArgumentParser(description=__doc__)
     parser.add_argument('-m', type=int, default=10,
                         help="main time in minutes (default is 10)")