fix swi call leak
improve yapi reformat
This commit is contained in:
parent
6b545c8f71
commit
d7e21c80df
4474
C/c_interface.c
4474
C/c_interface.c
File diff suppressed because it is too large
Load Diff
@ -283,7 +283,7 @@ static inline bool Yap_RecoverHandles__(int n, yhandle_t topHandle USES_REGS) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
LOCAL_CurHandle -= n;
|
LOCAL_CurHandle = topHandle;
|
||||||
// fprintf(stderr,"RS %ld %s:%d\n", LOCAL_CurHandle, __FILE__, __LINE__);
|
// fprintf(stderr,"RS %ld %s:%d\n", LOCAL_CurHandle, __FILE__, __LINE__);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
46
gtags.conf
46
gtags.conf
@ -1,46 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (c) 1998, 1999, 2000, 2001, 2002, 2003, 2010, 2011, 2013,
|
|
||||||
# 2015, 2016
|
|
||||||
# Tama Communications Corporation
|
|
||||||
#
|
|
||||||
# This file is part of GNU GLOBAL.
|
|
||||||
#
|
|
||||||
# This file is free software; as a special exception the author gives
|
|
||||||
# unlimited permission to copy and/or distribute it, with or without
|
|
||||||
# modifications, as long as this notice is preserved.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful, but
|
|
||||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
|
||||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
#
|
|
||||||
# *
|
|
||||||
# Configuration file for GNU GLOBAL source code tag system.
|
|
||||||
#
|
|
||||||
# Basically, GLOBAL doesn't need this file ('gtags.conf'), because it has
|
|
||||||
# default values in itsself. If you have the file as '/etc/gtags.conf' or
|
|
||||||
# "$HOME/.globalrc" in your system then GLOBAL overwrite the default values
|
|
||||||
# with the values in the file.
|
|
||||||
#
|
|
||||||
# The format is similar to termcap(5). You can specify a target with
|
|
||||||
# GTAGSLABEL environment variable. Default target is 'default'.
|
|
||||||
#
|
|
||||||
# If you want to have a common record for yourself, it is recommended to
|
|
||||||
# use the following method:
|
|
||||||
#
|
|
||||||
|
|
||||||
common:
|
|
||||||
:skip=Debug/,Release/,Threads/,mxe/,xcode/,codeblocks/,Qt/,xcode/,android/,compile_commands.json,xml/,YAPDroid/app/build/,YAPDroid/lib/build/:HTML/,HTML.pub/,tags,TAGS,ID,y.tab.c,y.tab.h,gtags.files,cscope.files,cscope.out,cscope.po.out,cscope.in.out,SCCS/,RCS/,CVS/,CVSROOT/,{arch}/,autom4te.cache/,*.orig,*.rej,*.bak,*~,#*#,*.swp,*.tmp,*_flymake.*,*_flymake:
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# A common map for both Exuberant Ctags and Universal Ctags.
|
|
||||||
# Don't include definitions of ctagscom and ctagslib in this entry.
|
|
||||||
#
|
|
||||||
default:\
|
|
||||||
yap:native:user:
|
|
||||||
|
|
||||||
yap:\
|
|
||||||
:tc=common:\
|
|
||||||
:langmap=Prolog\:.pl.yap.ypp.P.prolog:\
|
|
||||||
:gtags_parser=Prolog\:$ctagslib:
|
|
||||||
|
|
@ -801,7 +801,7 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ARG1 = Yap_GetFromHandle(s1);
|
ARG1 = Yap_GetFromHandle(s1);
|
||||||
Yap_RecoverHandles(sl, tnum - targ);
|
Yap_RecoverHandles(tnum - targ, sl);
|
||||||
Yap_CloseSlots(sl0);
|
Yap_CloseSlots(sl0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -70,6 +70,7 @@ class Type(object):
|
|||||||
REFERENCE = re.compile("""^(.+)&$""")
|
REFERENCE = re.compile("""^(.+)&$""")
|
||||||
|
|
||||||
def __init__(self, text):
|
def __init__(self, text):
|
||||||
|
# type: (object) -> object
|
||||||
if isinstance(text, Type):
|
if isinstance(text, Type):
|
||||||
self.clone_from(text)
|
self.clone_from(text)
|
||||||
return
|
return
|
||||||
@ -128,6 +129,7 @@ class Constraint(object):
|
|||||||
ARG = re.compile("""((?:[^,<(]|<[^>]*>|\([^)]*\))+),?""")
|
ARG = re.compile("""((?:[^,<(]|<[^>]*>|\([^)]*\))+),?""")
|
||||||
|
|
||||||
def __init__(self, line):
|
def __init__(self, line):
|
||||||
|
# type: (object) -> object
|
||||||
if isinstance(line, Constraint):
|
if isinstance(line, Constraint):
|
||||||
self.clone_from(line)
|
self.clone_from(line)
|
||||||
return
|
return
|
||||||
@ -182,6 +184,7 @@ def load_decls(filename):
|
|||||||
class DeclsLoader(object):
|
class DeclsLoader(object):
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
|
# type: (object) -> object
|
||||||
self.decls = load_decls(filename)
|
self.decls = load_decls(filename)
|
||||||
|
|
||||||
def print_decls(self):
|
def print_decls(self):
|
||||||
@ -201,6 +204,7 @@ class PredGenerator(DeclsLoader):
|
|||||||
"TieBreakVarBranch<SetVarBranch>")
|
"TieBreakVarBranch<SetVarBranch>")
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
|
# type: (object) -> object
|
||||||
super(PredGenerator, self).__init__(filename)
|
super(PredGenerator, self).__init__(filename)
|
||||||
self._change_home_to_space()
|
self._change_home_to_space()
|
||||||
self._change_intsharedarray_to_intargs()
|
self._change_intsharedarray_to_intargs()
|
||||||
@ -291,6 +295,7 @@ class PredGenerator(DeclsLoader):
|
|||||||
class Cluster(object):
|
class Cluster(object):
|
||||||
|
|
||||||
def __init__(self, name, arity):
|
def __init__(self, name, arity):
|
||||||
|
# type: (object, object) -> object
|
||||||
self.name = name
|
self.name = name
|
||||||
self.arity = arity
|
self.arity = arity
|
||||||
self.preds = []
|
self.preds = []
|
||||||
@ -299,6 +304,7 @@ class Cluster(object):
|
|||||||
class DTree(object):
|
class DTree(object):
|
||||||
|
|
||||||
def __init__(self, i, preds, cluster):
|
def __init__(self, i, preds, cluster):
|
||||||
|
# type: (object, object, object) -> object
|
||||||
self.index = i
|
self.index = i
|
||||||
self.cluster = cluster
|
self.cluster = cluster
|
||||||
if len(preds) == 1 and len(preds[0].argtypes) == i:
|
if len(preds) == 1 and len(preds[0].argtypes) == i:
|
||||||
@ -354,6 +360,7 @@ class DTree(object):
|
|||||||
class YAPConstraintGeneratorBase(PredGenerator):
|
class YAPConstraintGeneratorBase(PredGenerator):
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
|
# type: (object) -> object
|
||||||
super(YAPConstraintGeneratorBase, self).__init__(filename)
|
super(YAPConstraintGeneratorBase, self).__init__(filename)
|
||||||
self._classify()
|
self._classify()
|
||||||
self._dtreefy()
|
self._dtreefy()
|
||||||
@ -389,6 +396,7 @@ class YAPConstraintGeneratorBase(PredGenerator):
|
|||||||
class YAPConstraintPrologGenerator(YAPConstraintGeneratorBase):
|
class YAPConstraintPrologGenerator(YAPConstraintGeneratorBase):
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
|
# type: (object) -> object
|
||||||
super(YAPConstraintPrologGenerator, self).__init__(filename)
|
super(YAPConstraintPrologGenerator, self).__init__(filename)
|
||||||
|
|
||||||
def _prolog_clauses(self):
|
def _prolog_clauses(self):
|
||||||
@ -410,6 +418,7 @@ class YAPConstraintPrologGenerator(YAPConstraintGeneratorBase):
|
|||||||
class YAPConstraintCCGenerator(YAPConstraintGeneratorBase):
|
class YAPConstraintCCGenerator(YAPConstraintGeneratorBase):
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
|
# type: (object) -> object
|
||||||
super(YAPConstraintCCGenerator, self).__init__(filename)
|
super(YAPConstraintCCGenerator, self).__init__(filename)
|
||||||
|
|
||||||
def _cc_descriptors(self):
|
def _cc_descriptors(self):
|
||||||
@ -434,6 +443,7 @@ import sys
|
|||||||
class OStream(object):
|
class OStream(object):
|
||||||
|
|
||||||
def __init__(self, fd=sys.stdout):
|
def __init__(self, fd=sys.stdout):
|
||||||
|
# type: (object) -> object
|
||||||
self.file = fd
|
self.file = fd
|
||||||
self.column = 0
|
self.column = 0
|
||||||
|
|
||||||
@ -472,6 +482,7 @@ class PrologObject(object):
|
|||||||
class PrologClause(PrologObject):
|
class PrologClause(PrologObject):
|
||||||
|
|
||||||
def __init__(self, head, body):
|
def __init__(self, head, body):
|
||||||
|
# type: (object, object) -> object
|
||||||
self.head = head
|
self.head = head
|
||||||
self.body = body
|
self.body = body
|
||||||
|
|
||||||
@ -486,6 +497,7 @@ class PrologClause(PrologObject):
|
|||||||
class PrologLiteral(PrologObject):
|
class PrologLiteral(PrologObject):
|
||||||
|
|
||||||
def __init__(self, lit):
|
def __init__(self, lit):
|
||||||
|
# type: (object) -> object
|
||||||
self.literal = lit
|
self.literal = lit
|
||||||
|
|
||||||
def pp(self, out, offset):
|
def pp(self, out, offset):
|
||||||
@ -495,6 +507,7 @@ class PrologLiteral(PrologObject):
|
|||||||
class PrologIF(PrologObject):
|
class PrologIF(PrologObject):
|
||||||
|
|
||||||
def __init__(self, cond, left, right):
|
def __init__(self, cond, left, right):
|
||||||
|
# type: (object, object, object) -> object
|
||||||
self.cond = cond
|
self.cond = cond
|
||||||
self.left = left
|
self.left = left
|
||||||
self.right = right
|
self.right = right
|
||||||
@ -609,6 +622,7 @@ class YAPEnumPrologGenerator(object):
|
|||||||
class CCDescriptor(object):
|
class CCDescriptor(object):
|
||||||
|
|
||||||
def __init__(self, name, argtypes, api):
|
def __init__(self, name, argtypes, api):
|
||||||
|
# type: (object, object, object) -> object
|
||||||
self.name = name
|
self.name = name
|
||||||
self.argtypes = argtypes
|
self.argtypes = argtypes
|
||||||
self.api = api
|
self.api = api
|
||||||
|
@ -6,6 +6,7 @@ from pyswip.easy import getList, registerForeign
|
|||||||
|
|
||||||
class Notifier:
|
class Notifier:
|
||||||
def __init__(self, fun):
|
def __init__(self, fun):
|
||||||
|
# type: (object) -> object
|
||||||
self.fun = fun
|
self.fun = fun
|
||||||
|
|
||||||
def notify(self, t):
|
def notify(self, t):
|
||||||
@ -15,6 +16,7 @@ class Notifier:
|
|||||||
|
|
||||||
class Tower:
|
class Tower:
|
||||||
def __init__(self, N=3, interactive=False):
|
def __init__(self, N=3, interactive=False):
|
||||||
|
# type: (object, object) -> object
|
||||||
"""N is the number of disks
|
"""N is the number of disks
|
||||||
"""
|
"""
|
||||||
self.N = N
|
self.N = N
|
||||||
|
@ -12,6 +12,7 @@ URL = "http://www.sudoku.org.uk/daily.asp"
|
|||||||
|
|
||||||
class DailySudokuPuzzle(HTMLParser):
|
class DailySudokuPuzzle(HTMLParser):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
# type: () -> object
|
||||||
self.puzzle = []
|
self.puzzle = []
|
||||||
self.__in_td = False
|
self.__in_td = False
|
||||||
HTMLParser.__init__(self)
|
HTMLParser.__init__(self)
|
||||||
|
@ -22,6 +22,7 @@ from pyswip.core import *
|
|||||||
|
|
||||||
class InvalidTypeError(TypeError):
|
class InvalidTypeError(TypeError):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
|
# type: (object) -> object
|
||||||
type = args and args[0] or "Unknown"
|
type = args and args[0] or "Unknown"
|
||||||
msg = "Term is expected to be of type: '%s'" % type
|
msg = "Term is expected to be of type: '%s'" % type
|
||||||
Exception.__init__(self, msg, *args)
|
Exception.__init__(self, msg, *args)
|
||||||
@ -31,6 +32,7 @@ class Atom(object):
|
|||||||
__slots__ = "handle","chars"
|
__slots__ = "handle","chars"
|
||||||
|
|
||||||
def __init__(self, handleOrChars):
|
def __init__(self, handleOrChars):
|
||||||
|
# type: (object) -> object
|
||||||
"""Create an atom.
|
"""Create an atom.
|
||||||
``handleOrChars``: handle or string of the atom.
|
``handleOrChars``: handle or string of the atom.
|
||||||
"""
|
"""
|
||||||
@ -71,6 +73,7 @@ class Atom(object):
|
|||||||
class Term(object):
|
class Term(object):
|
||||||
__slots__ = "handle","chars","__value","a0"
|
__slots__ = "handle","chars","__value","a0"
|
||||||
def __init__(self, handle=None, a0=None):
|
def __init__(self, handle=None, a0=None):
|
||||||
|
# type: (object, object) -> object
|
||||||
if handle:
|
if handle:
|
||||||
#self.handle = PL_copy_term_ref(handle)
|
#self.handle = PL_copy_term_ref(handle)
|
||||||
self.handle = handle
|
self.handle = handle
|
||||||
@ -89,6 +92,7 @@ class Variable(object):
|
|||||||
__slots__ = "handle","chars"
|
__slots__ = "handle","chars"
|
||||||
|
|
||||||
def __init__(self, handle=None, name=None):
|
def __init__(self, handle=None, name=None):
|
||||||
|
# type: (object, object) -> object
|
||||||
self.chars = None
|
self.chars = None
|
||||||
if name:
|
if name:
|
||||||
self.chars = name
|
self.chars = name
|
||||||
@ -147,6 +151,7 @@ class Functor(object):
|
|||||||
func = {}
|
func = {}
|
||||||
|
|
||||||
def __init__(self, handleOrName, arity=1, args=None, a0=None):
|
def __init__(self, handleOrName, arity=1, args=None, a0=None):
|
||||||
|
# type: (object, object, object, object) -> object
|
||||||
"""Create a functor.
|
"""Create a functor.
|
||||||
``handleOrName``: functor handle, a string or an atom.
|
``handleOrName``: functor handle, a string or an atom.
|
||||||
"""
|
"""
|
||||||
@ -436,6 +441,7 @@ class Query(object):
|
|||||||
fid = None
|
fid = None
|
||||||
|
|
||||||
def __init__(self, *terms, **kwargs):
|
def __init__(self, *terms, **kwargs):
|
||||||
|
# type: (object, object) -> object
|
||||||
for key in kwargs:
|
for key in kwargs:
|
||||||
if key not in ["flags", "module"]:
|
if key not in ["flags", "module"]:
|
||||||
raise Exception("Invalid kwarg: %s" % key, key)
|
raise Exception("Invalid kwarg: %s" % key, key)
|
||||||
|
@ -53,6 +53,7 @@ class Prolog:
|
|||||||
__slots__ = "swipl_fid","swipl_qid","error"
|
__slots__ = "swipl_fid","swipl_qid","error"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
# type: () -> object
|
||||||
self.error = False
|
self.error = False
|
||||||
|
|
||||||
def __call__(self, query, maxresult, catcherrors, normalize):
|
def __call__(self, query, maxresult, catcherrors, normalize):
|
||||||
|
@ -18,7 +18,6 @@ else()
|
|||||||
add_library (Py4YAP SHARED ${PYTHON_SOURCES} ${PYTHON_HEADERS})
|
add_library (Py4YAP SHARED ${PYTHON_SOURCES} ${PYTHON_HEADERS})
|
||||||
|
|
||||||
# arithmetic hassle.
|
# arithmetic hassle.
|
||||||
set_property(TARGET Py4YAP PROPERTY CXX_STANDARD 11)
|
|
||||||
set_property(TARGET Py4YAP PROPERTY CXX_STANDARD_REQUIRED ON)
|
set_property(TARGET Py4YAP PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
target_link_libraries(Py4YAP libYap ${PYTHON_LIBRARIES})
|
target_link_libraries(Py4YAP libYap ${PYTHON_LIBRARIES})
|
||||||
@ -32,7 +31,6 @@ endif()
|
|||||||
|
|
||||||
|
|
||||||
# arithmetic hassle.
|
# arithmetic hassle.
|
||||||
set_property(TARGET YAPPython PROPERTY CXX_STANDARD 11)
|
|
||||||
set_property(TARGET YAPPython PROPERTY CXX_STANDARD_REQUIRED ON)
|
set_property(TARGET YAPPython PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
target_link_libraries(YAPPython libYap ${PYTHON_LIBRARIES})
|
target_link_libraries(YAPPython libYap ${PYTHON_LIBRARIES})
|
||||||
|
@ -1233,6 +1233,7 @@ PyObject *compound_to_pyeval(term_t t, PyObject *context) {
|
|||||||
Py_DECREF(o);
|
Py_DECREF(o);
|
||||||
DebugPrintf("CallObject %p\n", rc);
|
DebugPrintf("CallObject %p\n", rc);
|
||||||
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
#include "py4yap.h"
|
#include "py4yap.h"
|
||||||
|
|
||||||
|
|
||||||
X_API bool init_python_dll(void);
|
O_API bool init_python_dll(void);
|
||||||
|
|
||||||
|
|
||||||
X_API bool init_python_dll(void)
|
O_API bool init_python_dll(void) {
|
||||||
{
|
|
||||||
do_init_python();
|
do_init_python();
|
||||||
install_pypreds();
|
install_pypreds();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -1,11 +1,48 @@
|
|||||||
|
|
||||||
import yap
|
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
# debugging support.
|
# debugging support.
|
||||||
# import pdb
|
# import pdb
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
from yap import *
|
||||||
|
|
||||||
|
class Engine( YAPEngine ):
|
||||||
|
def __init__(self, args=None):
|
||||||
|
# type: (object) -> object
|
||||||
|
if not args:
|
||||||
|
args = YAPEngineArgs()
|
||||||
|
yap_lib_path = os.path.dirname(__file__)
|
||||||
|
args.setYapShareDir(os.path.join(yap_lib_path,"prolog"))
|
||||||
|
args.setYapLibDir(yap_lib_path)
|
||||||
|
args.setSavedState(os.path.join(yap_lib_path,"startup.yss"))
|
||||||
|
YAPEngine.__init__(self,args)
|
||||||
|
self.goal( set_prolog_flag('verbose', 'silent' ) )
|
||||||
|
self.goal( use_module(library('yapi') ) )
|
||||||
|
|
||||||
|
def run(self, g, m=None):
|
||||||
|
if m:
|
||||||
|
self.mgoal(g, m)
|
||||||
|
else:
|
||||||
|
self.goal(g)
|
||||||
|
|
||||||
|
def f(self, g):
|
||||||
|
self.E.fun(g)
|
||||||
|
|
||||||
|
|
||||||
|
class EngineArgs( YAPEngineArgs ):
|
||||||
|
""" Interface to Engine Options class"""
|
||||||
|
|
||||||
|
|
||||||
|
class Predicate( YAPPredicate ):
|
||||||
|
""" Interface to Generic Predicate"""
|
||||||
|
|
||||||
|
|
||||||
|
class PrologPredicate( YAPPrologPredicate ):
|
||||||
|
""" Interface to Prolog Predicate"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
global engine, handler
|
global engine, handler
|
||||||
|
|
||||||
yap_lib_path = os.path.dirname(__file__)
|
yap_lib_path = os.path.dirname(__file__)
|
||||||
@ -19,6 +56,7 @@ jupyter_query = namedtuple( 'jupyter_query', 'vars dict')
|
|||||||
python_query = namedtuple( 'python_query', 'vars dict')
|
python_query = namedtuple( 'python_query', 'vars dict')
|
||||||
yapi_query = namedtuple( 'yapi_query', 'vars dict')
|
yapi_query = namedtuple( 'yapi_query', 'vars dict')
|
||||||
show_answer = namedtuple( 'show_answer', 'vars dict')
|
show_answer = namedtuple( 'show_answer', 'vars dict')
|
||||||
|
set_prolog_flag = namedtuple('set_prolog_flag', 'flag new_value')
|
||||||
|
|
||||||
def v():
|
def v():
|
||||||
return yap.YAPVarTerm()
|
return yap.YAPVarTerm()
|
||||||
@ -97,16 +135,6 @@ def query_prolog(engine, s):
|
|||||||
q.close()
|
q.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
def boot_yap(**kwargs):
|
|
||||||
yap_lib_path = os.path.dirname(__file__)
|
|
||||||
args = yap.YAPEngineArgs()
|
|
||||||
args.setYapShareDir(os.path.join(yap_lib_path,"prolog"))
|
|
||||||
args.setYapLibDir(yap_lib_path)
|
|
||||||
args.setSavedState(os.path.join(yap_lib_path,"startup.yss"))
|
|
||||||
engine = yap.YAPEngine(args)
|
|
||||||
engine.goal( use_module(library('yapi') ) )
|
|
||||||
return engine
|
|
||||||
|
|
||||||
def live(**kwargs):
|
def live(**kwargs):
|
||||||
loop = True
|
loop = True
|
||||||
while loop:
|
while loop:
|
||||||
|
@ -1,53 +1,53 @@
|
|||||||
|
|
||||||
set (EXTRAS
|
set (EXTRAS
|
||||||
MANIFEST.in
|
MANIFEST.in
|
||||||
YAP_KERNEL.md
|
YAP_KERNEL.md
|
||||||
)
|
)
|
||||||
|
|
||||||
set (PYTHON_SOURCES
|
set (PYTHON_SOURCES
|
||||||
yap_kernel_launcher.py
|
yap_kernel_launcher.py
|
||||||
data_kernelspec/kernel.json
|
data_kernelspec/kernel.json
|
||||||
yap_kernel/__init__.py
|
yap_kernel/__init__.py
|
||||||
yap_kernel/__main__.py
|
yap_kernel/__main__.py
|
||||||
yap_kernel/_version.py
|
yap_kernel/_version.py
|
||||||
yap_kernel/codeutil.py
|
yap_kernel/codeutil.py
|
||||||
yap_kernel/connect.py
|
yap_kernel/connect.py
|
||||||
yap_kernel/datapub.py
|
yap_kernel/datapub.py
|
||||||
yap_kernel/displayhook.py
|
yap_kernel/displayhook.py
|
||||||
yap_kernel/embed.py
|
yap_kernel/embed.py
|
||||||
yap_kernel/eventloops.py
|
yap_kernel/eventloops.py
|
||||||
yap_kernel/heartbeat.py
|
yap_kernel/heartbeat.py
|
||||||
yap_kernel/interactiveshell.py
|
yap_kernel/interactiveshell.py
|
||||||
yap_kernel/iostream.py
|
yap_kernel/iostream.py
|
||||||
yap_kernel/jsonutil.py
|
yap_kernel/jsonutil.py
|
||||||
yap_kernel/kernelapp.py
|
yap_kernel/kernelapp.py
|
||||||
yap_kernel/kernelbase.py
|
yap_kernel/kernelbase.py
|
||||||
yap_kernel/kernelspec.py
|
yap_kernel/kernelspec.py
|
||||||
yap_kernel/log.py
|
yap_kernel/log.py
|
||||||
yap_kernel/parentpoller.py
|
yap_kernel/parentpoller.py
|
||||||
yap_kernel/pickleutil.py
|
yap_kernel/pickleutil.py
|
||||||
yap_kernel/serialize.py
|
yap_kernel/serialize.py
|
||||||
yap_kernel/yapkernel.py
|
yap_kernel/yapkernel.py
|
||||||
yap_kernel/zmqshell.py
|
yap_kernel/zmqshell.py
|
||||||
yap_kernel/comm/__init__.py
|
yap_kernel/comm/__init__.py
|
||||||
yap_kernel/comm/comm.py
|
yap_kernel/comm/comm.py
|
||||||
yap_kernel/comm/manager.py
|
yap_kernel/comm/manager.py
|
||||||
yap_kernel/gui/__init__.py
|
yap_kernel/gui/__init__.py
|
||||||
yap_kernel/gui/gtk3embed.py
|
yap_kernel/gui/gtk3embed.py
|
||||||
yap_kernel/gui/gtkembed.py
|
yap_kernel/gui/gtkembed.py
|
||||||
yap_kernel/inprocess/__init__.py
|
yap_kernel/inprocess/__init__.py
|
||||||
yap_kernel/inprocess/blocking.py
|
yap_kernel/inprocess/blocking.py
|
||||||
yap_kernel/inprocess/channels.py
|
yap_kernel/inprocess/channels.py
|
||||||
yap_kernel/inprocess/client.py
|
yap_kernel/inprocess/client.py
|
||||||
yap_kernel/inprocess/ipkernel.py
|
yap_kernel/inprocess/ipkernel.py
|
||||||
yap_kernel/inprocess/manager.py
|
yap_kernel/inprocess/manager.py
|
||||||
yap_kernel/inprocess/socket.py
|
yap_kernel/inprocess/socket.py
|
||||||
yap_kernel/pylab/__init__.py
|
yap_kernel/pylab/__init__.py
|
||||||
yap_kernel/pylab/backend_inline.py
|
yap_kernel/pylab/backend_inline.py
|
||||||
yap_kernel/pylab/config.py
|
yap_kernel/pylab/config.py
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_file(setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
|
configure_file(setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources)
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources)
|
||||||
file(COPY yap_kernel DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
file(COPY yap_kernel DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
@ -61,12 +61,12 @@
|
|||||||
set(SETUP_PY ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
|
set(SETUP_PY ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
|
||||||
|
|
||||||
add_custom_target( YAPKernel ALL
|
add_custom_target( YAPKernel ALL
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} sdist
|
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} sdist
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-index -f dist yap_kernel
|
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-index -f dist yap_kernel
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
|
||||||
|
|
||||||
# install(FILES jupyter.yap
|
# install(FILES jupyter.yap
|
||||||
# DESTINATION ${libpl} )
|
# DESTINATION ${libpl} )
|
||||||
|
@ -28,6 +28,7 @@ from internal_yapkernel import InternalYAPKernel
|
|||||||
class SimpleWindow(Qt.QWidget, InternalYAPKernel):
|
class SimpleWindow(Qt.QWidget, InternalYAPKernel):
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
|
# type: (object) -> object
|
||||||
Qt.QWidget.__init__(self)
|
Qt.QWidget.__init__(self)
|
||||||
self.app = app
|
self.app = app
|
||||||
self.add_widgets()
|
self.add_widgets()
|
||||||
|
@ -36,6 +36,7 @@ class MyFrame(wx.Frame, InternalYAPKernel):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, parent, title):
|
def __init__(self, parent, title):
|
||||||
|
# type: (object, object) -> object
|
||||||
wx.Frame.__init__(self, parent, -1, title,
|
wx.Frame.__init__(self, parent, -1, title,
|
||||||
pos=(150, 150), size=(350, 285))
|
pos=(150, 150), size=(350, 285))
|
||||||
|
|
||||||
|
@ -85,10 +85,6 @@ if 'develop' in sys.argv or any(a.startswith('bdist') for a in sys.argv):
|
|||||||
|
|
||||||
setuptools_args = {}
|
setuptools_args = {}
|
||||||
install_requires = setuptools_args['install_requires'] = [
|
install_requires = setuptools_args['install_requires'] = [
|
||||||
'ipython>=4.0.0',
|
|
||||||
'traitlets>=4.1.0',
|
|
||||||
'jupyter_client',
|
|
||||||
'tornado>=4.0',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if any(a.startswith(('bdist', 'build', 'install')) for a in sys.argv):
|
if any(a.startswith(('bdist', 'build', 'install')) for a in sys.argv):
|
||||||
|
@ -48,6 +48,7 @@ class Comm(LoggingConfigurable):
|
|||||||
_closed = Bool(True)
|
_closed = Bool(True)
|
||||||
|
|
||||||
def __init__(self, target_name='', data=None, metadata=None, buffers=None, **kwargs):
|
def __init__(self, target_name='', data=None, metadata=None, buffers=None, **kwargs):
|
||||||
|
# type: (object, object, object, object, object) -> object
|
||||||
if target_name:
|
if target_name:
|
||||||
kwargs['target_name'] = target_name
|
kwargs['target_name'] = target_name
|
||||||
super(Comm, self).__init__(**kwargs)
|
super(Comm, self).__init__(**kwargs)
|
||||||
|
@ -18,6 +18,7 @@ class ZMQDisplayHook(object):
|
|||||||
topic = b'execute_result'
|
topic = b'execute_result'
|
||||||
|
|
||||||
def __init__(self, session, pub_socket):
|
def __init__(self, session, pub_socket):
|
||||||
|
# type: (object, object) -> object
|
||||||
self.session = session
|
self.session = session
|
||||||
self.pub_socket = pub_socket
|
self.pub_socket = pub_socket
|
||||||
self.parent_header = {}
|
self.parent_header = {}
|
||||||
|
@ -138,6 +138,7 @@ def loop_wx(kernel):
|
|||||||
# We make the Frame hidden when we create it in the main app below.
|
# We make the Frame hidden when we create it in the main app below.
|
||||||
class TimerFrame(wx.Frame):
|
class TimerFrame(wx.Frame):
|
||||||
def __init__(self, func):
|
def __init__(self, func):
|
||||||
|
# type: (object) -> object
|
||||||
wx.Frame.__init__(self, None, -1)
|
wx.Frame.__init__(self, None, -1)
|
||||||
self.timer = wx.Timer(self)
|
self.timer = wx.Timer(self)
|
||||||
# Units for the timer are in milliseconds
|
# Units for the timer are in milliseconds
|
||||||
@ -184,6 +185,7 @@ def loop_tk(kernel):
|
|||||||
# For Tkinter, we create a Tk object and call its withdraw method.
|
# For Tkinter, we create a Tk object and call its withdraw method.
|
||||||
class Timer(object):
|
class Timer(object):
|
||||||
def __init__(self, func):
|
def __init__(self, func):
|
||||||
|
# type: (object) -> object
|
||||||
self.app = Tk()
|
self.app = Tk()
|
||||||
self.app.withdraw()
|
self.app.withdraw()
|
||||||
self.func = func
|
self.func = func
|
||||||
|
@ -27,6 +27,7 @@ class GTKEmbed(object):
|
|||||||
"""A class to embed a kernel into the GTK main event loop.
|
"""A class to embed a kernel into the GTK main event loop.
|
||||||
"""
|
"""
|
||||||
def __init__(self, kernel):
|
def __init__(self, kernel):
|
||||||
|
# type: (object) -> object
|
||||||
self.kernel = kernel
|
self.kernel = kernel
|
||||||
# These two will later store the real gtk functions when we hijack them
|
# These two will later store the real gtk functions when we hijack them
|
||||||
self.gtk_main = None
|
self.gtk_main = None
|
||||||
|
@ -25,6 +25,7 @@ class GTKEmbed(object):
|
|||||||
"""A class to embed a kernel into the GTK main event loop.
|
"""A class to embed a kernel into the GTK main event loop.
|
||||||
"""
|
"""
|
||||||
def __init__(self, kernel):
|
def __init__(self, kernel):
|
||||||
|
# type: (object) -> object
|
||||||
self.kernel = kernel
|
self.kernel = kernel
|
||||||
# These two will later store the real gtk functions when we hijack them
|
# These two will later store the real gtk functions when we hijack them
|
||||||
self.gtk_main = None
|
self.gtk_main = None
|
||||||
|
@ -30,6 +30,7 @@ class Heartbeat(Thread):
|
|||||||
"A simple ping-pong style heartbeat that runs in a thread."
|
"A simple ping-pong style heartbeat that runs in a thread."
|
||||||
|
|
||||||
def __init__(self, context, addr=None):
|
def __init__(self, context, addr=None):
|
||||||
|
# type: (object, object) -> object
|
||||||
if addr is None:
|
if addr is None:
|
||||||
addr = ('tcp', localhost(), 0)
|
addr = ('tcp', localhost(), 0)
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
|
@ -27,6 +27,7 @@ from .client import InProcessKernelClient
|
|||||||
class BlockingInProcessChannel(InProcessChannel):
|
class BlockingInProcessChannel(InProcessChannel):
|
||||||
|
|
||||||
def __init__(self, *args, **kwds):
|
def __init__(self, *args, **kwds):
|
||||||
|
# type: (object, object) -> object
|
||||||
super(BlockingInProcessChannel, self).__init__(*args, **kwds)
|
super(BlockingInProcessChannel, self).__init__(*args, **kwds)
|
||||||
self._in_queue = Queue()
|
self._in_queue = Queue()
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ class InProcessChannel(object):
|
|||||||
proxy_methods = []
|
proxy_methods = []
|
||||||
|
|
||||||
def __init__(self, client=None):
|
def __init__(self, client=None):
|
||||||
|
# type: (object) -> object
|
||||||
super(InProcessChannel, self).__init__()
|
super(InProcessChannel, self).__init__()
|
||||||
self.client = client
|
self.client = client
|
||||||
self._is_alive = False
|
self._is_alive = False
|
||||||
@ -70,6 +71,7 @@ class InProcessHBChannel(object):
|
|||||||
time_to_dead = 3.0
|
time_to_dead = 3.0
|
||||||
|
|
||||||
def __init__(self, client=None):
|
def __init__(self, client=None):
|
||||||
|
# type: (object) -> object
|
||||||
super(InProcessHBChannel, self).__init__()
|
super(InProcessHBChannel, self).__init__()
|
||||||
self.client = client
|
self.client = client
|
||||||
self._is_alive = False
|
self._is_alive = False
|
||||||
|
@ -70,6 +70,7 @@ class InProcessKernel(YAPKernel):
|
|||||||
stdin_socket = Instance(DummySocket, ())
|
stdin_socket = Instance(DummySocket, ())
|
||||||
|
|
||||||
def __init__(self, **traits):
|
def __init__(self, **traits):
|
||||||
|
# type: (object) -> object
|
||||||
super(InProcessKernel, self).__init__(**traits)
|
super(InProcessKernel, self).__init__(**traits)
|
||||||
|
|
||||||
self._underlying_iopub_socket.observe(self._io_dispatch, names=['message_sent'])
|
self._underlying_iopub_socket.observe(self._io_dispatch, names=['message_sent'])
|
||||||
|
@ -98,6 +98,7 @@ class YAPInteraction:
|
|||||||
"""An enhanced, interactive shell for YAP."""
|
"""An enhanced, interactive shell for YAP."""
|
||||||
|
|
||||||
def __init__(self, shell, **kwargs):
|
def __init__(self, shell, **kwargs):
|
||||||
|
# type: (object, object) -> object
|
||||||
try:
|
try:
|
||||||
if self.yapeng:
|
if self.yapeng:
|
||||||
return
|
return
|
||||||
|
@ -43,6 +43,7 @@ class IOPubThread(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, socket, pipe=False):
|
def __init__(self, socket, pipe=False):
|
||||||
|
# type: (object, object) -> object
|
||||||
"""Create IOPub thread
|
"""Create IOPub thread
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@ -220,6 +221,7 @@ class BackgroundSocket(object):
|
|||||||
io_thread = None
|
io_thread = None
|
||||||
|
|
||||||
def __init__(self, io_thread):
|
def __init__(self, io_thread):
|
||||||
|
# type: (object) -> object
|
||||||
self.io_thread = io_thread
|
self.io_thread = io_thread
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
@ -261,6 +263,7 @@ class OutStream(TextIOBase):
|
|||||||
encoding = 'UTF-8'
|
encoding = 'UTF-8'
|
||||||
|
|
||||||
def __init__(self, session, pub_thread, name, pipe=None):
|
def __init__(self, session, pub_thread, name, pipe=None):
|
||||||
|
# type: (object, object, object, object) -> object
|
||||||
if pipe is not None:
|
if pipe is not None:
|
||||||
warnings.warn("pipe argument to OutStream is deprecated and ignored",
|
warnings.warn("pipe argument to OutStream is deprecated and ignored",
|
||||||
DeprecationWarning)
|
DeprecationWarning)
|
||||||
|
@ -134,6 +134,7 @@ class Kernel(SingletonConfigurable):
|
|||||||
control_msg_types = msg_types + ['clear_request', 'abort_request']
|
control_msg_types = msg_types + ['clear_request', 'abort_request']
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
# type: (object) -> object
|
||||||
super(Kernel, self).__init__(**kwargs)
|
super(Kernel, self).__init__(**kwargs)
|
||||||
|
|
||||||
# Build dict of handlers for message types
|
# Build dict of handlers for message types
|
||||||
|
@ -10,6 +10,7 @@ class EnginePUBHandler(PUBHandler):
|
|||||||
engine=None
|
engine=None
|
||||||
|
|
||||||
def __init__(self, engine, *args, **kwargs):
|
def __init__(self, engine, *args, **kwargs):
|
||||||
|
# type: (object, object, object) -> object
|
||||||
PUBHandler.__init__(self,*args, **kwargs)
|
PUBHandler.__init__(self,*args, **kwargs)
|
||||||
self.engine = engine
|
self.engine = engine
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ class ParentPollerUnix(Thread):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
# type: () -> object
|
||||||
super(ParentPollerUnix, self).__init__()
|
super(ParentPollerUnix, self).__init__()
|
||||||
self.daemon = True
|
self.daemon = True
|
||||||
|
|
||||||
@ -50,6 +51,7 @@ class ParentPollerWindows(Thread):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, interrupt_handle=None, parent_handle=None):
|
def __init__(self, interrupt_handle=None, parent_handle=None):
|
||||||
|
# type: (object, object) -> object
|
||||||
""" Create the poller. At least one of the optional parameters must be
|
""" Create the poller. At least one of the optional parameters must be
|
||||||
provided.
|
provided.
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@ def use_cloudpickle():
|
|||||||
|
|
||||||
class CannedObject(object):
|
class CannedObject(object):
|
||||||
def __init__(self, obj, keys=[], hook=None):
|
def __init__(self, obj, keys=[], hook=None):
|
||||||
|
# type: (object, object, object) -> object
|
||||||
"""can an object for safe pickling
|
"""can an object for safe pickling
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@ -167,6 +168,7 @@ class CannedObject(object):
|
|||||||
class Reference(CannedObject):
|
class Reference(CannedObject):
|
||||||
"""object for wrapping a remote reference by name."""
|
"""object for wrapping a remote reference by name."""
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
|
# type: (object) -> object
|
||||||
if not isinstance(name, string_types):
|
if not isinstance(name, string_types):
|
||||||
raise TypeError("illegal name: %r"%name)
|
raise TypeError("illegal name: %r"%name)
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -185,6 +187,7 @@ class Reference(CannedObject):
|
|||||||
class CannedCell(CannedObject):
|
class CannedCell(CannedObject):
|
||||||
"""Can a closure cell"""
|
"""Can a closure cell"""
|
||||||
def __init__(self, cell):
|
def __init__(self, cell):
|
||||||
|
# type: (object) -> object
|
||||||
self.cell_contents = can(cell.cell_contents)
|
self.cell_contents = can(cell.cell_contents)
|
||||||
|
|
||||||
def get_object(self, g=None):
|
def get_object(self, g=None):
|
||||||
@ -197,6 +200,7 @@ class CannedCell(CannedObject):
|
|||||||
class CannedFunction(CannedObject):
|
class CannedFunction(CannedObject):
|
||||||
|
|
||||||
def __init__(self, f):
|
def __init__(self, f):
|
||||||
|
# type: (object) -> object
|
||||||
self._check_type(f)
|
self._check_type(f)
|
||||||
self.code = f.__code__
|
self.code = f.__code__
|
||||||
if f.__defaults__:
|
if f.__defaults__:
|
||||||
@ -239,6 +243,7 @@ class CannedFunction(CannedObject):
|
|||||||
class CannedClass(CannedObject):
|
class CannedClass(CannedObject):
|
||||||
|
|
||||||
def __init__(self, cls):
|
def __init__(self, cls):
|
||||||
|
# type: (object) -> object
|
||||||
self._check_type(cls)
|
self._check_type(cls)
|
||||||
self.name = cls.__name__
|
self.name = cls.__name__
|
||||||
self.old_style = not isinstance(cls, type)
|
self.old_style = not isinstance(cls, type)
|
||||||
@ -263,6 +268,7 @@ class CannedClass(CannedObject):
|
|||||||
|
|
||||||
class CannedArray(CannedObject):
|
class CannedArray(CannedObject):
|
||||||
def __init__(self, obj):
|
def __init__(self, obj):
|
||||||
|
# type: (object) -> object
|
||||||
from numpy import ascontiguousarray
|
from numpy import ascontiguousarray
|
||||||
self.shape = obj.shape
|
self.shape = obj.shape
|
||||||
self.dtype = obj.dtype.descr if obj.dtype.fields else obj.dtype.str
|
self.dtype = obj.dtype.descr if obj.dtype.fields else obj.dtype.str
|
||||||
@ -300,6 +306,7 @@ class CannedBytes(CannedObject):
|
|||||||
wrap = staticmethod(buffer_to_bytes)
|
wrap = staticmethod(buffer_to_bytes)
|
||||||
|
|
||||||
def __init__(self, obj):
|
def __init__(self, obj):
|
||||||
|
# type: (object) -> object
|
||||||
self.buffers = [obj]
|
self.buffers = [obj]
|
||||||
|
|
||||||
def get_object(self, g=None):
|
def get_object(self, g=None):
|
||||||
|
@ -61,6 +61,7 @@ class Reference(HasTraits):
|
|||||||
|
|
||||||
class Version(Unicode):
|
class Version(Unicode):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
# type: (object, object) -> object
|
||||||
self.min = kwargs.pop('min', None)
|
self.min = kwargs.pop('min', None)
|
||||||
self.max = kwargs.pop('max', None)
|
self.max = kwargs.pop('max', None)
|
||||||
kwargs['default_value'] = self.min
|
kwargs['default_value'] = self.min
|
||||||
|
@ -35,6 +35,7 @@ class YAPKernel(KernelBase):
|
|||||||
_sys_eval_input = Any()
|
_sys_eval_input = Any()
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
# type: (object) -> object
|
||||||
super(YAPKernel, self).__init__(**kwargs)
|
super(YAPKernel, self).__init__(**kwargs)
|
||||||
|
|
||||||
# Initialize the InteractiveShell subclass
|
# Initialize the InteractiveShell subclass
|
||||||
@ -376,6 +377,7 @@ class YAPKernel(KernelBase):
|
|||||||
|
|
||||||
class Kernel(YAPKernel):
|
class Kernel(YAPKernel):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
# type: (object, object) -> object
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn('Kernel is a deprecated alias of yap_kernel.yapkernel.YAPKernel',
|
warnings.warn('Kernel is a deprecated alias of yap_kernel.yapkernel.YAPKernel',
|
||||||
DeprecationWarning)
|
DeprecationWarning)
|
||||||
|
@ -950,4 +950,4 @@ prolog:message( r_root ) -->
|
|||||||
|
|
||||||
:- initialization( set_prolog_flag( double_quotes, string) ).
|
:- initialization( set_prolog_flag( double_quotes, string) ).
|
||||||
|
|
||||||
@}
|
%%% @}
|
||||||
|
Reference in New Issue
Block a user