Some cleanup prior to an upcoming change for bug #1680.

Minor optimization in _init_map (replace loop w/ list-comprehension
Remove unused variables VALUE_POS, STRING_POS,
At call to self.set, remove unnecessary logic that duplicates
 else-clause within the set() function itself


svn: r10404
This commit is contained in:
James G Sack 2008-03-27 03:11:48 +00:00
parent 76ee14989f
commit bca1d41204

View File

@ -35,9 +35,8 @@ def _init_map(data, key_col, data_col):
""" """
Initialize the map, building a new map from the specified columns. Initialize the map, building a new map from the specified columns.
""" """
new_data = {} new_data = dict([ (item[key_col], item[data_col])
for item in data: for item in data ])
new_data[item[key_col]] = item[data_col]
return new_data return new_data
class GrampsTypeMeta(type): class GrampsTypeMeta(type):
@ -53,7 +52,6 @@ class GrampsTypeMeta(type):
class GrampsType(object): class GrampsType(object):
"""Base class for all Gramps object types.""" """Base class for all Gramps object types."""
(VALUE_POS, STRING_POS) = range(2)
_CUSTOM = 0 _CUSTOM = 0
_DEFAULT = 0 _DEFAULT = 0
@ -75,11 +73,7 @@ class GrampsType(object):
Create a new type, initialize the value from one of several possible Create a new type, initialize the value from one of several possible
states. states.
""" """
if value is not None:
self.set(value) self.set(value)
else:
self.val = self._DEFAULT
self.string = u''
def __set_tuple(self, value): def __set_tuple(self, value):
v,s = self._DEFAULT,u'' v,s = self._DEFAULT,u''