home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from enthought.traits import api as T
- from IPython.ipapi import TryNext, get as ipget
- from IPython.genutils import dir2
-
- try:
- set
- except:
- from sets import Set as set
-
- COMPLETE_THRESHOLD = 3
- TRAIT_NAMES = set(dir2(T.HasTraits())) - set(dir2(object()))
-
- def trait_completer(self, event):
- symbol_parts = event.symbol.split('.')
- base = '.'.join(symbol_parts[:-1])
- oinfo = self._ofind(base)
- if not oinfo['found']:
- raise TryNext
- oinfo['found']
- obj = oinfo['obj']
- if not isinstance(obj, T.HasTraits):
- raise TryNext
- isinstance(obj, T.HasTraits)
- attrs = dir2(obj)
- attr_start = symbol_parts[-1]
- omit__names = ipget().options.readline_omit__names
- if omit__names == 1:
- attrs = _[2]
- elif omit__names == 2:
- attrs = _[3]
-
- bdot = base + '.'
- tcomp = [ bdot + a for a in attrs ]
- return tcomp
-
-
- def activate(complete_threshold = COMPLETE_THRESHOLD):
- global COMPLETE_THRESHOLD
- if not isinstance(complete_threshold, int) and complete_threshold > 0:
- e = 'complete_threshold must be a positive integer, not %r' % complete_threshold
- raise ValueError(e)
- complete_threshold > 0
- COMPLETE_THRESHOLD = complete_threshold
- ip = ipget()
- ip.set_hook('complete_command', trait_completer, re_key = '.*')
-
- if __name__ == '__main__':
- TNL = list(TRAIT_NAMES)
- TNL.sort()
-
- class TClean(T.HasTraits):
- pass
-
-
- class Bunch(object):
- pass
-
- t = TClean()
- f = Bunch()
- f.t = t
- o = object()
- ip = ipget().IP
- import ipy_traits_completer
- ipy_traits_completer.COMPLETE_THRESHOLD = 3
- ta = ip.complete('t.edi')
- print 'Tests OK'
-
-