~mcfletch/basicproperty/trunk

« back to all changes in this revision

Viewing changes to basictypes/basic_types.py

  • Committer: Mike C. Fletcher
  • Date: 2011-11-30 01:55:05 UTC
  • Revision ID: mcfletch@vrplumber.com-20111130015505-1po5tzzfydky7n5y
Eliminate support for Python 2.2, and with it the booleanfix module, which blew up on Python 3.x

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
module designs stand in datatypes which can be used to
5
5
define basicproperty property classes.
6
6
"""
7
 
from basictypes import latebind, datatypedefinition, registry, booleanfix
 
7
from basictypes import latebind, datatypedefinition, registry
8
8
import types, traceback
9
9
 
10
10
class Object_DT( datatypedefinition.BaseType_DT ):
110
110
                'no',
111
111
                '',
112
112
        )
113
 
        baseType = booleanfix.bool
 
113
        baseType = bool
114
114
        def coerce(cls, value):
115
115
                """Coerce value to Boolean value
116
116
 
126
126
                if type(value) in (str, unicode):
127
127
                        test = str(test.lower())
128
128
                if test in cls.falseValues:
129
 
                        return booleanfix.False
 
129
                        return False
130
130
                elif not test:
131
 
                        return booleanfix.False
 
131
                        return False
132
132
                else:
133
 
                        return booleanfix.True
 
133
                        return True
134
134
        coerce = classmethod( coerce )
135
135
        def check( cls, value ):
136
136
                """Determine whether value conforms to definition"""
137
137
                if not isinstance( value, cls.baseType ):
138
138
                        return 0
139
 
                if value not in (booleanfix.False,booleanfix.True):
 
139
                if value not in ( False, True):
140
140
                        return 0
141
141
                return 1
142
142
        check = classmethod( check )
144
144
        registry.registerDT( bool, Boolean_DT )
145
145
except NameError:
146
146
        pass
147
 
registry.registerDT( booleanfix.bool, Boolean_DT )
 
147
registry.registerDT(  bool, Boolean_DT )
148
148
 
149
149
class StringLocale_DT( datatypedefinition.BaseType_DT ):
150
150
        """String data-type specifier"""