gnome-games r9035 - trunk/gnome-sudoku/src/lib
- From: thomashpa svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r9035 - trunk/gnome-sudoku/src/lib
- Date: Fri, 10 Apr 2009 23:10:46 +0000 (UTC)
Author: thomashpa
Date: Fri Apr 10 23:10:46 2009
New Revision: 9035
URL: http://svn.gnome.org/viewvc/gnome-games?rev=9035&view=rev
Log:
fixes various issues found with pychecker
Modified:
trunk/gnome-sudoku/src/lib/game_selector.py
trunk/gnome-sudoku/src/lib/gsudoku.py
trunk/gnome-sudoku/src/lib/main.py
trunk/gnome-sudoku/src/lib/printing.py
trunk/gnome-sudoku/src/lib/saver.py
trunk/gnome-sudoku/src/lib/sudoku_thumber.py
trunk/gnome-sudoku/src/lib/timer.py
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 Fri Apr 10 23:10:46 2009
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
import gtk, gobject, time
-import sudoku, saver, sudoku_maker, random
-from sudoku import DifficultyRating as DR
+import sudoku, saver, sudoku_maker
import sudoku_thumber
from gettext import gettext as _
from timer import format_time,format_friendly_date
@@ -11,6 +10,7 @@
from gtk_goodies import gconf_wrapper
def color_from_difficulty (diff):
+ DR = sudoku.DifficultyRating
if diff < DR.easy_range[1]:
if diff < DR.easy_range[1]/3: c='#8ae234' # green
elif diff < 2*DR.easy_range[1]/3: c='#73d216'
@@ -72,7 +72,6 @@
self.new_game_view.set_model(self.new_game_model)
self.new_game_view.set_markup_column(0)
self.new_game_view.set_pixbuf_column(1)
- selected_puzzle = None
self.make_saved_game_model()
if len(self.saved_game_model)==0:
for w in self.saved_game_widgets: w.hide()
@@ -96,8 +95,8 @@
saved_games_to_exclude = [
g['game'].split('\n')[0] for g in self.saved_games
]
- for cat in DR.ordered_categories:
- rng = DR.categories[cat]; label = DR.label_by_cat[cat]
+ for cat in sudoku.DifficultyRating.ordered_categories:
+ label = sudoku.DifficultyRating.label_by_cat[cat]
puzzles = self.sudoku_maker.get_puzzles(1,[cat],new=True,
exclude=saved_games_to_exclude
)
Modified: trunk/gnome-sudoku/src/lib/gsudoku.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/gsudoku.py (original)
+++ trunk/gnome-sudoku/src/lib/gsudoku.py Fri Apr 10 23:10:46 2009
@@ -865,11 +865,6 @@
set_method(bottom_text="")
@simple_debug
- def num_to_str (self, n):
- if n >= 10: return SuperNumberEntry.conversions[n]
- else: return str(n)
-
- @simple_debug
def reset_grid (self):
"""Reset grid to its original setup.
Modified: trunk/gnome-sudoku/src/lib/main.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/main.py (original)
+++ trunk/gnome-sudoku/src/lib/main.py Fri Apr 10 23:10:46 2009
@@ -921,8 +921,7 @@
def profile_me ():
print 'Profiling GNOME Sudoku'
- import tempfile,os.path
- import hotshot, hotshot.stats
+ import tempfile, hotshot, hotshot.stats
pname = os.path.join(tempfile.gettempdir(),'GNOME_SUDOKU_HOTSHOT_PROFILE')
prof = hotshot.Profile(pname)
prof.runcall(start_game)
@@ -930,10 +929,3 @@
stats.strip_dirs()
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/printing.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/printing.py (original)
+++ trunk/gnome-sudoku/src/lib/printing.py Fri Apr 10 23:10:46 2009
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-import gtk, cairo
-import sudoku, gsudoku
+import gtk, cairo, time
+import sudoku, gsudoku, saver
from defaults import *
-from sudoku import DifficultyRating as DR
from gtk_goodies import gconf_wrapper
from gettext import gettext as _
from gettext import ngettext
@@ -59,7 +58,6 @@
operation.set_n_pages(pages)
def draw_page(self, operation, context, page_nr):
- import pango
import sudoku_thumber
margin = 25
@@ -107,7 +105,7 @@
sp = SudokuPrinter(*args,**kwargs)
res = sp.print_op.run(gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG, sp.main_window)
if res == gtk.PRINT_OPERATION_RESULT_ERROR:
- error_dialog = gtk.MessageDialog(main_window,
+ error_dialog = gtk.MessageDialog(sp.main_window,
gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_ERROR,
gtk.BUTTONS_CLOSE,
@@ -162,13 +160,13 @@
return
# Otherwise, we're printing!
levels = []
- for cat in DR.categories:
+ for cat in sudoku.DifficultyRating.categories:
if getattr(self,
cat.replace(' ','_')+'CheckButton'
).get_active():
levels.append(cat)
if not levels:
- levels = DR.categories.keys()
+ levels = sudoku.DifficultyRating.categories.keys()
nsudokus = self.sudokusToPrintSpinButton.get_adjustment().get_value()
sudokus = self.sudoku_maker.get_puzzles(
nsudokus,
@@ -180,7 +178,6 @@
sudokus = [(sudoku.sudoku_grid_from_string(puzzle),
"%s (%.2f)"%(sudoku.get_difficulty_category_name(d),d)
) for puzzle,d in sudokus]
- from printing import SudokuPrinter
sp = SudokuPrinter(sudokus,
self.dialog,
sudokus_per_page=self.sudokusPerPageSpinButton.get_adjustment().get_value())
Modified: trunk/gnome-sudoku/src/lib/saver.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/saver.py (original)
+++ trunk/gnome-sudoku/src/lib/saver.py Fri Apr 10 23:10:46 2009
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-import pickle, types, os, os.path, sudoku, errno
+import gtk, pickle, types, os, os.path, errno
from defaults import *
from gtk_goodies.dialog_extras import show_message
from gettext import gettext as _
@@ -139,7 +139,6 @@
return gamestring.split('\n')[0].replace(' ','')
def save_game (self, ui):
- game = self.game_from_ui(ui)
jar = jar_game(ui)
filename = os.path.join(self.save_path,self.get_filename(jar['game']))
try:
@@ -160,7 +159,6 @@
)
def finish_game (self, ui):
- game = self.game_from_ui(ui)
jar = jar_game(ui)
self.finish_jar(jar)
@@ -210,14 +208,13 @@
os.remove(os.path.join(previously_saved_game))
def abandon_game (self, ui):
- 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)
- except OSError, e:
+ except OSError:
files = []
games = []
for f in files:
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 Fri Apr 10 23:10:46 2009
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-import cairo
-import pango
-import gtk
+import gtk, cairo
SUDOKU_SIZE = 9
N_BOXES = 3
Modified: trunk/gnome-sudoku/src/lib/timer.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/timer.py (original)
+++ trunk/gnome-sudoku/src/lib/timer.py Fri Apr 10 23:10:46 2009
@@ -42,7 +42,7 @@
time_strings.append(unit_formatter(time_covered))
time = time - time_covered * divisor
if friendly and len(time_strings)>2:
- time_stings = time_strings[:2]
+ time_strings = time_strings[:2]
if len(time_strings)>2:
# Translators... this is a messay way of concatenating
# lists. In English we do lists this way: 1, 2, 3, 4, 5
@@ -83,8 +83,6 @@
def format_friendly_date (tim):
lt = time.localtime(tim)
- hours = int(time.strftime("%H",lt))
- minutes = int(time.strftime("%M",lt))
diff = time.time() - tim
ct = time.localtime(); chour=ct[3]; cmin=ct[4]
to_yesterday = chour*60*60+cmin*60
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]