From: Eevee Date: Sat, 13 Dec 2008 03:56:57 +0000 (-0800) Subject: Moved code out of lib/. X-Git-Url: http://git.veekun.com/pseudoku.git/commitdiff_plain/ef420dd690bb7803272ebc08c8e7a6e132dd0061 Moved code out of lib/. There's no non-code to protect it from, so not much point in the separation. --- diff --git a/lib/pseudoku/__init__.py b/pseudoku/__init__.py similarity index 52% rename from lib/pseudoku/__init__.py rename to pseudoku/__init__.py index 83abfc3..3b6eeb9 100644 --- a/lib/pseudoku/__init__.py +++ b/pseudoku/__init__.py @@ -2,26 +2,6 @@ from grid import Grid def main(): grid = Grid.from_string(""" - ...69.... - 9.5..876. - ..4..1.2. - 6...5...3 - 38.....49 - 7...3...2 - .7.9..3.. - .231..4.8 - ....83... - """) - - print grid - - grid.solve() - - print grid - - - - grid = Grid.from_string(""" 3...2...7 ...3.1... ..6...4.. diff --git a/lib/pseudoku/grid/__init__.py b/pseudoku/grid/__init__.py similarity index 95% rename from lib/pseudoku/grid/__init__.py rename to pseudoku/grid/__init__.py index d1906ae..2f77aaf 100644 --- a/lib/pseudoku/grid/__init__.py +++ b/pseudoku/grid/__init__.py @@ -9,6 +9,13 @@ from cellgroup import Row, Column, Box symbols = [str(x + 1) for x in range(9)] + [chr(x + 97) for x in xrange(26)] class GridSizeError(Exception): + """Exception thrown when an impossible grid size is encountered.""" + pass + +class GridIntegrityError(Exception): + """Exception thrown when a grid's state violates its own constraints. This + should only happen if there are bugs in the code itself. + """ pass class Cell(object): @@ -258,11 +265,16 @@ class Grid(object): return self - ### Methods + ### Inspectors def cell(self, row, column): return self._cells[self._cellidx(row, column)] + def is_filled(self): + for cell in self._cells: + if cell.value == None: + return False + return True ### Solving @@ -270,9 +282,10 @@ class Grid(object): """Returns True iff the grid is solved. Raises an exception if an integrity problem is found, such as a value appearing twice in a row. """ - # TODO + # TODO remove this; name sucks and concept also sucks return None + def solve(self): """Attempts to solve the grid.""" # XXX track how many cells are changed and repeat as appropriate diff --git a/lib/pseudoku/grid/cellgroup.py b/pseudoku/grid/cellgroup.py similarity index 100% rename from lib/pseudoku/grid/cellgroup.py rename to pseudoku/grid/cellgroup.py diff --git a/setup.py b/setup.py index a13a3a0..8d834ec 100644 --- a/setup.py +++ b/setup.py @@ -2,8 +2,7 @@ from setuptools import setup, find_packages setup( name = 'Pseudoku', version = '0.0', - package_dir = {'': 'lib'}, - packages = find_packages('lib'), + packages = find_packages(exclude=['tests', 'tests.*']), entry_points = { 'console_scripts': [