Beispiel #1
0
    def __init__(self, *args, **kwargs):
        '''
        Create the hy environment
        '''
        super(HyKernel, self).__init__(*args, **kwargs)
        load_stdlib()
        [load_macros(m) for m in ['hy.core', 'hy.macros']]

        self._cell_magic_warned = False
        self._line_magic_warned = False
Beispiel #2
0
    def __init__(self, *args, **kwargs):
        '''
        Create the hy environment
        '''
        super(HyKernel, self).__init__(*args, **kwargs)
        load_stdlib()
        [load_macros(m) for m in ['hy.core', 'hy.macros']]

        self._cell_magic_warned = False
        self._line_magic_warned = False
Beispiel #3
0
    def complete(txt):
        try:
            from hy.compiler import _compile_table, load_stdlib
            load_stdlib()
        except:
            _compile_table = []

        matches = [word for word in env if word.startswith(txt)]
        for p in _compile_table + list(env.__macros__):
            p = filter(lambda x: isinstance(x, str), p.keys())
            p = [x.replace('_', '-') for x in p]
            matches.extend(
                [x for x in p if x.startswith(txt) and x not in matches])
        return matches
Beispiel #4
0
 def __init__(self, *args, **kwargs):
     '''
     Create the hy environment
     '''
     self.env = {}
     super(CalystoHy, self).__init__(*args, **kwargs)
     load_stdlib()
     [load_macros(m) for m in ['hy.core', 'hy.macros']]
     if "str" in dir(__builtins__):
         self.env.update(
             {key: getattr(__builtins__, key)
              for key in dir(__builtins__)})
     if "keys" in dir(__builtins__):
         self.env.update(__builtins__)
     self.env["raw_input"] = self.raw_input
     self.env["read"] = self.raw_input
     self.env["input"] = self.raw_input
     # Because using eval of mode="single":
     sys.displayhook = self.displayhook
Beispiel #5
0
    def _find_hy_completions(self, partial_name):
        from hy.macros import _hy_macros
        from hy.compiler import load_stdlib, _stdlib, _compile_table
        from itertools import chain
        from keyword import iskeyword

        # Without this, built in macros will not load until after
        # the first sexp is evalutaed
        load_stdlib()

        matches = []

        # Add macros
        for namespace in _hy_macros.values():
            for name in namespace.keys():
                if name.startswith(partial_name):
                    matches.append(name)

        # Add builtins
        for name in chain(_stdlib.keys(), _compile_table.keys()):
            if str(name).startswith(partial_name) and not iskeyword(str(name)):
                matches.append(name)
        return matches
Beispiel #6
0
    def _find_hy_completions(self, partial_name):
        from hy.macros import _hy_macros
        from hy.compiler import load_stdlib, _stdlib, _compile_table
        from itertools import chain
        from keyword import iskeyword

        # Without this, built in macros will not load until after
        # the first sexp is evalutaed
        load_stdlib()

        matches = []

        # Add macros
        for namespace in _hy_macros.values():
            for name in namespace.keys():
                if name.startswith(partial_name):
                    matches.append(name)

        # Add builtins
        for name in chain(_stdlib.keys(), _compile_table.keys()):
            if str(name).startswith(partial_name) and not iskeyword(str(name)):
                matches.append(name)
        return matches