diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2009-09-10 18:13:04 +0200 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2009-09-10 18:13:04 +0200 |
commit | a7092cb6c3248ddd2b3330922204fb504bd4accd (patch) | |
tree | b11fd34773c61b11a93104d8ad2f465dce27c8f6 /protocols.py | |
parent | 5362f4a0eae9efa8b625ba0de078951c83e66769 (diff) | |
download | astroid-git-a7092cb6c3248ddd2b3330922204fb504bd4accd.tar.gz |
[R] demonkey patching some Const, Dict, List and Tuple attributes
Diffstat (limited to 'protocols.py')
-rw-r--r-- | protocols.py | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/protocols.py b/protocols.py index 28f17aec..3837a31a 100644 --- a/protocols.py +++ b/protocols.py @@ -332,48 +332,3 @@ nodes.With.ass_type = end_ass_type -# iteration protocol ########################################################## - -def const_itered(self): - if isinstance(self.value, basestring): - return self.value - raise TypeError() -nodes.Const.itered = const_itered - - -def tl_itered(self): - return self.elts -nodes.Tuple.itered = tl_itered -nodes.List.itered = tl_itered - - -def dict_itered(self): - return self.items[::2] -nodes.Dict.itered = dict_itered - - -# subscription protocol ####################################################### - -def const_getitem(self, index, context=None): - if isinstance(self.value, basestring): - return self.value[index] - raise TypeError() -nodes.Const.getitem = const_getitem - - -def tl_getitem(self, index, context=None): - return self.elts[index] -nodes.Tuple.getitem = tl_getitem -nodes.List.getitem = tl_getitem - - -def dict_getitem(self, key, context=None): - for i in xrange(0, len(self.items), 2): - for inferedkey in self.items[i].infer(context): - if inferedkey is YES: - continue - if isinstance(inferedkey, Const) and inferedkey.value == key: - return self.items[i+1] - raise IndexError(key) -nodes.Dict.getitem = dict_getitem - |