mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake 8
This commit is contained in:
parent
99ef711af1
commit
d77ef531ad
2 changed files with 61 additions and 60 deletions
|
@ -22,7 +22,8 @@
|
||||||
# ---------------------------------------------------------------------------##
|
# ---------------------------------------------------------------------------##
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
import sys, os
|
import sys
|
||||||
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
|
@ -34,7 +35,10 @@ import pysollib.settings
|
||||||
# Toolkit imports
|
# Toolkit imports
|
||||||
from pysollib.pysoltk import TOOLBAR_BUTTONS
|
from pysollib.pysoltk import TOOLBAR_BUTTONS
|
||||||
|
|
||||||
from pysollib.mygettext import _, n_
|
from pysollib.mygettext import _
|
||||||
|
|
||||||
|
if sys.version_info > (3,):
|
||||||
|
unicode = str
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * Options
|
# * Options
|
||||||
|
@ -240,16 +244,16 @@ class Options:
|
||||||
('tabletile_name', 'str'),
|
('tabletile_name', 'str'),
|
||||||
('translate_game_names', 'bool'),
|
('translate_game_names', 'bool'),
|
||||||
('solver_presets', 'list'),
|
('solver_presets', 'list'),
|
||||||
#('toolbar_vars', 'list'),
|
# ('toolbar_vars', 'list'),
|
||||||
#('recent_gameid', 'list'),
|
# ('recent_gameid', 'list'),
|
||||||
#('favorite_gameid', 'list'),
|
# ('favorite_gameid', 'list'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._config = None # configobj.ConfigObj instance
|
self._config = None # configobj.ConfigObj instance
|
||||||
self._config_encoding = 'utf-8'
|
self._config_encoding = 'utf-8'
|
||||||
|
|
||||||
self.version_tuple = pysollib.settings.VERSION_TUPLE # XXX
|
self.version_tuple = pysollib.settings.VERSION_TUPLE # XXX
|
||||||
self.saved = 0 # XXX
|
self.saved = 0 # XXX
|
||||||
# options menu:
|
# options menu:
|
||||||
self.player = _("Unknown")
|
self.player = _("Unknown")
|
||||||
|
@ -268,7 +272,7 @@ class Options:
|
||||||
self.highlight_samerank = True
|
self.highlight_samerank = True
|
||||||
self.highlight_not_matching = True
|
self.highlight_not_matching = True
|
||||||
self.mahjongg_show_removed = False
|
self.mahjongg_show_removed = False
|
||||||
self.mahjongg_create_solvable = 2 # 0 - none, 1 - easy, 2 - hard
|
self.mahjongg_create_solvable = 2 # 0 - none, 1 - easy, 2 - hard
|
||||||
self.shisen_show_hint = True
|
self.shisen_show_hint = True
|
||||||
self.shisen_show_matching = False
|
self.shisen_show_matching = False
|
||||||
self.animations = 3 # default to Medium
|
self.animations = 3 # default to Medium
|
||||||
|
@ -284,21 +288,21 @@ class Options:
|
||||||
self.tile_theme = 'default'
|
self.tile_theme = 'default'
|
||||||
self.default_tile_theme = 'default'
|
self.default_tile_theme = 'default'
|
||||||
self.toolbar = 1 # 0 == hide, 1,2,3,4 == top, bottom, lef, right
|
self.toolbar = 1 # 0 == hide, 1,2,3,4 == top, bottom, lef, right
|
||||||
##self.toolbar_style = 'default'
|
# self.toolbar_style = 'default'
|
||||||
self.toolbar_style = 'bluecurve'
|
self.toolbar_style = 'bluecurve'
|
||||||
self.toolbar_relief = 'flat'
|
self.toolbar_relief = 'flat'
|
||||||
self.toolbar_compound = 'none' # icons only
|
self.toolbar_compound = 'none' # icons only
|
||||||
self.toolbar_size = 0
|
self.toolbar_size = 0
|
||||||
self.toolbar_vars = {}
|
self.toolbar_vars = {}
|
||||||
for w in TOOLBAR_BUTTONS:
|
for w in TOOLBAR_BUTTONS:
|
||||||
self.toolbar_vars[w] = True # show all buttons
|
self.toolbar_vars[w] = True # show all buttons
|
||||||
self.statusbar = True
|
self.statusbar = True
|
||||||
self.statusbar_game_number = False # show game number in statusbar
|
self.statusbar_game_number = False # show game number in statusbar
|
||||||
self.statusbar_stuck = False # show stuck indicator
|
self.statusbar_stuck = False # show stuck indicator
|
||||||
self.num_cards = False
|
self.num_cards = False
|
||||||
self.helpbar = False
|
self.helpbar = False
|
||||||
self.splashscreen = True
|
self.splashscreen = True
|
||||||
self.mouse_type = 'drag-n-drop' # or 'sticky-mouse' or 'point-n-click'
|
self.mouse_type = 'drag-n-drop' # or 'sticky-mouse' or 'point-n-click'
|
||||||
self.mouse_undo = False # use mouse for undo/redo
|
self.mouse_undo = False # use mouse for undo/redo
|
||||||
self.negative_bottom = True
|
self.negative_bottom = True
|
||||||
self.translate_game_names = True
|
self.translate_game_names = True
|
||||||
|
@ -307,42 +311,42 @@ class Options:
|
||||||
self.sound_mode = 1
|
self.sound_mode = 1
|
||||||
self.sound_sample_volume = 80
|
self.sound_sample_volume = 80
|
||||||
self.sound_music_volume = 100
|
self.sound_music_volume = 100
|
||||||
self.sound_sample_buffer_size = 1 # 1 - 4 (1024 - 4096 bytes)
|
self.sound_sample_buffer_size = 1 # 1 - 4 (1024 - 4096 bytes)
|
||||||
self.sound_samples = {
|
self.sound_samples = {
|
||||||
'areyousure' : True,
|
'areyousure': True,
|
||||||
'autodrop' : True,
|
'autodrop': True,
|
||||||
'autoflip' : True,
|
'autoflip': True,
|
||||||
'autopilotlost' : True,
|
'autopilotlost': True,
|
||||||
'autopilotwon' : True,
|
'autopilotwon': True,
|
||||||
'deal' : True,
|
'deal': True,
|
||||||
'dealwaste' : True,
|
'dealwaste': True,
|
||||||
'droppair' : True,
|
'droppair': True,
|
||||||
'drop' : True,
|
'drop': True,
|
||||||
#'extra' : True,
|
# 'extra': True,
|
||||||
'flip' : True,
|
'flip': True,
|
||||||
'move' : True,
|
'move': True,
|
||||||
'nomove' : True,
|
'nomove': True,
|
||||||
'redo' : True,
|
'redo': True,
|
||||||
'startdrag' : True,
|
'startdrag': True,
|
||||||
'turnwaste' : True,
|
'turnwaste': True,
|
||||||
'undo' : True,
|
'undo': True,
|
||||||
'gamefinished' : False,
|
'gamefinished': False,
|
||||||
'gamelost' : False,
|
'gamelost': False,
|
||||||
'gameperfect' : False,
|
'gameperfect': False,
|
||||||
'gamewon' : False,
|
'gamewon': False,
|
||||||
}
|
}
|
||||||
# fonts
|
# fonts
|
||||||
self.fonts = {
|
self.fonts = {
|
||||||
"default" : None,
|
"default": None,
|
||||||
#"default" : ("helvetica", 12),
|
# "default": ("helvetica", 12),
|
||||||
"sans" : ("times", 12), # for html
|
"sans": ("times", 12), # for html
|
||||||
"fixed" : ("courier", 12), # for html & log
|
"fixed": ("courier", 12), # for html & log
|
||||||
"small" : ("helvetica", 12),
|
"small": ("helvetica", 12),
|
||||||
"canvas_default" : ("helvetica", 12),
|
"canvas_default": ("helvetica", 12),
|
||||||
#"canvas_card" : ("helvetica", 12),
|
# "canvas_card": ("helvetica", 12),
|
||||||
"canvas_fixed" : ("courier", 12),
|
"canvas_fixed": ("courier", 12),
|
||||||
"canvas_large" : ("helvetica", 16),
|
"canvas_large": ("helvetica", 16),
|
||||||
"canvas_small" : ("helvetica", 10),
|
"canvas_small": ("helvetica", 10),
|
||||||
}
|
}
|
||||||
# colors
|
# colors
|
||||||
self.colors = {
|
self.colors = {
|
||||||
|
@ -373,8 +377,9 @@ class Options:
|
||||||
self.game_holded = 0 # gameid or 0
|
self.game_holded = 0 # gameid or 0
|
||||||
self.wm_maximized = 0
|
self.wm_maximized = 0
|
||||||
self.save_games_geometry = False
|
self.save_games_geometry = False
|
||||||
self.games_geometry = {} # saved games geometry (gameid: (width, height))
|
# saved games geometry (gameid: (width, height))
|
||||||
self.game_geometry = (0, 0) # game geometry before exit
|
self.games_geometry = {}
|
||||||
|
self.game_geometry = (0, 0) # game geometry before exit
|
||||||
self.offsets = {} # cards offsets
|
self.offsets = {} # cards offsets
|
||||||
#
|
#
|
||||||
self.randomize_place = False
|
self.randomize_place = False
|
||||||
|
@ -409,7 +414,7 @@ class Options:
|
||||||
def setDefaults(self, top=None):
|
def setDefaults(self, top=None):
|
||||||
WIN_SYSTEM = pysollib.settings.WIN_SYSTEM
|
WIN_SYSTEM = pysollib.settings.WIN_SYSTEM
|
||||||
# toolbar
|
# toolbar
|
||||||
#if WIN_SYSTEM == 'win32':
|
# if WIN_SYSTEM == 'win32':
|
||||||
# self.toolbar_style = 'crystal'
|
# self.toolbar_style = 'crystal'
|
||||||
# fonts
|
# fonts
|
||||||
if WIN_SYSTEM == 'win32':
|
if WIN_SYSTEM == 'win32':
|
||||||
|
@ -420,7 +425,7 @@ class Options:
|
||||||
# tile theme
|
# tile theme
|
||||||
if WIN_SYSTEM == 'win32':
|
if WIN_SYSTEM == 'win32':
|
||||||
self.tile_theme = self.default_tile_theme = 'winnative'
|
self.tile_theme = self.default_tile_theme = 'winnative'
|
||||||
if sys.getwindowsversion() >= (5, 1): # xp
|
if sys.getwindowsversion() >= (5, 1): # xp
|
||||||
self.tile_theme = 'xpnative'
|
self.tile_theme = 'xpnative'
|
||||||
elif WIN_SYSTEM == 'x11':
|
elif WIN_SYSTEM == 'x11':
|
||||||
self.tile_theme = 'clam'
|
self.tile_theme = 'clam'
|
||||||
|
@ -435,14 +440,14 @@ class Options:
|
||||||
top.winfo_screendepth())
|
top.winfo_screendepth())
|
||||||
# bg
|
# bg
|
||||||
if sd > 8:
|
if sd > 8:
|
||||||
self.tabletile_name = "Nostalgy.gif" # basename
|
self.tabletile_name = "Nostalgy.gif" # basename
|
||||||
else:
|
else:
|
||||||
self.tabletile_name = None
|
self.tabletile_name = None
|
||||||
# cardsets
|
# cardsets
|
||||||
c = "Standard"
|
c = "Standard"
|
||||||
if sw < 800 or sh < 600:
|
if sw < 800 or sh < 600:
|
||||||
c = "2000"
|
c = "2000"
|
||||||
#if sw > 1024 and sh > 768:
|
# if sw > 1024 and sh > 768:
|
||||||
# c = 'Dondorf'
|
# c = 'Dondorf'
|
||||||
self.cardset = {
|
self.cardset = {
|
||||||
# game_type: (cardset_name, back_file)
|
# game_type: (cardset_name, back_file)
|
||||||
|
@ -453,7 +458,7 @@ class Options:
|
||||||
CSI.TYPE_TAROCK: ("Vienna 2K", ""),
|
CSI.TYPE_TAROCK: ("Vienna 2K", ""),
|
||||||
CSI.TYPE_HEXADECK: ("Hex A Deck", ""),
|
CSI.TYPE_HEXADECK: ("Hex A Deck", ""),
|
||||||
CSI.TYPE_MUGHAL_GANJIFA: ("Mughal Ganjifa", ""),
|
CSI.TYPE_MUGHAL_GANJIFA: ("Mughal Ganjifa", ""),
|
||||||
##CSI.TYPE_NAVAGRAHA_GANJIFA: ("Navagraha Ganjifa", ""),
|
# CSI.TYPE_NAVAGRAHA_GANJIFA: ("Navagraha Ganjifa", ""),
|
||||||
CSI.TYPE_NAVAGRAHA_GANJIFA: ("Dashavatara Ganjifa", ""),
|
CSI.TYPE_NAVAGRAHA_GANJIFA: ("Dashavatara Ganjifa", ""),
|
||||||
CSI.TYPE_DASHAVATARA_GANJIFA: ("Dashavatara Ganjifa", ""),
|
CSI.TYPE_DASHAVATARA_GANJIFA: ("Dashavatara Ganjifa", ""),
|
||||||
CSI.TYPE_TRUMP_ONLY: ("Matrix", ""),
|
CSI.TYPE_TRUMP_ONLY: ("Matrix", ""),
|
||||||
|
@ -527,8 +532,7 @@ class Options:
|
||||||
config['offsets'][key] = val
|
config['offsets'][key] = val
|
||||||
|
|
||||||
config.write()
|
config.write()
|
||||||
##config.write(sys.stdout); print
|
# config.write(sys.stdout); print
|
||||||
|
|
||||||
|
|
||||||
def _getOption(self, section, key, t):
|
def _getOption(self, section, key, t):
|
||||||
config = self._config
|
config = self._config
|
||||||
|
@ -545,7 +549,7 @@ class Options:
|
||||||
elif t == 'list':
|
elif t == 'list':
|
||||||
val = config[section][key]
|
val = config[section][key]
|
||||||
assert isinstance(val, (list, tuple))
|
assert isinstance(val, (list, tuple))
|
||||||
else: # str
|
else: # str
|
||||||
val = config[section][key]
|
val = config[section][key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
val = None
|
val = None
|
||||||
|
@ -578,7 +582,7 @@ class Options:
|
||||||
'cardsets',
|
'cardsets',
|
||||||
'games_geometry',
|
'games_geometry',
|
||||||
'offsets',
|
'offsets',
|
||||||
):
|
):
|
||||||
if section not in config:
|
if section not in config:
|
||||||
config[section] = {}
|
config[section] = {}
|
||||||
|
|
||||||
|
@ -591,7 +595,7 @@ class Options:
|
||||||
# validation
|
# validation
|
||||||
vdt = validate.Validator()
|
vdt = validate.Validator()
|
||||||
res = config.validate(vdt)
|
res = config.validate(vdt)
|
||||||
##from pprint import pprint; pprint(res)
|
# from pprint import pprint; pprint(res)
|
||||||
if res is not True:
|
if res is not True:
|
||||||
for section, data in res.items():
|
for section, data in res.items():
|
||||||
if data is True:
|
if data is True:
|
||||||
|
@ -602,7 +606,6 @@ class Options:
|
||||||
'section: "%s", key: "%s"' % (section, key))
|
'section: "%s", key: "%s"' % (section, key))
|
||||||
config[section][key] = None
|
config[section][key] = None
|
||||||
|
|
||||||
|
|
||||||
# general
|
# general
|
||||||
for key, t in self.GENERAL_OPTIONS:
|
for key, t in self.GENERAL_OPTIONS:
|
||||||
val = self._getOption('general', key, t)
|
val = self._getOption('general', key, t)
|
||||||
|
@ -711,5 +714,3 @@ class Options:
|
||||||
self.offsets[key] = val
|
self.offsets[key] = val
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use Test::Differences qw( eq_or_diff );
|
||||||
use String::ShellQuote qw/ shell_quote /;
|
use String::ShellQuote qw/ shell_quote /;
|
||||||
|
|
||||||
# my $cmd = shell_quote( 'flake8', '.' );
|
# my $cmd = shell_quote( 'flake8', '.' );
|
||||||
my $cmd = shell_quote( 'flake8', glob('./pysollib/[a-m]*.py') );
|
my $cmd = shell_quote( 'flake8', glob('./pysollib/[a-o]*.py') );
|
||||||
|
|
||||||
# TEST
|
# TEST
|
||||||
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
||||||
|
|
Loading…
Add table
Reference in a new issue