proxy.py (3105:993f1abefd67) | proxy.py (3109:c3956807347f) |
---|---|
1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 25 unchanged lines hidden (view full) --- 34##################################################################### 35 36class BaseProxy(object): 37 def __init__(self, search_self, search_up): 38 self._search_self = search_self 39 self._search_up = search_up 40 self._multiplier = None 41 | 1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 25 unchanged lines hidden (view full) --- 34##################################################################### 35 36class BaseProxy(object): 37 def __init__(self, search_self, search_up): 38 self._search_self = search_self 39 self._search_up = search_up 40 self._multiplier = None 41 |
42 def __str__(self): 43 if self._search_self and not self._search_up: 44 s = 'Self' 45 elif not self._search_self and self._search_up: 46 s = 'Parent' 47 else: 48 s = 'ConfusedProxy' 49 return s + '.' + self.path() 50 |
|
42 def __setattr__(self, attr, value): 43 if not attr.startswith('_'): 44 raise AttributeError, \ 45 "cannot set attribute '%s' on proxy object" % attr 46 super(BaseProxy, self).__setattr__(attr, value) 47 48 # support multiplying proxies by constants 49 def __mul__(self, other): --- 47 unchanged lines hidden (view full) --- 97 except TypeError: 98 if index != 0: 99 raise 100 # if index is 0 and item is not subscriptable, just 101 # use item itself (so cpu[0] works on uniprocessors) 102 return obj 103 getindex = staticmethod(getindex) 104 | 51 def __setattr__(self, attr, value): 52 if not attr.startswith('_'): 53 raise AttributeError, \ 54 "cannot set attribute '%s' on proxy object" % attr 55 super(BaseProxy, self).__setattr__(attr, value) 56 57 # support multiplying proxies by constants 58 def __mul__(self, other): --- 47 unchanged lines hidden (view full) --- 106 except TypeError: 107 if index != 0: 108 raise 109 # if index is 0 and item is not subscriptable, just 110 # use item itself (so cpu[0] works on uniprocessors) 111 return obj 112 getindex = staticmethod(getindex) 113 |
114 # This method should be called once the proxy is assigned to a 115 # particular parameter or port to set the expected type of the 116 # resolved proxy |
|
105 def set_param_desc(self, pdesc): 106 self._pdesc = pdesc 107 108class AttrProxy(BaseProxy): 109 def __init__(self, search_self, search_up, attr): 110 super(AttrProxy, self).__init__(search_self, search_up) 111 self._attr = attr 112 self._modifiers = [] --- 82 unchanged lines hidden --- | 117 def set_param_desc(self, pdesc): 118 self._pdesc = pdesc 119 120class AttrProxy(BaseProxy): 121 def __init__(self, search_self, search_up, attr): 122 super(AttrProxy, self).__init__(search_self, search_up) 123 self._attr = attr 124 self._modifiers = [] --- 82 unchanged lines hidden --- |