Changeset 290

Show
Ignore:
Timestamp:
09/24/02 02:14:45 (6 years ago)
Author:
sholloway
Message:

Added doctests!!!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBFoundation/RBFoundation/Acquisition.py

    r253 r290  
    6464        """Removes attribute from self if exists, or from an aquirable object.""" 
    6565        try: 
    66             super(AcquisitionHooks, self).__getattribute__(name) 
     66            return super(AcquisitionHooks, self).__delattr__(name) 
    6767        except AttributeError: 
    68             success, result = self._DelAcquirableAttr(name, value
     68            success, result = self._DelAcquirableAttr(name
    6969            if success: return result 
    70         return super(AcquisitionHooks, self).__delattr__(name) 
     70            else: raise 
    7171 
    7272#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    7373 
    7474class SingleAcquisitionMixin(AcquisitionHooks): 
    75     """Allows for dynamic pseudo inheritence from a list of 'acquirable' objects.""" 
     75    """Allows for dynamic pseudo inheritence from a list of 'acquirable' objects. 
     76 
     77    >>> a = SingleAcquisitionMixin() 
     78    >>> class temp(object): 
     79    ...     v = 1 
     80    ...     u = 2 
     81    ... 
     82    >>> t = temp() 
     83    >>> a.SetAcquirable(t) 
     84    >>> a.v 
     85    1 
     86    >>> a.u 
     87    2 
     88    >>> a.u = 'a new value' 
     89    >>> a.u 
     90    'a new value' 
     91    >>> a.new_val = 'test new value' 
     92    >>> a.new_val 
     93    'test new value' 
     94    >>> vars(a).keys() 
     95    ['new_val', '_SingleAcquisitionMixin__AcquirableObject'] 
     96    >>> vars(t).keys() 
     97    ['u'] 
     98    >>> vars(t.__class__).keys() 
     99    ['__module__', 'u', 'v', '__dict__', '__weakref__', '__doc__'] 
     100    """ 
    76101 
    77102    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    116141 
    117142class AcquisitionMixin(AcquisitionHooks): 
    118     """Allows for dynamic pseudo inheritence from a list of 'acquirable' objects.""" 
     143    """Allows for dynamic pseudo inheritence from a list of 'acquirable' objects. 
     144 
     145    >>> a = AcquisitionMixin() 
     146    >>> class temp(object): 
     147    ...     v = 1 
     148    ...     u = 2 
     149    ... 
     150    >>> t = temp() 
     151    >>> a.AddAcquirable(t) 
     152    >>> a.v 
     153    1 
     154    >>> a.u 
     155    2 
     156    >>> a.u = 'a new value' 
     157    >>> a.u 
     158    'a new value' 
     159    >>> a.new_val = 'test new value' 
     160    >>> a.new_val 
     161    'test new value' 
     162    >>> vars(a).keys() 
     163    ['new_val', '_AcquisitionMixin__AcquirableObjects'] 
     164    >>> vars(t).keys() 
     165    ['u'] 
     166    >>> vars(t.__class__).keys() 
     167    ['__module__', 'u', 'v', '__dict__', '__weakref__', '__doc__'] 
     168    >>> class temp2(object): 
     169    ...     q = 'r' 
     170    ...     s = 't' 
     171    ...     v = 'From temp2' 
     172    ... 
     173    >>> a.AddAcquirable(temp2()) 
     174    >>> a.q 
     175    'r' 
     176    >>> a.s 
     177    't' 
     178    >>> a.v 
     179    1 
     180    >>> a.v = 23 
     181    >>> a.v 
     182    23 
     183    >>> del a.v 
     184    >>> a.v 
     185    1 
     186    """ 
    119187 
    120188    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    142210    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    143211 
     212    __invalid = id(None) 
     213 
    144214    def _GetAcquirableAttr(self, name): 
    145215        for x in self.__AcquirableObjects: 
    146             result = getattr(x, name, id(None)
    147             if result != id(None):  
     216            result = getattr(x, name, self.__invalid
     217            if result != self.__invalid:  
    148218                return 1, result 
    149219        return 0, None 
     
    174244    a.AddAcquirable(temp()) 
    175245 
    176     if 1: 
    177         assert a.v == 1 
    178         assert a.u == 2 
    179         assert a.u != a.v 
    180         a.u = 'new value' 
    181         assert a.u == 'new value' 
    182         a.new_val = 'a new value!' 
    183         assert a.new_val == 'a new value!' 
    184  
    185         import time 
    186         count = 1e4 
    187         start = time.clock() 
    188         for i in xrange(count): me = i + temp.v 
    189         pereach = (time.clock() - start) / count 
    190         print "Normal:", pereach, "per", count 
    191  
    192         start = time.clock() 
    193         for i in xrange(count): me = i + a.v 
    194         pereach2 = (time.clock() - start) / count 
    195         print "Acquisition:", pereach2, "per", count 
    196  
    197         print "Acquisition is", pereach2/pereach, "times slower"  
     246    assert a.v == 1 
     247    assert a.u == 2 
     248    assert a.u != a.v 
     249    a.u = 'new value' 
     250    assert a.u == 'new value' 
     251    a.new_val = 'a new value!' 
     252    assert a.new_val == 'a new value!' 
     253 
     254    import time 
     255    count = 1e4 
     256    start = time.clock() 
     257    for i in xrange(count): me = i + temp.v 
     258    pereach = (time.clock() - start) / count 
     259    print "Normal:", pereach, "per", count 
     260 
     261    start = time.clock() 
     262    for i in xrange(count): me = i + a.v 
     263    pereach2 = (time.clock() - start) / count 
     264    print "Acquisition:", pereach2, "per", count 
     265 
     266    print "Acquisition is", pereach2/pereach, "times slower"  
     267 
     268    print 
     269    import doctest, Acquisition 
     270    doctest.testmod(Acquisition) 
     271 
    198272    print "Test complete." 
    199273 
  • trunk/RBFoundation/RBFoundation/AttributedDict.py

    r253 r290  
    2727    """AttributedDict is intended to be a handly little class that you can 
    2828    stuff attributes and such into like you would any other class, yet have 
    29     the nice iteration capabilities of a dictionary.""" 
     29    the nice iteration capabilities of a dictionary. 
     30     
     31    >>> test = AttributedDict() 
     32    >>> test.fun 
     33    Traceback (most recent call last): 
     34    AttributeError: 'AttributedDict' object has no attribute 'fun' 
     35    >>> test.fun = 7 
     36    >>> test.fun 
     37    7 
     38    >>> test.items() 
     39    [('fun', 7)] 
     40    >>> test.more = test.fun * 3 
     41    >>> test 
     42    {'fun': 7, 'more': 21} 
     43    >>> testupdate = {'regular':'dict'} 
     44    >>> testupdate.update(test) 
     45    >>> testupdate 
     46    {'fun': 7, 'regular': 'dict', 'more': 21} 
     47    >>> test.more 
     48    21 
     49    >>> test.regular 
     50    Traceback (most recent call last): 
     51    AttributeError: 'AttributedDict' object has no attribute 'regular' 
     52    >>> test.update(testupdate) 
     53    >>> test.regular 
     54    'dict' 
     55    >>> test 
     56    {'fun': 7, 'regular': 'dict', 'more': 21} 
     57 
     58    """ 
    3059     
    3160    __slots__ = [] # we really didnt want any attributes anyway 
     
    6190 
    6291if __name__ == '__main__': 
     92    print "Testing..." 
     93 
    6394    class _test(AttributedDict):  
    6495        answer = 42 
     
    108139 
    109140    print "Attributed Dict is", pereach2/pereach, "times slower"  
     141 
     142    print  
     143    print  
     144 
     145    import doctest, ChainedDict 
     146    doctest.testmod(ChainedDict) 
     147 
     148    print "Test complete." 
  • trunk/RBFoundation/RBFoundation/ChainedDict.py

    r280 r290  
    1919##~ 
    2020##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     21 
     22"""Implements a dictionary-like with failover to a secondary dictionary-like object. 
     23 
     24Useful for acquisition.  =) 
     25 
     26>>> cd = ChainedDict({'testing': 1}) 
     27>>> cd.SetChained({'testing': 21, 'chained': 42}) 
     28>>> cd.source 
     29{'testing': 1} 
     30>>> cd.chained 
     31{'testing': 21, 'chained': 42} 
     32>>> cd.items() 
     33[('testing', 1)] 
     34>>> cd.items(include_chained=1) 
     35[('testing', 1), ('chained', 42)] 
     36>>> cd['testing'] == 1 
     371 
     38>>> cd['chained'] == 42 
     391 
     40>>> del cd['testing'] 
     41>>> cd['testing'] == 21 
     421 
     43>>> cd['testing'] = 37 
     44>>> cd.items(include_chained=1) 
     45[('testing', 37), ('chained', 42)] 
     46>>> cd.items() 
     47[('testing', 37)] 
     48>>> cd['testing'] == 37 
     491 
     50>>> cd.get('testing', None) == 37 
     511 
     52>>> del cd['testing'] 
     53>>> cd['testing'] == 21 
     541 
     55>>> 'testing' in cd 
     561 
     57>>> 'chained' in cd 
     581 
     59>>> 'not_there' not in cd 
     601 
     61>>> cd.get('testing', None) == 21 
     621 
     63>>> cd.get('chained', None) == 42 
     641 
     65>>> cd.items() 
     66[] 
     67>>> cd.items(include_chained=1) 
     68[('testing', 21), ('chained', 42)] 
     69 
     70""" 
    2171 
    2272#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    141191#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    142192 
     193 
    143194if __name__=='__main__': 
     195    print "Testing..." 
    144196    print  
    145197 
     
    180232    print cd.items(include_chained=1) 
    181233    print 
     234 
     235    import doctest, ChainedDict 
     236    doctest.testmod(ChainedDict) 
     237 
     238    print "Test complete." 
     239 
     240 
  • trunk/RBFoundation/RBFoundation/ContextApply.py

    r280 r290  
    2020##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2121 
     22"""Binds calling variables to a callable object, with ordering options. 
     23 
     24>>> def _TestReturnArgsKw(*args, **kw): 
     25...     return args, kw 
     26... 
     27>>> fn = ContextApply(_TestReturnArgsKw, 2,3,5, seven='11') 
     28>>> fn(13,17,19,twenty='3') 
     29((13, 17, 19, 2, 3, 5), {'twenty': '3', 'seven': '11'}) 
     30>>> fn = ContextApply_p_s(_TestReturnArgsKw, 2,3,5, seven='11') 
     31>>> fn(13,17,19,twenty='3') 
     32((13, 17, 19, 2, 3, 5), {'twenty': '3', 'seven': '11'}) 
     33>>> fn = ContextApply_s_p(_TestReturnArgsKw, 2,3,5, seven='11') 
     34>>> fn(13,17,19,twenty='3') 
     35((2, 3, 5, 13, 17, 19), {'twenty': '3', 'seven': '11'}) 
     36>>> fn = ContextApply_p(_TestReturnArgsKw, 2,3,5, seven='11') 
     37>>> fn(13,17,19,twenty='3') 
     38((13, 17, 19), {'twenty': '3'}) 
     39>>> fn = ContextApply_s(_TestReturnArgsKw, 2,3,5, seven='11') 
     40>>> fn(13,17,19,twenty='3') 
     41((2, 3, 5), {'seven': '11'}) 
     42>>> fn = ContextApply_0(_TestReturnArgsKw, 2,3,5, seven='11') 
     43>>> fn(13,17,19,twenty='3') 
     44((), {}) 
     45""" 
     46 
    2247#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2348#~ Imports  
     
    3863 
    3964#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     65#~ Test Utilities 
     66#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     67 
     68def _TestReturnArgsKw(*args, **kw): 
     69    return args, kw 
     70 
     71#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    4072#~ Default Smart Apply Class                          
    4173#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    71103        - Passed from calling code, 
    72104        - Saved context, 
     105 
     106     
    73107    """ 
    74108    def __call__(self, *args, **kw): 
     
    144178     
    145179    Note: Implementation of the composite pattern. 
     180 
     181    >>> import operator 
     182    >>> multi = MultipleApply(None, [operator.add, operator.mul, operator.mod]) 
     183    >>> multi(3,4) 
     184    [7, 12, 3] 
     185     
    146186    """ 
    147187    def __init__(self, idx=-1, *args, **kw): 
     
    173213 
    174214if __name__ == '__main__': 
     215    print "Testing..." 
     216 
     217    import doctest, ContextApply 
     218    doctest.testmod(ContextApply) 
     219 
    175220    from pprint import pprint 
    176221 
     
    210255    assert multi(3,4) == ((3,4), {}) 
    211256     
     257    print "Test complete." 
  • trunk/RBFoundation/RBFoundation/LazyProperty.py

    r284 r290  
    1919##~ 
    2020##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     21 
     22""" 
     23>>> class Test(object): 
     24...     p = LazyProperty('t', dict) 
     25... 
     26>>> t = Test() 
     27>>> vars(t) 
     28{} 
     29>>> t.p 
     30{} 
     31>>> t.p is not Test.p 
     321 
     33>>> vars(t) 
     34{'_lazy_t': {}} 
     35 
     36""" 
    2137 
    2238#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBFoundation/RBFoundation/Utilities.py

    r263 r290  
    2626#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2727 
    28 def cleanupstrlst(datalst): 
    29     return filter(None, map(str.strip, datalst)) 
     28def cleanupstrlst(datalst, FilterResult=0): 
     29    """Strips characters from a list of strings, and drops subsequent empty strings. 
    3030 
    31 def joinclean(joinstr, data): 
     31    >>> cleanupstrlst(["   this  ", "  is  ", " \\t fun \\t \\r", "  \\n \\r \\t test\\t\\t"]) 
     32    ['this', 'is', 'fun', 'test'] 
     33    """ 
     34    result = map(str.strip, datalst) 
     35    if FilterResult: 
     36        return filter(None, result) 
     37    else: return result 
     38 
     39def joinclean(joinstr, data, *args, **kw): 
     40    """Uses cleanupstrlst, then joins the result using joinstr. 
     41    If data is simply a string, then the data is splitup using strtolist. 
     42 
     43    >>> joinclean(".", ["   this  ", "  is  ", " \\t fun \\t \\r", "  \\n \\r \\t test\\t\\t"]) 
     44    'this.is.fun.test' 
     45    >>> joinclean("-", "data, , fun  ,   data   ,   oh\\t\\t\\t ,please  \\t, \\r\\n can \\t  ,  I have more data!   ") 
     46    'data--fun-data-oh-please-can-I have more data!' 
     47 
     48    """ 
    3249    if isinstance(data, list): 
    33         return joinstr.join(cleanupstrlst(data)) 
     50        return joinstr.join(cleanupstrlst(data, *args, **kw)) 
    3451    elif isinstance(data, (str, unicode)): 
    35         return joinstr.join(strtolist(data)) 
     52        return joinstr.join(strtolist(data, *args, **kw)) 
    3653 
    37 def strtolist(data, splitchar=','): 
    38     return cleanupstrlst(data.split(',')) 
     54def strtolist(data, splitchar=',', *args, **kw): 
     55    """Splits a dilimited string, then runs the result through cleanupstrlst. 
    3956 
     57    >>> strtolist("data, , fun  ,   data   ,   oh\\t\\t\\t ,please  \\t, \\r\\n can \\t  ,  I have more data!   ") 
     58    ['data', '', 'fun', 'data', 'oh', 'please', 'can', 'I have more data!'] 
     59    """ 
     60 
     61    return cleanupstrlst(data.split(splitchar), *args, **kw) 
     62 
     63 
     64#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     65#~ Testing  
     66#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     67 
     68if __name__=='__main__': 
     69    print "Testing..." 
     70    import doctest, Utilities 
     71    doctest.testmod(Utilities) 
     72    print "Test complete." 
     73 
     74 
  • trunk/RBFoundation/RBFoundation/WeakBind.py

    r286 r290  
    3131import weakref 
    3232import types 
     33from AspectOriented.Aspect import Aspect as _Aspect 
    3334 
    3435#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    3738 
    3839typesBindMethods = (types.MethodType, types.BuiltinMethodType ) 
    39 typesRequireBinding = typesBindMethods + (types.ObjectType, types.InstanceType) 
     40typesInstances = (types.ObjectType, types.InstanceType) 
     41typesRequireBinding = typesBindMethods + typesInstances 
    4042 
    4143typesNonBindMethods = (types.FunctionType, types.LambdaType, types.GeneratorType, types.BuiltinFunctionType) 
     
    4345 
    4446#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     47#~ Callable Aspects 
     48#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     49 
     50##class _CallableFuctionAspect(_Aspect): 
     51##    def __nonzero__(self): return self.im_func and 1 or 0 
     52##    def __hash__(self): return hash(self.im_func) 
     53##    def _DoCall(self, *args, **kw): 
     54##        return self.im_func(*args, **kw) 
     55##    __call__ = _DoCall 
     56 
     57##class _CallableMethodAspect(_Aspect): 
     58##    def __nonzero__(self): return self.im_self() is not None and 1 or 0 
     59##    def __hash__(self): return hash(self.im_self) 
     60##    def _DoCall(self, *args, **kw): 
     61##        im_self = self.im_self() 
     62##        if im_self is None: raise weakref.ReferenceError, "weakly-referenced object no longer exists" 
     63##        return self.im_func(im_self, *args, **kw) 
     64##    __call__ = _DoCall 
     65 
     66##class _CallableInstanceAspect(_Aspect): 
     67##    def __nonzero__(self): return self.im_self() is not None and 1 or 0 
     68##    def __hash__(self): return hash(self.im_self)  
     69##    def _DoCall(self, *args, **kw): 
     70##        im_self = self.im_self() 
     71##        if im_self is None: raise weakref.ReferenceError, "weakly-referenced object no longer exists" 
     72##        return im_self(*args, **kw) 
     73##    __call__ = _DoCall 
     74 
     75#~ Test Utilities ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     76 
     77def _PrintOnRelease(wr): 
     78    print "Released weakref" 
     79 
     80class _TestObject(object): 
     81    def TestMethod(self, *args, **kw): 
     82        return args, kw 
     83 
     84#~ Class Bases ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    4585 
    4686class BoundCallableBase(object): 
     
    61101     
    62102    As a related sidenote, the ContextApply module builds upon this concepts to bind method variables 
    63     to bound-callable objects.""" 
     103    to bound-callable objects. 
     104     
     105    >>> t = _TestObject() 
     106    >>> wbc = WeakBoundCallable(t.TestMethod, _PrintOnRelease) 
     107    >>> wbc(1,2,3,four=4) 
     108    ((1, 2, 3), {'four': 4}) 
     109    >>> del t 
     110    Released weakref 
     111 
     112    """ 
    64113     
    65114    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    82131            # keep a hard reference to the BoundCallableBase 
    83132            self.im_func = Callable 
     133            ##_CallableFuctionAspect.InsertAspect(self) 
    84134        elif isinstance(Callable, typesBindMethods): 
    85135            # Wrap up the method and potential instance 
     136            self.im_func = getattr(Callable, 'im_func', Callable) 
    86137            if getattr(Callable, 'im_self', None) is not None:  
    87138                self.im_self = weakref.ref(Callable.im_self, *weakrefArgs, **weakrefKw) 
    88             self.im_func = getattr(Callable, 'im_func', Callable) 
     139                ##_CallableMethodAspect.InsertAspect(self) 
     140            else: 
     141                ##_CallableFuctionAspect.InsertAspect(self) 
     142                pass 
    89143        elif isinstance(Callable, typesInstances): 
    90144            # This is a "callable object", make a weakref to it 
    91145            self.im_self = weakref.ref(Callable, *weakrefArgs, **weakrefKw) 
    92146            self.im_func = None 
     147            ##_CallableInstanceAspect.InsertAspect(self) 
    93148        elif callable(Callable): 
    94149            # What the heck is it?  well... its supposed to be callable... 
    95150            self.im_func = Callable 
     151            ##_CallableFuctionAspect.InsertAspect(self) 
    96152 
    97153    def __nonzero__(self): 
     
    133189    __call__ = _DoCall 
    134190 
     191#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     192 
    135193BoundCallable = WeakBoundCallable 
    136194 
     
    140198    """Provides the same interface as WeakBoundCallable, but maintains strong references 
    141199    to both class instances and callable objects.  Used mainly in ContextApply to build  
    142     upon a common class interface.""" 
     200    upon a common class interface. 
     201     
     202    >>> t = _TestObject() 
     203    >>> sbc = StrongBoundCallable(t.TestMethod) 
     204    >>> sbc(1,2,3,four=4) 
     205    ((1, 2, 3), {'four': 4}) 
     206    """ 
    143207 
    144208    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    161225        return self.Callable is not None and 1 or 0 
    162226 
    163     #def __call__(self, *args, **kw): 
    164     #    return self._DoCall(args, kw
     227    def __hash__(self): 
     228        return hash(self.Callable
    165229 
    166230    def __eq__(self, other): 
     
    184248 
    185249def BindCallable(Callable, BindClass=BoundCallable, *args, **kw): 
    186     """Binds a callable object using BindClass only if needed."""  
     250    """Binds a callable object using BindClass only if needed. 
     251     
     252    >>> BindCallable(_PrintOnRelease) is _PrintOnRelease 
     253    1 
     254    >>> BindCallable(_TestObject.TestMethod) is not _TestObject.TestMethod 
     255    1 
     256    """  
    187257    if isinstance(Callable, BoundCallableBase): 
    188258        # It's already bound in some form or another,  
     
    201271 
    202272def WeakBindCallable(Callable, *args, **kw): 
    203     """Weakly binds a callable object only if needed."""  
     273    """Weakly binds a callable object only if needed. 
     274 
     275    >>> WeakBindCallable(_TestObject.TestMethod) is not _TestObject.TestMethod 
     276    1 
     277    >>> WeakBindCallable(_TestObject().TestMethod) and 1 or 0 
     278    0 
     279    >>> t = _TestObject() 
     280    >>> wbc = WeakBindCallable(t.TestMethod) 
     281    >>> wbc is not t.TestMethod 
     282    1 
     283    >>> t.TestMethod() == wbc() 
     284    1 
     285    >>> del t 
     286    >>> wbc and 1 or 0 
     287    0 
     288    """ 
    204289    return BindCallable(Callable, WeakBoundCallable, *args, **kw) 
    205290 
    206291def StrongBindCallable(Callable, *args, **kw): 
    207     """Strongly binds a callable object only if needed."""  
     292    """Strongly binds a callable object only if needed. 
     293 
     294    >>> StrongBindCallable(_TestObject.TestMethod) is not _TestObject.TestMethod 
     295    1 
     296    >>> StrongBindCallable(_TestObject().TestMethod) and 1 or 0 
     297    1 
     298    >>> t = _TestObject() 
     299    >>> sbc = StrongBindCallable(t.TestMethod) 
     300    >>> sbc is not t.TestMethod 
     301    1 
     302    >>> t.TestMethod() == sbc() 
     303    1 
     304    >>> del t 
     305    >>> sbc and 1 or 0 
     306    1 
     307    """ 
    208308    return BindCallable(Callable, StrongBoundCallable, *args, **kw) 
    209309 
     
    214314if __name__ == '__main__': 
    215315    print "Testing..." 
     316    import doctest, WeakBind 
     317    doctest.testmod(WeakBind) 
     318 
    216319    import sys 
    217320 
  • trunk/RBFoundation/RBFoundation/__init__.py

    r286 r290  
    4646""" 
    4747 
    48 __version__         = '0.3.2
     48__version__         = '0.3.3
    4949__author__          = 'Shane Holloway' 
    5050__author_email__    = 'shane.holloway@runeblade.com' 
  • trunk/RBSkinning/RBSkinning/wxPythonSkin/splitter.py

    r277 r290  
    5555        self.object = wx.wxSplitterWindow(winParent, **kwSettings) 
    5656        self.SplitWindows = [] 
     57        self.wxInitialStandardOptions() 
    5758        self.AddToLayout() 
    5859 
     
    6667            elif self.settings['orientation'] == 'horizontal': 
    6768                self.object.SplitHorizontally(self.SplitWindows[0], self.SplitWindows[1]) 
    68         self.wxInitialStandardOptions() 
    6969 
    7070    def SkinFinalize(self):