3 new revisions:
Revision: e2a4eab233b1
Branch: default
Author: gbtami
Date: Wed Dec 31 09:35:55 2014 UTC
Log: List fixes
https://code.google.com/p/pychess/source/detail?r=e2a4eab233b1
Revision: 574b549a8d35
Branch: default
Author: gbtami
Date: Wed Dec 31 09:39:34 2014 UTC
Log: Get rid os types from pychess config file to be 2 and 3
compatible sim...
https://code.google.com/p/pychess/source/detail?r=574b549a8d35
Revision: 7579d6dd74d8
Branch: default
Author: gbtami
Date: Wed Dec 31 09:59:14 2014 UTC
Log: file() -> open()
https://code.google.com/p/pychess/source/detail?r=7579d6dd74d8
==============================================================================
Revision: e2a4eab233b1
Branch: default
Author: gbtami
Date: Wed Dec 31 09:35:55 2014 UTC
Log: List fixes
https://code.google.com/p/pychess/source/detail?r=e2a4eab233b1
Modified:
/lib/pychess/Players/CECPEngine.py
/lib/pychess/Players/engineNest.py
/lib/pychess/Savers/chessalpha2.py
/lib/pychess/ic/ICLogon.py
/lib/pychess/widgets/pydock/StarArrowButton.py
=======================================
--- /lib/pychess/Players/CECPEngine.py Tue Dec 30 16:34:48 2014 UTC
+++ /lib/pychess/Players/CECPEngine.py Wed Dec 31 09:35:55 2014 UTC
@@ -980,7 +980,7 @@
return {"type": "text", "name": name, "default": value}
elif " -combo " in option:
name, value = option.split(" -combo ")
- choices = map(str.strip, value.split("///"))
+ choices = list(map(str.strip, value.split("///")))
default = ""
for choice in choices:
if choice.startswith("*"):
=======================================
--- /lib/pychess/Players/engineNest.py Tue Dec 30 19:30:35 2014 UTC
+++ /lib/pychess/Players/engineNest.py Wed Dec 31 09:35:55 2014 UTC
@@ -151,7 +151,7 @@
if 'author' in ids:
engine['author'] = ids['author']
if options:
- engine["options"] = options.values()
+ engine["options"] = list(options.values())
return engine
def __fromCECPProcess (self, subprocess):
@@ -163,7 +163,7 @@
if features['analyze'] == 1:
engine["analyze"] = True
if options:
- engine["options"] = options.values()
+ engine["options"] = list(options.values())
return engine
=======================================
--- /lib/pychess/Savers/chessalpha2.py Tue Dec 30 17:57:03 2014 UTC
+++ /lib/pychess/Savers/chessalpha2.py Wed Dec 31 09:35:55 2014 UTC
@@ -69,7 +69,7 @@
sanmvs = map(toFAN, model.boards[:-1], model.moves)
sanmvs = map(fanconv, sanmvs)
- if model.lowply & 1: sanmvs = [">"]+sanmvs
+ if model.lowply & 1: sanmvs = [">"]+list(sanmvs)
if model.status in (DRAW, WHITEWON, BLACKWON):
sanmvs.extend(['']*(-len(sanmvs)%2))
sanmvs.append(fanconv(reprResult[model.status]))
=======================================
--- /lib/pychess/ic/ICLogon.py Tue Dec 30 12:47:46 2014 UTC
+++ /lib/pychess/ic/ICLogon.py Wed Dec 31 09:35:55 2014 UTC
@@ -174,7 +174,7 @@
ports = (port,)
else:
ports = self.widgets["portsEntry"].get_text()
- ports = map(int, re.findall("\d+", ports))
+ ports = list(map(int, re.findall("\d+", ports)))
if not 5000 in ports: ports.append(5000)
if not 23 in ports: ports.append(23)
self.showConnecting()
=======================================
--- /lib/pychess/widgets/pydock/StarArrowButton.py Tue Dec 30 16:34:48 2014
UTC
+++ /lib/pychess/widgets/pydock/StarArrowButton.py Wed Dec 31 09:35:55 2014
UTC
@@ -58,7 +58,7 @@
starWidth, starHeight = self.getSizeOfSvg(self.bgSvg)
scale = min(1, parentAlloc.width / float(starWidth),
parentAlloc.height / float(starHeight))
- self.size = map(int, (starWidth*scale, starHeight*scale))
+ self.size = list(map(int, (starWidth*scale, starHeight*scale)))
self.resize(self.size[0], self.size[1])
if self.get_window():
==============================================================================
Revision: 574b549a8d35
Branch: default
Author: gbtami
Date: Wed Dec 31 09:39:34 2014 UTC
Log: Get rid os types from pychess config file to be 2 and 3
compatible simultaneously
https://code.google.com/p/pychess/source/detail?r=574b549a8d35
Modified:
/lib/pychess/System/conf_configParser.py
=======================================
--- /lib/pychess/System/conf_configParser.py Tue Dec 30 15:33:20 2014 UTC
+++ /lib/pychess/System/conf_configParser.py Wed Dec 31 09:39:34 2014 UTC
@@ -1,6 +1,7 @@
import os, atexit
+from ast import literal_eval
-from pychess.compat import SafeConfigParser, PY2
+from pychess.compat import SafeConfigParser
from pychess.System.Log import log
configParser = SafeConfigParser()
@@ -12,30 +13,11 @@
configParser.readfp(open(path))
if not configParser.has_section(section):
configParser.add_section(section)
-if not configParser.has_section(section+"_Types"):
- configParser.add_section(section+"_Types")
atexit.register(lambda: configParser.write(open(path,"w")))
idkeyfuncs = {}
conid = 0
-typeEncode = {
- str: repr(str),
- int: repr(int),
- float: repr(float),
- bool: repr(bool)
-}
-if PY2:
- typeEncode[unicode] = repr(unicode)
-
-typeDecode = {
- repr(str): configParser.get,
- repr(int): configParser.getint,
- repr(float): configParser.getfloat,
- repr(bool): configParser.getboolean,
-}
-if PY2:
- typeDecode[repr(unicode)] = configParser.get
def notify_add (key, func, args):
global conid
@@ -47,13 +29,21 @@
del idkeyfuncs[conid]
def get (key):
- decoder = typeDecode[configParser.get(section+"_Types", key)]
- return decoder(section, key)
+ try:
+ return configParser.getint(section, key)
+ except ValueError:
+ pass
+
+ try:
+ return configParser.getboolean(section, key)
+ except ValueError:
+ pass
+
+ return configParser.get(section, key)
def set (key, value):
try:
configParser.set (section, key, str(value))
- configParser.set (section+"_Types", key, typeEncode[type(value)])
except Exception as e:
log.error("Unable to save configuration '%s'='%s' because of
error: %s %s"%
(repr(key), repr(value),
e.__class__.__name__, ", ".join(str(a) for a in e.args)))
@@ -62,5 +52,4 @@
func (None, *args)
def hasKey (key):
- return configParser.has_option(section, key) and \
- configParser.has_option(section+"_Types", key)
+ return configParser.has_option(section, key)
==============================================================================
Revision: 7579d6dd74d8
Branch: default
Author: gbtami
Date: Wed Dec 31 09:59:14 2014 UTC
Log: file() -> open()
https://code.google.com/p/pychess/source/detail?r=7579d6dd74d8
Modified:
/lib/pychess/System/protoopen.py
/lib/pychess/widgets/pydock/OverlayWindow.py
/lib/pychess/widgets/pydock/PyDockTop.py
/utilities/eco-da.py
/utilities/eco-de.py
/utilities/eco-es.py
/utilities/eco-hu.py
=======================================
--- /lib/pychess/System/protoopen.py Tue Dec 30 17:16:47 2014 UTC
+++ /lib/pychess/System/protoopen.py Wed Dec 31 09:59:14 2014 UTC
@@ -29,12 +29,12 @@
if splitted[0] == "file":
if append:
- return file(splitted[1], "a")
- return file(splitted[1], "w")
+ return open(splitted[1], "a")
+ return open(splitted[1], "w")
elif len(splitted) == 1:
if append:
- return file(splitted[0], "a")
- return file(splitted[0], "w")
+ return open(splitted[0], "a")
+ return open(splitted[0], "w")
raise IOError("PyChess doesn't support writing to protocol")
=======================================
--- /lib/pychess/widgets/pydock/OverlayWindow.py Tue Dec 30 12:55:47 2014
UTC
+++ /lib/pychess/widgets/pydock/OverlayWindow.py Wed Dec 31 09:59:14 2014
UTC
@@ -130,11 +130,11 @@
"#ffffff": getcol("p_base_color"),
"#000000": getcol("p_fg_color")}
- data = file(svgPath).read()
+ data = open(svgPath).read()
data = re.sub("|".join(colorDic.keys()),
lambda m: m.group() in colorDic and
colorDic[m.group()] or m.group(),
data)
- f = file(TEMP_PATH, "w")
+ f = open(TEMP_PATH, "w")
f.write(data)
f.close()
svg = Rsvg.Handle.new_from_file(TEMP_PATH)
=======================================
--- /lib/pychess/widgets/pydock/PyDockTop.py Tue Dec 30 14:13:27 2014 UTC
+++ /lib/pychess/widgets/pydock/PyDockTop.py Wed Dec 31 09:59:14 2014 UTC
@@ -116,7 +116,7 @@
if self.get_child():
self.__addToXML(self.get_child(), dockElem, doc)
- f = file(xmlpath, "w")
+ f = open(xmlpath, "w")
doc.writexml(f)
f.close()
doc.unlink()
=======================================
--- /utilities/eco-da.py Tue Dec 30 12:55:47 2014 UTC
+++ /utilities/eco-da.py Wed Dec 31 09:59:14 2014 UTC
@@ -19,7 +19,7 @@
# All xml tags are namespace prefixed in parsed tree !
ns = "{
http://www.w3.org/1999/xhtml}"
- ecofile = file("eco.pgn", "w")
+ ecofile = open("eco.pgn", "w")
rows = [c for c in tree.findall(".//%sli" % ns) if c.text and
c.text[0] in "ABCDE"]
=======================================
--- /utilities/eco-de.py Tue Dec 30 12:55:47 2014 UTC
+++ /utilities/eco-de.py Wed Dec 31 09:59:14 2014 UTC
@@ -19,7 +19,7 @@
# All xml tags are namespace prefixed in parsed tree !
ns = "{
http://www.w3.org/1999/xhtml}"
- ecofile = file("eco.pgn", "w")
+ ecofile = open("eco.pgn", "w")
tables = [c for c in tree.findall(".//%stable" % ns) if c.get("class")
== "prettytable"]
=======================================
--- /utilities/eco-es.py Tue Dec 30 12:55:47 2014 UTC
+++ /utilities/eco-es.py Wed Dec 31 09:59:14 2014 UTC
@@ -19,7 +19,7 @@
# All xml tags are namespace prefixed in parsed tree !
ns = "{
http://www.w3.org/1999/xhtml}"
- ecofile = file("eco.pgn", "w")
+ ecofile = open("eco.pgn", "w")
rows = [c for c in tree.findall(".//%sli" % ns) if c.text and
c.text[0] in "ABCDE"]
=======================================
--- /utilities/eco-hu.py Tue Dec 30 12:55:47 2014 UTC
+++ /utilities/eco-hu.py Wed Dec 31 09:59:14 2014 UTC
@@ -19,7 +19,7 @@
# All xml tags are namespace prefixed in parsed tree !
ns = "{
http://www.w3.org/1999/xhtml}"
- ecofile = file("eco.pgn", "w")
+ ecofile = open("eco.pgn", "w")
rows = [c for c in tree.findall(".//%sli" % ns) if c.get("class") is
None]