home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import re
- from IPython.hooks import CommandChainDispatcher
- import IPython.hooks as IPython
-
- class StrDispatch(object):
-
- def __init__(self):
- self.strs = { }
- self.regexs = { }
-
-
- def add_s(self, s, obj, priority = 0):
- chain = self.strs.get(s, CommandChainDispatcher())
- chain.add(obj, priority)
- self.strs[s] = chain
-
-
- def add_re(self, regex, obj, priority = 0):
- chain = self.regexs.get(regex, CommandChainDispatcher())
- chain.add(obj, priority)
- self.regexs[regex] = chain
-
-
- def dispatch(self, key):
- if key in self.strs:
- yield self.strs[key]
-
- for r, obj in self.regexs.items():
- if re.match(r, key):
- yield obj
- continue
-
-
-
- def __repr__(self):
- return '<Strdispatch %s, %s>' % (self.strs, self.regexs)
-
-
- def s_matches(self, key):
- if key not in self.strs:
- return None
- for el in self.strs[key]:
- yield el[1]
- key not in self.strs
-
-
-
- def flat_matches(self, key):
- for val in self.dispatch(key):
- for el in val:
- yield el[1]
-
-
-
-
-