[Python-checkins] r65434 - in sandbox/trunk/ttk-gsoc/src: 2.x/ttk.py 3.x/ttk.py
guilherme.polo
python-checkins at python.org
Sun Aug 3 18:51:59 CEST 2008
Author: guilherme.polo
Date: Sun Aug 3 18:51:58 2008
New Revision: 65434
Log:
Fixed an old bug that reappeared :/ seems good now
Modified:
sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
sandbox/trunk/ttk-gsoc/src/3.x/ttk.py
Modified: sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/2.x/ttk.py (original)
+++ sandbox/trunk/ttk-gsoc/src/2.x/ttk.py Sun Aug 3 18:51:58 2008
@@ -12,7 +12,7 @@
of the widgets appearance lies at Themes.
"""
-__version__ = "0.1.5"
+__version__ = "0.1.6"
__author__ = "Guilherme Polo <ggpolo at gmail.com>"
@@ -321,18 +321,12 @@
return _dict_from_tcltuple(res)
def _convert_stringval(value):
- """Converts a value, that may possibly represents a sequence,
- hopefully, to a more appropriate Python object."""
+ """Converts a value to, hopefully, a more appropriate Python object."""
+ value = unicode(value)
try:
value = int(value)
except (ValueError, TypeError):
- if ' ' in value:
- value = map(str, value)
- try:
- value = map(int, value)
- except ValueError:
- # this value needs no conversion apparently
- pass
+ pass
return value
@@ -340,19 +334,14 @@
"""Returns adict with its values converted from Tcl objects to Python
objects."""
for opt, val in adict.iteritems():
- if isinstance(val, basestring):
- val = _convert_stringval(val)
-
- elif val and hasattr(val, '__len__'):
+ if val and hasattr(val, '__len__') and not isinstance(val, basestring):
if getattr(val[0], 'typename', None) == 'StateSpec':
val = _list_from_statespec(val)
else:
- # converts a sequence that possibly has Tcl objects, or not,
- # to a better representation
- val = map(_convert_stringval, map(str, val))
+ val = map(_convert_stringval, val)
- elif hasattr(val, 'typename'): # some other Tcl object
- val = str(val)
+ elif hasattr(val, 'typename'): # some other (single) Tcl object
+ val = _convert_stringval(val)
adict[opt] = val
Modified: sandbox/trunk/ttk-gsoc/src/3.x/ttk.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/3.x/ttk.py (original)
+++ sandbox/trunk/ttk-gsoc/src/3.x/ttk.py Sun Aug 3 18:51:58 2008
@@ -12,7 +12,7 @@
of the widgets appearance lies at Themes.
"""
-__version__ = "0.1.5"
+__version__ = "0.1.6"
__author__ = "Guilherme Polo <ggpolo at gmail.com>"
@@ -321,18 +321,12 @@
return _dict_from_tcltuple(res)
def _convert_stringval(value):
- """Converts a value, that may possibly represents a sequence,
- hopefully, to a more appropriate Python object."""
+ """Converts a value to, hopefully, a more appropriate Python object."""
+ value = str(value)
try:
value = int(value)
except (ValueError, TypeError):
- if ' ' in value:
- value = list(map(str, value))
- try:
- value = list(map(int, value))
- except ValueError:
- # this value needs no conversion apparently
- pass
+ pass
return value
@@ -340,19 +334,14 @@
"""Returns adict with its values converted from Tcl objects to Python
objects."""
for opt, val in adict.items():
- if isinstance(val, str):
- val = _convert_stringval(val)
-
- elif val and hasattr(val, '__len__'):
+ if val and hasattr(val, '__len__') and not isinstance(val, str):
if getattr(val[0], 'typename', None) == 'StateSpec':
val = _list_from_statespec(val)
else:
- # converts a sequence that possibly has Tcl objects, or not,
- # to a better representation
- val = list(map(_convert_stringval, map(str, val)))
+ val = list(map(_convert_stringval, val))
- elif hasattr(val, 'typename'): # some other Tcl object
- val = str(val)
+ elif hasattr(val, 'typename'): # some other (single) Tcl object
+ val = _convert_stringval(val)
adict[opt] = val
More information about the Python-checkins
mailing list