From: Eevee Date: Wed, 7 Jan 2009 13:44:00 +0000 (-0500) Subject: Renamed cellgroup.py and CellConstraint. X-Git-Url: http://git.veekun.com/pseudoku.git/commitdiff_plain/8a045b780490790e8d69f929562a8d4befaf6283 Renamed cellgroup.py and CellConstraint. They are now constrants.py and Constraint, respectively. --- diff --git a/pseudoku/grid/__init__.py b/pseudoku/grid/__init__.py index a62f18f..3bf854b 100644 --- a/pseudoku/grid/__init__.py +++ b/pseudoku/grid/__init__.py @@ -5,7 +5,7 @@ from operator import attrgetter import re from weakref import ref -from cellgroup import CellConstraint, Row, Column, Box +from constraints import Constraint, Row, Column, Box symbols = [str(x + 1) for x in range(9)] + [chr(x + 97) for x in xrange(26)] @@ -144,7 +144,7 @@ class Grid(object): ### Accessors - def get_constraints(self, constraint_class=CellConstraint): + def get_constraints(self, constraint_class=Constraint): """Returns constraints of a certain type. Returns all of them by default. """ diff --git a/pseudoku/grid/cellgroup.py b/pseudoku/grid/constraints.py similarity index 95% rename from pseudoku/grid/cellgroup.py rename to pseudoku/grid/constraints.py index 841a490..91f8287 100644 --- a/pseudoku/grid/cellgroup.py +++ b/pseudoku/grid/constraints.py @@ -2,7 +2,7 @@ from __future__ import division from weakref import ref -class CellConstraint(object): +class Constraint(object): """Represents any group of cells in a grid that cannot repeat a digit.""" ### Accessors @@ -46,7 +46,7 @@ class CellConstraint(object): target_cell.set(value) -class Box(CellConstraint): +class Box(Constraint): def _get_box_row(self): return self._pos // self.grid._box_width box_row = property(_get_box_row) @@ -67,7 +67,7 @@ class Box(CellConstraint): self._cells.append(ref(self.grid.cell(cell_row, cell_col))) -class Row(CellConstraint): +class Row(Constraint): def __init__(self, grid, position): self._grid = ref(grid) self._pos = position @@ -76,7 +76,7 @@ class Row(CellConstraint): for col in xrange(self.grid._size): self._cells.append(ref(self.grid.cell(self._pos, col))) -class Column(CellConstraint): +class Column(Constraint): def __init__(self, grid, position): self._grid = ref(grid) self._pos = position @@ -85,7 +85,7 @@ class Column(CellConstraint): for row in xrange(self.grid._size): self._cells.append(ref(self.grid.cell(row, self._pos))) -class Diagonal(CellConstraint): +class Diagonal(Constraint): def __init__(self, grid, direction='down', offset=0): self._grid = ref(grid) self._direction = direction