gnome-games r9009 - trunk/gnome-sudoku/src/lib
- From: thomashpa svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r9009 - trunk/gnome-sudoku/src/lib
- Date: Wed, 8 Apr 2009 10:05:36 +0000 (UTC)
Author: thomashpa
Date: Wed Apr 8 10:05:36 2009
New Revision: 9009
URL: http://svn.gnome.org/viewvc/gnome-games?rev=9009&view=rev
Log:
trivial white space clean up. Replace a few tabs and get rid of white space before newline
Modified:
trunk/gnome-sudoku/src/lib/colors.py
trunk/gnome-sudoku/src/lib/dialog_swallower.py
trunk/gnome-sudoku/src/lib/game_selector.py
trunk/gnome-sudoku/src/lib/gnome_sudoku.py
trunk/gnome-sudoku/src/lib/gsudoku.py
trunk/gnome-sudoku/src/lib/main.py
trunk/gnome-sudoku/src/lib/pausable.py
trunk/gnome-sudoku/src/lib/printing.py
trunk/gnome-sudoku/src/lib/saver.py
trunk/gnome-sudoku/src/lib/simple_debug.py
trunk/gnome-sudoku/src/lib/sudoku.py
trunk/gnome-sudoku/src/lib/sudoku_maker.py
trunk/gnome-sudoku/src/lib/sudoku_thumber.py
trunk/gnome-sudoku/src/lib/timer.py
Modified: trunk/gnome-sudoku/src/lib/colors.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/colors.py (original)
+++ trunk/gnome-sudoku/src/lib/colors.py Wed Apr 8 10:05:36 2009
@@ -27,7 +27,7 @@
if (h < 0): h+=1
if (h > 1): h -= 1
return h,s,v
-
+
def hsv_to_rgb (h,s,v):
if s==0:
return v,v,v
Modified: trunk/gnome-sudoku/src/lib/dialog_swallower.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/dialog_swallower.py (original)
+++ trunk/gnome-sudoku/src/lib/dialog_swallower.py Wed Apr 8 10:05:36 2009
@@ -13,7 +13,7 @@
response = None
running = False
-
+
def __init__ (self,main_area):
gtk.Notebook.__init__(self)
self.set_show_tabs(False)
@@ -24,7 +24,7 @@
child = d.child
d.remove(child)
return self.swallow_widget(child)
-
+
def swallow_widget (self, w):
w.unparent()
return self.append_page(w)
@@ -56,7 +56,7 @@
self.response = None
return tmp_response
-
+
if __name__ == '__main__':
Modified: trunk/gnome-sudoku/src/lib/game_selector.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/game_selector.py (original)
+++ trunk/gnome-sudoku/src/lib/game_selector.py Wed Apr 8 10:05:36 2009
@@ -32,7 +32,7 @@
elif diff < DR.very_hard_range[0]+ span*2/3:
c='#cc0000'
else:
- c='#a40000'
+ c='#a40000'
return color_hex_to_float(c)
class NewOrSavedGameSelector (gconf_wrapper.GConfWrapper):
@@ -47,7 +47,7 @@
if gconf:
gconf_wrapper.GConfWrapper.__init__(self,gconf)
self.sudoku_maker = sudokuMaker or sudoku_maker.SudokuMaker()
-
+
def setup_dialog (self):
self.builder = gtk.Builder()
self.builder.add_from_file(self.ui_file)
@@ -169,16 +169,16 @@
self.puzzle = (self.NEW_GAME,puzzle)
self.dialog.emit('response',gtk.RESPONSE_OK)
- @simple_debug
+ @simple_debug
def close (self):
- self.dialog.emit('response',gtk.RESPONSE_CLOSE)
+ self.dialog.emit('response',gtk.RESPONSE_CLOSE)
@simple_debug
def handle_response (self, response):
if response==gtk.RESPONSE_OK:
return self.puzzle
else:
- return None
+ return None
def run_swallowed_dialog (self, swallower):
self.setup_dialog()
Modified: trunk/gnome-sudoku/src/lib/gnome_sudoku.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/gnome_sudoku.py (original)
+++ trunk/gnome-sudoku/src/lib/gnome_sudoku.py Wed Apr 8 10:05:36 2009
@@ -5,7 +5,7 @@
class SafeStdout:
def __init__(self):
self.stdout = sys.stdout
-
+
def fileno(self):
return self.stdout.fileno()
@@ -18,5 +18,5 @@
sys.stdout = SafeStdout()
def start_game ():
- import main
- main.start_game()
+ import main
+ main.start_game()
Modified: trunk/gnome-sudoku/src/lib/gsudoku.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/gsudoku.py (original)
+++ trunk/gnome-sudoku/src/lib/gsudoku.py Wed Apr 8 10:05:36 2009
@@ -34,7 +34,7 @@
# And the standard font-sizes -- these should fit nicely with the
# BASE_SIZE
-BASE_FONT_SIZE = pango.SCALE * 13
+BASE_FONT_SIZE = pango.SCALE * 13
NOTE_FONT_SIZE = pango.SCALE * 6
BORDER_WIDTH = 9.0 # The size of space we leave for a box
@@ -54,7 +54,7 @@
__gsignals__ = {
'changed':(gobject.SIGNAL_RUN_LAST,gobject.TYPE_NONE,()),
}
-
+
def __init__ (self,default=None,upper=9):
self.value = default
gtk.EventBox.__init__(self)
@@ -102,12 +102,12 @@
text = ''
top_note_text = ''
- bottom_note_text = ''
+ bottom_note_text = ''
read_only = False
read_only_hidden = False
_layout = None
_top_note_layout = None
- _bottom_note_layout = None
+ _bottom_note_layout = None
text_color = None
highlight_color = None
custom_background_color = None
@@ -118,14 +118,14 @@
# undo-change - A hacky way to handle the fact that we want to
# respond to undo's changes but we don't want undo to respond
# to itself...
- 'undo-change':(gobject.SIGNAL_RUN_LAST,gobject.TYPE_NONE,()),
+ 'undo-change':(gobject.SIGNAL_RUN_LAST,gobject.TYPE_NONE,()),
'notes-changed':(gobject.SIGNAL_RUN_LAST,gobject.TYPE_NONE,()),
}
base_state = gtk.STATE_NORMAL
npicker = None
draw_boxes = False
-
+
def __init__ (self, upper=9, text=''):
gtk.Widget.__init__(self)
self.upper = upper
@@ -168,7 +168,7 @@
if self.is_focus() and not self.read_only:
self._toggle_box_drawing_(True)
else:
- self._toggle_box_drawing_(False)
+ self._toggle_box_drawing_(False)
def _toggle_box_drawing_ (self, val):
if val and not self.draw_boxes:
@@ -176,7 +176,7 @@
self.queue_draw()
if (not val) and self.draw_boxes:
self.draw_boxes = False
- self.queue_draw()
+ self.queue_draw()
def button_press_cb (self, w, e):
if self.read_only: return
@@ -186,7 +186,7 @@
# than selecting a number.
return
if self.is_focus():
- x,y = e.get_coords()
+ x,y = e.get_coords()
alloc = self.get_allocation()
my_w = alloc.width
my_h = alloc.height
@@ -210,7 +210,7 @@
txt = gtk.gdk.keyval_name(e.keyval)
if type(txt) == type(None):
# Make sure we don't trigger on unplugging the A/C charger etc
- return
+ return
txt = txt.replace('KP_', '')
if self.get_text() == txt:
# If there's no change, do nothing
@@ -290,7 +290,7 @@
self.emit('value-about-to-change')
self.set_text(text)
self.queue_draw()
- self.emit('changed')
+ self.emit('changed')
def set_font (self, font):
if type(font)==str:
@@ -337,7 +337,7 @@
self.emit('value-about-to-change')
self.set_note_text(*args,**kwargs)
self.emit('notes-changed')
-
+
def do_realize (self):
# The do_realize method is responsible for creating GDK (windowing system)
# resources. In this example we will create a new gdk.Window which we
@@ -396,7 +396,7 @@
# Save the allocated space
self.allocation = allocation
-
+
# If we're realized, move and resize the window to the
# requested coordinates/positions
if self.flags() & gtk.REALIZED:
@@ -408,7 +408,7 @@
# a good idea to write this code as optimized as it can be, don't
# Create any resources in here.
x, y, w, h = self.allocation
- cr = self.window.cairo_create()
+ cr = self.window.cairo_create()
if h<w:
scale = h/float(BASE_SIZE)
else:
@@ -421,9 +421,9 @@
self.draw_text(cr)
if self.draw_boxes and self.is_focus():
self.draw_note_area_highlight_box(cr)
-
- def draw_background_color (self, cr):
+
+ def draw_background_color (self, cr):
if self.read_only:
if self.custom_background_color:
r,g,b = self.custom_background_color
@@ -433,7 +433,7 @@
else:
cr.set_source_color(self.style.base[gtk.STATE_INSENSITIVE])
elif self.is_focus():
- cr.set_source_color(self.style.base[gtk.STATE_SELECTED])
+ cr.set_source_color(self.style.base[gtk.STATE_SELECTED])
elif self.custom_background_color:
cr.set_source_rgb(*self.custom_background_color)
else:
@@ -512,7 +512,7 @@
BASE_SIZE-NORMAL_LINE_WIDTH #y2
)
cr.stroke()
-
+
def draw_text (self, cr):
if self.text_color:
cr.set_source_rgb(*self.text_color)
@@ -529,7 +529,7 @@
)
cr.update_layout(self._layout)
cr.show_layout(self._layout)
- cr.set_source_color(self.style.text[self.state])
+ cr.set_source_color(self.style.text[self.state])
# And draw any note text...
if self._top_note_layout:
fontw, fonth = self._top_note_layout.get_pixel_size()
@@ -613,14 +613,14 @@
if val: self.set_text('X')
else: self.set_text('')
-
+
gobject.type_register(NumberBox)
class SudokuNumberGrid (gtk.AspectFrame):
def __init__ (self, group_size=9):
self.table = gtk.Table(rows=group_size,columns=group_size,homogeneous=True)
- self.group_size = group_size
+ self.group_size = group_size
self.__entries__ = {}
for x in range(self.group_size):
for y in range(self.group_size):
@@ -659,7 +659,7 @@
self.table.set_row_spacing(box_side*n-1,self.big_spacing)
self.table.set_col_spacing(box_side*n-1,self.big_spacing)
self.table.set_border_width(self.big_spacing)
-
+
def get_focused_entry (self):
return self.table.focus_child
@@ -689,7 +689,7 @@
Now for the cool part...
del pd[1]
pd -> {2: [2,3],3:[2],4:[2]}
-
+
Pretty neat, no?
"""
def __init__ (self, *args):
@@ -728,7 +728,7 @@
}
do_highlight_cells = False
-
+
@simple_debug
def __init__ (self,grid=None,group_size=9,
show_impossible_implications=False):
@@ -812,7 +812,7 @@
if not self.do_highlight_cells: return
self.unhighlight_cells()
if not hasattr(self,'box_color'): self.get_highlight_colors()
- my_x,my_y = self.focused.x,self.focused.y
+ my_x,my_y = self.focused.x,self.focused.y
# col_coords can sometimes be null.
if not hasattr(self.grid, 'col_coords'): return
@@ -832,10 +832,10 @@
e.set_background_color(self.box_and_row_color)
else:
e.set_background_color(self.box_color)
-
+
@simple_debug
- def show_hint (self):
+ def show_hint (self):
if hasattr(self,'focused'):
entry = self.focused
if entry.read_only or entry.get_text():
@@ -879,7 +879,7 @@
for x in range(self.group_size):
for y in range(self.group_size):
if not self.grid.virgin._get_(x,y):
- val = self.__entries__[(x,y)].get_value() # get the value from the user-visible grid,
+ val = self.__entries__[(x,y)].get_value() # get the value from the user-visible grid,
if val:
removed.append((x,y,val,self.trackers_for_point(x,y,val)))
self.remove(x,y,do_removal=True)
@@ -900,7 +900,7 @@
def clear_hints (self):
self.clear_notes(clear_args={'bottom_text':''})
-
+
@simple_debug
def blank_grid (self):
for x in range(self.group_size):
@@ -920,7 +920,7 @@
self.__trackers_tracking__ = {}
self.__colors_used__ = [None,ERROR_HIGHLIGHT_COLOR]
self.blank_grid()
- self.setup_grid(grid,group_size)
+ self.setup_grid(grid,group_size)
@simple_debug
def load_game (self, game):
@@ -960,7 +960,7 @@
self.doing_initial_setup = False
@simple_debug
- def entry_callback (self, widget, *args):
+ def entry_callback (self, widget, *args):
if not widget.get_text():
if self.grid and self.grid._get_(widget.x,widget.y):
self.grid.remove(widget.x,widget.y)
@@ -1021,14 +1021,14 @@
if tracker==-1: pass
self.__entries__[(x,y)].set_color(self.get_tracker_color(tracker))
self.trackers[tracker].append((x,y,val))
- elif True in self.__trackers_tracking__.values():
+ elif True in self.__trackers_tracking__.values():
for k,v in self.__trackers_tracking__.items():
if v:
self.__entries__[(x,y)].set_color(self.get_tracker_color(k))
self.trackers[k].append((x,y,val))
# Add value to our underlying sudoku grid -- this will raise
# an error if the value is out of bounds with the current
- # rules.
+ # rules.
try:
self.grid.add(x,y,val,True)
except sudoku.ConflictError, err:
@@ -1041,7 +1041,7 @@
"""Remove x,y from our visible grid.
If do_removal, remove it from our underlying grid as well.
- """
+ """
e=self.__entries__[(x,y)]
if do_removal and self.grid and self.grid._get_(x,y):
self.grid.remove(x,y)
@@ -1095,7 +1095,7 @@
if filled and filled!=-1:
e.set_text_interactive('')
e.set_text_interactive(str(filled[1]))
-
+
@simple_debug
def mark_impossible_implications (self, x, y):
if not self.grid: return
@@ -1167,7 +1167,7 @@
for y in range(self.group_size):
val = self.grid._get_(x,y)
if (val
- and (x,y,val) not in tracks
+ and (x,y,val) not in tracks
and not self.grid.virgin._get_(x,y)
):
removed.append((x,y,val,self.trackers_for_point(x,y,val)))
@@ -1188,7 +1188,7 @@
class GridDancer:
- DANCE_COLORS = [colors.color_hex_to_float(hx) for hx in
+ DANCE_COLORS = [colors.color_hex_to_float(hx) for hx in
[
'#cc0000', # red
'#ef2929',
@@ -1204,7 +1204,7 @@
]
STEPS_PER_ANIMATION = 10
-
+
def __init__ (self, grid):
self.animations = [self.value_dance,
self.box_dance,
@@ -1242,7 +1242,7 @@
].set_background_color(
random.choice(self.DANCE_COLORS)
)
-
+
def rotate_animation (self):
ci = self.animations.index(self.current_animation)
if (ci+1) == len(self.animations):
@@ -1275,7 +1275,7 @@
color = self.DANCE_COLORS[n]
for y in range(9):
self.grid.__entries__[(x,y)].set_background_color(color)
-
+
def row_dance (self):
for y in range(9):
n = (y + self.adjustment) % len(self.DANCE_COLORS)
@@ -1289,7 +1289,7 @@
color = self.DANCE_COLORS[n]
for x,y in self.grid.grid.box_coords[box]:
self.grid.__entries__[(x,y)].set_background_color(color)
-
+
def value_dance (self):
for value in range(10):
n = (value + self.adjustment) % len(self.DANCE_COLORS)
@@ -1308,7 +1308,7 @@
if __name__ == '__main__':
def test_sng ():
w = gtk.Window()
- w.connect('delete-event', gtk.main_quit)
+ w.connect('delete-event', gtk.main_quit)
t = SudokuNumberGrid(4)
w.add(t)
t.__entries__[(0,1)].set_color((0.0,1.0,0.0))
@@ -1335,7 +1335,7 @@
w.connect('delete-event', gtk.main_quit)
vb = gtk.VBox()
hb = gtk.HBox()
- swallower = SwappableArea(hb)
+ swallower = SwappableArea(hb)
tb = gtk.Toolbar()
b = gtk.ToolButton(stock_id=gtk.STOCK_QUIT)
b.connect('clicked',lambda x: w.hide() or gtk.main_quit())
@@ -1353,9 +1353,9 @@
from gtk_goodies.dialog_extras import MessageDialog
md = MessageDialog(title="Foo",label="Foo",sublabel="Bar "*12)
swallower.run_dialog(md)
- hb.pack_start(sgd,padding=6)
+ hb.pack_start(sgd,padding=6)
sgd.change_grid(SudokuGrid(sample_open_sudoku),9)
- gtk.main()
+ gtk.main()
def test_sudoku_game ():
from sudoku import SudokuGrid, sample_open_sudoku
@@ -1367,7 +1367,7 @@
w.show_all()
test_dance_grid(sgd)
gtk.main()
-
+
def test_number_selector ():
w = gtk.Window()
w.connect('delete-event',gtk.main_quit)
Modified: trunk/gnome-sudoku/src/lib/main.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/main.py (original)
+++ trunk/gnome-sudoku/src/lib/main.py Wed Apr 8 10:05:36 2009
@@ -78,7 +78,7 @@
<menuitem action="New"/>
<separator/>
<menuitem action="PuzzleInfo"/>
- <separator/>
+ <separator/>
<menuitem action="Print"/>
<menuitem action="PrintMany"/>
<separator/>
@@ -89,13 +89,13 @@
<menuitem action="Redo"/>
<separator/>
<menuitem action="Clear"/>
- <menuitem action="ClearNotes"/>
+ <menuitem action="ClearNotes"/>
</menu>
<menu action="View">
<menuitem action="FullScreen"/>
<separator/>
<menuitem action="ToggleToolbar"/>
- <menuitem action="ToggleHighlight"/>
+ <menuitem action="ToggleHighlight"/>
</menu>
<menu action="Tools">
<menuitem action="ShowPossible"/>
@@ -123,7 +123,7 @@
<toolitem action="Redo"/>
<separator/>
<toolitem action="ShowPossible"/>
- <toolitem action="AutofillCurrentSquare"/>
+ <toolitem action="AutofillCurrentSquare"/>
<separator/>
<toolitem action="ToggleHighlight"/>
<toolitem action="Tracker"/>
@@ -144,7 +144,7 @@
'width': 700,
'height': 675,
'auto_save_interval':60 # auto-save interval in seconds...
- }
+ }
@simple_debug
def __init__ (self, run_selector=True):
@@ -165,7 +165,7 @@
# setup sudoku maker...
self.sudoku_maker = sudoku_maker.SudokuMaker()
self.sudoku_tracker = saver.SudokuTracker()
- # generate puzzles while our use is working...
+ # generate puzzles while our use is working...
self.show()
if run_selector:
self.do_stop()
@@ -177,7 +177,7 @@
# Generate puzzles in background...
if self.gconf['generate_puzzles_in_background']:
gobject.timeout_add(1000,lambda *args: self.start_worker_thread() and True)
-
+
@inactivate_new_game_etc
def select_game (self):
@@ -193,7 +193,7 @@
if choice[0] == game_selector.NewOrSavedGameSelector.SAVED_GAME:
saver.open_game(self,choice[1])
self.update_statusbar()
- if self.gconf['show_toolbar']:
+ if self.gconf['show_toolbar']:
self.tb.show()
if self.gconf['always_show_hints']:
self.gsd.update_all_hints()
@@ -209,15 +209,15 @@
self.initialize_prefs()
self.setup_main_window()
self.gsd = gsudoku.SudokuGameDisplay()
- self.gsd.connect('puzzle-finished',self.you_win_callback)
+ self.gsd.connect('puzzle-finished',self.you_win_callback)
self.setup_color()
self.setup_actions()
self.setup_undo()
self.setup_autosave()
self.w.add_accel_group(self.uimanager.get_accel_group())
- self.setup_main_boxes()
+ self.setup_main_boxes()
self.setup_tracker_interface()
- self.setup_toggles()
+ self.setup_toggles()
def setup_main_window (self):
gtk.window_set_default_icon_name('gnome-sudoku')
@@ -225,11 +225,11 @@
self.w.set_default_size(self.gconf['width'], self.gconf['height'])
self.w.set_title(APPNAME_SHORT)
self.w.connect('configure-event',self.resize_cb)
- self.w.connect('delete-event',self.quit_cb)
+ self.w.connect('delete-event',self.quit_cb)
self.uimanager = gtk.UIManager()
def setup_actions (self):
- self.main_actions = gtk.ActionGroup('MainActions')
+ self.main_actions = gtk.ActionGroup('MainActions')
self.main_actions.add_actions([
('Game',None,_('_Game')),
('New',gtk.STOCK_NEW,None,
@@ -289,14 +289,14 @@
_('Generate new puzzles in the background while you play. This will automatically pause when the game goes into the background.'),
self.toggle_generator_cb, True),
])
-
+
self.edit_actions = gtk.ActionGroup('EditActions')
self.edit_actions.add_actions(
[('Edit',None,_('_Edit')),
('Undo',gtk.STOCK_UNDO,_('_Undo'),'<Control>z',_('Undo last action'), self.stop_dancer),
('Redo',gtk.STOCK_REDO,_('_Redo'),'<Shift><Control>z',_('Redo last action')),
('Clear',gtk.STOCK_CLEAR,_('_Clear'),'<Control>b',_("Clear entries you've filled in"),self.clear_cb),
- ('ClearNotes',None,_('Clear _Notes'),None,_("Clear notes and hints"),self.clear_notes_cb),
+ ('ClearNotes',None,_('Clear _Notes'),None,_("Clear notes and hints"),self.clear_notes_cb),
# Trackers...
('Tracker%s',None,_('No Tracker'),'<Control>0',None,lambda *args: self.set_tracker(-1)),
('Generator',None,_('_Generate new puzzles'),None,_('Generate new puzzles.'),
@@ -336,7 +336,7 @@
bgcol = 'black'
else:
bgcol = None
- if bgcol: self.gsd.set_bg_color(bgcol)
+ if bgcol: self.gsd.set_bg_color(bgcol)
def setup_autosave (self):
gobject.timeout_add(1000*(self.gconf['auto_save_interval'] or 60), # in seconds...
@@ -361,7 +361,7 @@
self.game_box.show()
self.main_area.pack_start(self.game_box,False,padding=12)
self.statusbar = gtk.Statusbar(); self.statusbar.show()
- self.vb.pack_end(self.statusbar,fill=False,expand=False)
+ self.vb.pack_end(self.statusbar,fill=False,expand=False)
self.w.add(self.vb)
def setup_by_hand_area (self):
@@ -369,7 +369,7 @@
self.by_hand_label = gtk.Label()
self.by_hand_label.set_alignment(0,0)
self.by_hand_label.set_markup('<i>%s</i>'%_('Entering custom grid...'))
- self.game_box.pack_start(self.by_hand_label,False,)#padding=12)
+ self.game_box.pack_start(self.by_hand_label,False,)#padding=12)
self.by_hand_buttonbox = gtk.HButtonBox()
self.by_hand_buttonbox.set_spacing(12)
self.by_hand_save_button = gtk.Button(_('_Play game'))
@@ -379,7 +379,7 @@
self.by_hand_buttonbox.add(self.by_hand_cancel_button)
self.by_hand_buttonbox.add(self.by_hand_save_button)
self.game_box.pack_start(self.by_hand_buttonbox,False,padding=18)
- self.by_hand_widgets = [self.by_hand_label,self.by_hand_buttonbox]
+ self.by_hand_widgets = [self.by_hand_label,self.by_hand_buttonbox]
def setup_toggles (self):
# sync up toggles with gconf values...
@@ -396,7 +396,7 @@
self.main_actions.get_action('ToggleHighlight')),
('show_tracker',
self.main_actions.get_action('Tracker')),
- ])
+ ])
@simple_debug
def start_worker_thread (self, *args):
@@ -447,7 +447,7 @@
self.gsd.auto_fills)%{'n':self.gsd.auto_fills}
from gsudoku import GridDancer
self.dancer = GridDancer(self.gsd)
- self.dancer.start_dancing()
+ self.dancer.start_dancing()
dialog_extras.show_message(_("You win!"),label=_("You win!"),
sublabel=sublabel
)
@@ -480,7 +480,7 @@
self.do_stop()
self.select_game()
-
+
@simple_debug
def stop_game (self):
if (self.gsd.grid
@@ -492,14 +492,14 @@
except dialog_extras.UserCancelledError:
return
self.do_stop()
-
+
def do_stop (self):
self.stop_dancer()
self.gsd.grid = None
self.tracker_ui.reset()
- self.history.clear()
+ self.history.clear()
self.won = False
-
+
@simple_debug
def resize_cb (self, widget, event):
self.gconf['width'] = event.width
@@ -533,7 +533,7 @@
self.gconf['current_game']=''
if not self.won:
if not self.gsd.grid:
- self.gconf['current_game']=''
+ self.gconf['current_game']=''
self.stop_worker_thread()
# allow KeyboardInterrupts, which calls quit_cb outside the main loop
try:
@@ -547,7 +547,7 @@
self.stop_game()
self.gsd.change_grid(sudoku.InteractiveSudoku(),9)
for w in self.by_hand_widgets: w.show_all()
-
+
@simple_debug
def save_handmade_grid (self, *args):
for w in self.by_hand_widgets: w.hide()
@@ -563,12 +563,12 @@
@simple_debug
def save_game (self, *args):
- self.sudoku_tracker.save_game(self)
+ self.sudoku_tracker.save_game(self)
@simple_debug
def zoom_in_cb (self,*args):
self.gh.change_font_size(multiplier=1.1)
- self.zoom = self.zoom * 1.1
+ self.zoom = self.zoom * 1.1
@simple_debug
def zoom_out_cb (self,*args):
@@ -583,9 +583,9 @@
else:
self.w.fullscreen()
self.is_fullscreen = True
-
+
@simple_debug
- def clear_cb (self,*args):
+ def clear_cb (self,*args):
clearer=Undo.UndoableObject(
self.do_clear, #action
self.undo_clear, #inverse
@@ -625,7 +625,7 @@
self.gsd.always_show_hints = True
self.gsd.update_all_hints()
else:
- self.gsd.always_show_hints = False
+ self.gsd.always_show_hints = False
self.gsd.clear_hints()
@simple_debug
@@ -663,7 +663,7 @@
@simple_debug
def setup_tracker_interface (self):
- self.trackers = {}
+ self.trackers = {}
self.tracker_ui = TrackerBox(self)
self.tracker_ui.show_all()
self.tracker_ui.hide()
@@ -682,7 +682,7 @@
self.gsd.add_tracker(e.x,e.y,n)
else:
print 'No tracker ',n,'yet'
-
+
@simple_debug
def tracker_toggle_cb (self, widg):
if widg.get_active():
@@ -703,7 +703,7 @@
def update_statusbar (self, *args):
- if not self.gsd.grid:
+ if not self.gsd.grid:
self.set_statusbar_value(" ")
return True
@@ -762,15 +762,15 @@
# have reason to...
if self.gsd.grid and self.gsd.grid.is_changed() and not self.won:
self.sudoku_tracker.save_game(self)
-
+
def offer_to_load_autosaved_file (self):
- pass
+ pass
@simple_debug
def load_autosave (self, filename):
saver.unpickle_game(self,filename)
self.history.clear()
-
+
@simple_debug
def show_about (self, *args):
about = gtk.AboutDialog()
@@ -778,8 +778,8 @@
about.set_name(APPNAME)
about.set_version(VERSION)
about.set_copyright(COPYRIGHT)
- about.set_license(LICENSE[0] + '\n\n' + LICENSE[1] + '\n\n' +LICENSE[2])
- about.set_wrap_license(True)
+ about.set_license(LICENSE[0] + '\n\n' + LICENSE[1] + '\n\n' +LICENSE[2])
+ about.set_wrap_license(True)
about.set_comments(DESCRIPTION)
about.set_authors(AUTHORS)
about.set_website(WEBSITE)
@@ -814,7 +814,7 @@
@simple_debug
def __init__ (self, main_ui):
-
+
gtk.VBox.__init__(self)
self.builder = gtk.Builder()
self.builder.add_from_file(os.path.join(GLADE_DIR,'tracker.ui'))
@@ -828,7 +828,7 @@
@simple_debug
def reset (self):
-
+
for tree in self.tracker_model:
if tree[0]>-1:
self.tracker_model.remove(tree.iter)
@@ -848,7 +848,7 @@
@simple_debug
def setup_actions (self):
- self.tracker_actions = gtk.ActionGroup('tracker_actions')
+ self.tracker_actions = gtk.ActionGroup('tracker_actions')
self.tracker_actions.add_actions(
[('Clear',
gtk.STOCK_CLEAR,
@@ -899,7 +899,7 @@
pb_str_new += chr(int(tc[1]*255))
pb_str_new += chr(int(tc[2]*255))
pb_str_new += alpha
-
+
return gtk.gdk.pixbuf_new_from_data(pb_str_new, gtk.gdk.COLORSPACE_RGB, True, 8, pb.get_width(), pb.get_height(), pb.get_rowstride())
@simple_debug
@@ -969,7 +969,7 @@
u = UI()
if not u.quit:
try:
- gtk.main()
+ gtk.main()
except KeyboardInterrupt:
# properly quit on a keyboard interrupt...
u.quit_cb()
@@ -983,13 +983,13 @@
prof.runcall(start_game)
stats = hotshot.stats.load(pname)
stats.strip_dirs()
- stats.sort_stats('time','calls').print_stats()
+ stats.sort_stats('time','calls').print_stats()
+
+
+
-
-
-
if __name__ == '__main__':
import defaults
defaults.DATA_DIR == '/tmp/'; DATA_DIR=='/tmp/'
-
+
Modified: trunk/gnome-sudoku/src/lib/pausable.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/pausable.py (original)
+++ trunk/gnome-sudoku/src/lib/pausable.py Wed Apr 8 10:05:36 2009
@@ -32,7 +32,7 @@
cls.terminate = lambda *args: self.terminate(cls)
cls.stop = lambda *args: self.terminate(cls)
self.init_wrap(cls.__init__)
-
+
def init_wrap (self, f):
def _(cls, *args, **kwargs):
@@ -58,6 +58,6 @@
while cls.paused:
if cls.terminated: raise "Terminated!"
time.sleep(self.sleep_for)
-
-
+
+
make_pausable = PausableWrapper()
Modified: trunk/gnome-sudoku/src/lib/printing.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/printing.py (original)
+++ trunk/gnome-sudoku/src/lib/printing.py Wed Apr 8 10:05:36 2009
@@ -84,7 +84,7 @@
cr.set_font_size(12)
cr.select_font_face("", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD)
- cr.set_source_rgb(0,0,0)
+ cr.set_source_rgb(0,0,0)
xbearing, ybearing, width, height, xadvance, yadvance = cr.text_extents(label)
cr.move_to(left, top-height/2)
cr.show_text(label)
@@ -140,7 +140,7 @@
('print_easy','easyCheckButton'),
('print_medium','mediumCheckButton'),
('print_hard','hardCheckButton'),
- ('print_very_hard','very_hardCheckButton'),
+ ('print_very_hard','very_hardCheckButton'),
]:
setattr(self,wname,self.builder.get_object(wname))
try: assert(getattr(self,wname))
Modified: trunk/gnome-sudoku/src/lib/saver.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/saver.py (original)
+++ trunk/gnome-sudoku/src/lib/saver.py Wed Apr 8 10:05:36 2009
@@ -65,7 +65,7 @@
if jar.has_key('notes') and jar['notes']:
for x,y,top,bot in jar['notes']:
ui.gsd.__entries__[(x,y)].set_note_text(top,bot)
-
+
def pickle_game (ui, target):
close_me = False
if type(target) in types.StringTypes:
@@ -74,7 +74,7 @@
to_dump = jar_game(ui)
pickle.dump(to_dump,target)
if close_me: target.close()
-
+
def unpickle_game (ui, target):
close_me = False
if type(target)==str:
@@ -98,7 +98,7 @@
if not os.path.exists(path):
try:
os.makedirs(path)
- except OSError, e:
+ except OSError, e:
if e.errno == errno.ENOSPC:
show_message(
title=_('No Space'),
@@ -115,7 +115,7 @@
_('Error %(errno)s: %(error)s')%{'errno':e.errno,
'error':e.strerror}
)
-
+
def game_from_ui (self, ui):
return ui.gsd.grid.virgin.to_string()
@@ -197,7 +197,7 @@
game = self.game_from_ui(ui)
jar = jar_game(ui)
self.remove_from_saved_games(jar)
-
+
def list_saved_games (self):
try:
files = os.listdir(self.save_path)
Modified: trunk/gnome-sudoku/src/lib/simple_debug.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/simple_debug.py (original)
+++ trunk/gnome-sudoku/src/lib/simple_debug.py Wed Apr 8 10:05:36 2009
@@ -19,8 +19,8 @@
options,args = parser.parse_args()
-
-# Make a lovely wrapper
+
+# Make a lovely wrapper
if options.debug:
def simple_debug (f):
def _ (self, *args,**kwargs):
Modified: trunk/gnome-sudoku/src/lib/sudoku.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/sudoku.py (original)
+++ trunk/gnome-sudoku/src/lib/sudoku.py Wed Apr 8 10:05:36 2009
@@ -44,7 +44,7 @@
class ConflictError (ValueError):
-
+
def __init__ (self, conflict_type, coordinates, value):
self.args = conflict_type,coordinates,value
self.type = conflict_type
@@ -55,7 +55,7 @@
class AlreadySetError (ValueError):
pass
-
+
class SudokuGrid:
def __init__ (self, grid=False, verbose=False, group_size=9):
self.grid = []
@@ -115,9 +115,9 @@
import traceback
traceback.print_exc()
else:
- #FIXME: This is called when the fill button
- #is clicked multiple times, which causes this exception:
- #raise AlreadySetError
+ #FIXME: This is called when the fill button
+ #is clicked multiple times, which causes this exception:
+ #raise AlreadySetError
return;
if val in self.rows[y]:
raise ConflictError(TYPE_ROW,(x,y),val)
@@ -178,7 +178,7 @@
def find_conflicts (self, x, y, val, conflict_type=None):
'''Find all squares that conflict with value val at position x,y.
-
+
If conflict_type is specified, we only find conflicts of given
type (ROW, COLUMN OR BOX).
'''
@@ -205,7 +205,7 @@
def is_valid_puzzle (p):
"""Check puzzle for basic validity.
-
+
This does not check for solvability or ensure a unique
solution -- it merely checks well-formedness. This should
provide some protection again file corruption, etc. (i.e. if
@@ -231,7 +231,7 @@
i = 0
for x in range(GROUP_SIZE):
row = []
- for y in range(GROUP_SIZE):
+ for y in range(GROUP_SIZE):
if len(s) <= i: n = 0
else: n = s[i]
try:
@@ -245,11 +245,11 @@
i += 1
grid.append(row)
return SudokuGrid(grid)
-
+
class SudokuSolver (SudokuGrid):
"""A SudokuGrid that can solve itself."""
- def __init__ (self, grid=False, verbose=False,group_size=9):
+ def __init__ (self, grid=False, verbose=False,group_size=9):
self.current_guess = None
self.initialized=False
SudokuGrid.__init__(self,grid,verbose=verbose,group_size=group_size)
@@ -291,7 +291,7 @@
return -1
if len(needed_set)>1:
return -1
-
+
def auto_fill (self):
changed = []
try: changed = self.fill_must_fills()
@@ -333,7 +333,7 @@
"%s,%s must be two values at once!"%(coords)
)
return changed
-
+
def fill_must_fills_2 (self):
changed = []
for label,coord_dic,filled_dic in [('Column',self.col_coords,self.cols),
@@ -378,7 +378,7 @@
needed_dic = {}
for c in needed: needed_dic[c]=[]
# just work on the open squares
- coord_set = filter(lambda coords: not self._get_(*coords),coord_set)
+ coord_set = filter(lambda coords: not self._get_(*coords),coord_set)
for xy,poss_set in [(c,self.possible_values(*c)) for c in coord_set]:
# our set of values we can fill is now greater...
values = values|poss_set
@@ -409,7 +409,7 @@
def scan_must_fills (self):
"""Scan to find how many fill_must_fills we could fill in with
100% positivity based on the grid as it currently stands (not
- using the *cumulative* results"""
+ using the *cumulative* results"""
# we do this by temporarily disabling the add call
self.fake_add = True
self.fake_added = []
@@ -470,7 +470,7 @@
if not poss:
if self.verbose: print 'Solved!'
return True
- # otherwise, find the possibility with the least possibilities
+ # otherwise, find the possibility with the least possibilities
poss.sort(lambda a,b: len(a[1])>len(b[1]) and 1 or len(a[1])<len(b[1]) and -1 or \
a[0]>b[0] and 1 or a[1]<b[1] and -1 or 0)
least = poss[0]
@@ -586,7 +586,7 @@
return (self.grid!=self.virgin.grid)
class DifficultyRating:
-
+
very_hard = _('Very Hard')
hard = _('Hard')
medium = _('Medium')
@@ -607,7 +607,7 @@
'medium':medium,
'hard':hard,
'very hard':very_hard}
-
+
def __init__ (self,
fill_must_fillables,
elimination_fillables,
@@ -615,7 +615,7 @@
backtraces,
squares_filled):
self.fill_must_fillables = fill_must_fillables
- self.elimination_fillables = elimination_fillables
+ self.elimination_fillables = elimination_fillables
self.guesses = guesses
self.backtraces = backtraces
self.squares_filled = squares_filled
@@ -627,7 +627,7 @@
self.instant_elimination_fillable = float(len(self.elimination_fillables[0]))
else:
self.instant_elimination_fillable = 0.0
-
+
self.proportion_instant_elimination_fillable = self.instant_elimination_fillable/self.squares_filled
# some more numbers that may be crazy...
self.proportion_instant_fill_fillable = self.instant_fill_fillable/self.squares_filled
@@ -794,7 +794,7 @@
self.remove(g)
nuked += [g]
return nuked
-
+
class BreadcrumbTrail (GuessList):
def append (self, guess):
# Raise an error if we add something to ourselves twice
Modified: trunk/gnome-sudoku/src/lib/sudoku_maker.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/sudoku_maker.py (original)
+++ trunk/gnome-sudoku/src/lib/sudoku_maker.py Wed Apr 8 10:05:36 2009
@@ -51,7 +51,7 @@
x,y = upper - y,upper-x
# reflect twice...
return y, x
-
+
def make_symmetric_puzzle (self):
nclues = self.clues/2
buckshot = set(random.sample(self.all_coords,nclues))
@@ -86,7 +86,7 @@
new_puzzle.add(x,y,self.start_grid._get_(x,y))
self.puzzles.append(new_puzzle)
return new_puzzle
-
+
def make_puzzle_by_boxes (self,
skew_by=0.0,
max_squares=None,):
@@ -133,7 +133,7 @@
clued += clues
if skew_by:
# Reduce our number of squares proportionally to
- # skewiness.
+ # skewiness.
max_squares = round(max_squares * skew_by)
# shuffle ourselves...
random.shuffle(nclues)
@@ -171,7 +171,7 @@
return solver.difficulty()
else:
return None
-
+
def generate_puzzle_for_difficulty (self,
lower_target=0.3,
upper_target=0.5,
@@ -329,7 +329,7 @@
except:
print 'Problem copying base puzzles'
print 'Attempted to copy from %s to %s' % (source, target)
-
+
def get_pregenerated (self, difficulty):
fname = os.path.join(self.pickle_to, difficulty.replace(' ','_'))
try:
@@ -340,7 +340,7 @@
return []
else:
return [line.strip() for line in lines]
-
+
def get_new_puzzle (self, difficulty, new=True):
"""Return puzzle with difficulty near difficulty.
@@ -449,7 +449,7 @@
if i < n:
print 'WARNING: Not able to provide %s puzzles in levels %s'%(n,levels)
print 'WARNING: Generate more puzzles if you really need this many puzzles!'
- return puzzles
+ return puzzles
def get_puzzles (self, n, levels, new=True, randomize=True,
exclude=[]):
@@ -462,7 +462,7 @@
if not n: return []
assert(levels)
puzzles = []
-
+
# Open files to read puzzles...
files = {}
for l in levels:
@@ -478,7 +478,7 @@
if lev in finished:
il += 1
continue
-
+
if len(files[lev]) == 0:
finished.append(lev)
else:
@@ -500,7 +500,7 @@
print 'WARNING: Not able to provide %s puzzles in levels %s'%(n,levels)
print 'WARNING: Generate more puzzles if you really need this many puzzles!'
- return puzzles
+ return puzzles
# End convenience methods for accessing puzzles we've created
@@ -508,8 +508,8 @@
def make_batch (self, diff_min=None, diff_max=None):
self.new_generator = InterruptibleSudokuGenerator(**self.generator_args)
- key = self.new_generator.start_grid.to_string()
- #while
+ key = self.new_generator.start_grid.to_string()
+ #while
# self.new_generator = InterruptibleSudokuGenerator(**self.generator_args)
# key = self.new_generator.start_grid.to_string()
#print 'We have our solution grid'
@@ -581,7 +581,7 @@
def get_difficulty (self, puz):
return sudoku.SudokuRater(puz).difficulty()
-
+
if __name__ == '__main__':
import time
#puzzles=sg.generate_puzzles(30)
@@ -595,7 +595,7 @@
#unique_puzzles=filter(lambda x: sudoku.SudokuSolver(x[0].grid,verbose=False).has_unique_solution(),puzzles)
sm = SudokuMaker()
#st = SudokuTracker(sm)
-elif False:
+elif False:
usage="""Commands are:
run: Run sudoku-maker
len: \# of puzzles generated
Modified: trunk/gnome-sudoku/src/lib/sudoku_thumber.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/sudoku_thumber.py (original)
+++ trunk/gnome-sudoku/src/lib/sudoku_thumber.py Wed Apr 8 10:05:36 2009
@@ -23,7 +23,7 @@
)
SQUARE_SIZE = WHITE_SPACE / SUDOKU_SIZE
- FONT_SIZE = SQUARE_SIZE
+ FONT_SIZE = SQUARE_SIZE
outer = {}
outer["left"] = offset_x
@@ -54,7 +54,7 @@
cr.set_source_rgb(*border_color)
cr.stroke()
- #Outer thick lines
+ #Outer thick lines
cr.set_line_join(cairo.LINE_JOIN_MITER)
cr.set_line_width(THICK)
cr.rectangle(outer["left"] + BORDER + THICK/2.0,
@@ -100,10 +100,10 @@
cr.select_font_face("",
cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_BOLD)
- cr.set_source_rgb(0,0,0)
+ cr.set_source_rgb(0,0,0)
xbearing,ybearing,width,height,xadvance,yadvance = (
cr.text_extents(letter)
- )
+ )
elif played and played[y][x]:
cr.select_font_face("Times",
Modified: trunk/gnome-sudoku/src/lib/timer.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/timer.py (original)
+++ trunk/gnome-sudoku/src/lib/timer.py Wed Apr 8 10:05:36 2009
@@ -119,7 +119,7 @@
'timing-started':(gobject.SIGNAL_RUN_LAST,gobject.TYPE_NONE,()),
'timing-stopped':(gobject.SIGNAL_RUN_LAST,gobject.TYPE_NONE,())
}
-
+
def __init__ (self, window):
gobject.GObject.__init__(self)
self.window = window
@@ -130,8 +130,8 @@
self.window.connect('window-state-event',self.window_state_event_cb)
self.window.connect('state-changed',self.window_state_event_cb)
self.window.connect('visibility-notify-event',self.window_state_event_cb)
- self.window.connect('expose-event',self.window_state_event_cb)
- self.window.connect('no-expose-event',self.window_state_event_cb)
+ self.window.connect('expose-event',self.window_state_event_cb)
+ self.window.connect('no-expose-event',self.window_state_event_cb)
def window_state_event_cb (self, *args):
if self.window.is_active():
@@ -143,7 +143,7 @@
if not self.__absolute_start_time__:
return
- if on and not self.timing_running:
+ if on and not self.timing_running:
self.timing_started_at = time.time()
self.timing_running = True
self.emit('timing-started')
@@ -174,7 +174,7 @@
# make sure to call finish_timing before using this function
def active_time_string (self):
return format_time(self.tot_time)
-
+
# make sure to call finish_timing before using this function
def total_time_string (self):
return format_time(self.tot_time_complete)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]