"""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.
"""
#!/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
import pygame
class Timer:
+ """Keeps track of time remaining one player."""
def __init__(self, main_time, byop, byot):
self._last = 0
self._elapsed = 0.
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:
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)")