Merge 192.168.1.79:github/yap-6.3
This commit is contained in:
33
packages/python/swig/yap4py/__init__.py
Normal file
33
packages/python/swig/yap4py/__init__.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import imp
|
||||
import os
|
||||
import ctypes
|
||||
import glob
|
||||
import os.path
|
||||
import platform
|
||||
import sys
|
||||
|
||||
global yap_lib_path
|
||||
yap_lib_path = "/home/vsc/anaconda3/conda-bld/yap4py_1522052049872/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib"
|
||||
|
||||
if platform.system() == 'Windows':
|
||||
def load( dll ):
|
||||
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
|
||||
dll = os.path.abspath(dll)
|
||||
ctypes.WinDLL(dll)
|
||||
elif platform.system() == 'Darwin':
|
||||
def load( dll ):
|
||||
dll = glob.glob(os.path.join(os.path.dirname(__file__),dll))[0]
|
||||
dll = os.path.abspath(dll)
|
||||
ctypes.CDLL(dll)
|
||||
print('loaded ',dll)
|
||||
|
||||
# try:
|
||||
# load( '_yap*.so' )
|
||||
# except:
|
||||
# load( '_yap*.dylib' )
|
||||
else:
|
||||
def load( dll ):
|
||||
dll = glob.glob(os.path.join(os.path.dirname(__file__),dll))[0]
|
||||
dll = os.path.abspath(dll)
|
||||
ctypes.CDLL(dll)
|
||||
#load('_yap*.so')
|
@@ -67,7 +67,6 @@ class Query:
|
||||
return self
|
||||
|
||||
def __next__(self):
|
||||
print(self)
|
||||
if not self.q:
|
||||
raise StopIteration()
|
||||
if self.q.next():
|
||||
@@ -144,39 +143,41 @@ class YAPShell:
|
||||
# if not isinstance(eq[0],str):
|
||||
# print( "Error: Variable Name matches a Python Symbol")
|
||||
# return
|
||||
self.do_ask = True
|
||||
engine = self.engine
|
||||
bindings = []
|
||||
g = python_query(self, query)
|
||||
if not self.q:
|
||||
try:
|
||||
engine = self.engine
|
||||
bindings = []
|
||||
loop = False
|
||||
g = python_query(self, query)
|
||||
self.q = Query( engine, g )
|
||||
for bind in self.q:
|
||||
bindings += [bind]
|
||||
if self.do_ask:
|
||||
print(bindings)
|
||||
bindings = []
|
||||
for bind in self.q:
|
||||
bindings += [bind]
|
||||
if loop:
|
||||
continue
|
||||
if not self.q.port == "exit":
|
||||
break
|
||||
s = input("more(;), all(*), no(\\n), python(#) ?").lstrip()
|
||||
else:
|
||||
s = ";"
|
||||
if s.startswith(';') or s.startswith('y'):
|
||||
continue
|
||||
elif s.startswith('#'):
|
||||
try:
|
||||
exec(s.lstrip('#'))
|
||||
except:
|
||||
raise
|
||||
elif s.startswith('*') or s.startswith('a'):
|
||||
self.do_ask = False
|
||||
continue
|
||||
else:
|
||||
break
|
||||
if self.q:
|
||||
self.os = query
|
||||
if bindings:
|
||||
return True,bindings
|
||||
print("No (more) answers")
|
||||
return False, None
|
||||
|
||||
if s.startswith(';') or s.startswith('y'):
|
||||
continue
|
||||
elif s.startswith('#'):
|
||||
try:
|
||||
exec(s.lstrip('#'))
|
||||
except:
|
||||
raise
|
||||
elif s.startswith('*') or s.startswith('a'):
|
||||
loop = True
|
||||
continue
|
||||
else:
|
||||
break
|
||||
if self.q:
|
||||
self.os = query
|
||||
if bindings:
|
||||
return True,bindings
|
||||
print("No (more) answers")
|
||||
return False, None
|
||||
except Exception as e:
|
||||
print("Exception")
|
||||
print(dir(e))
|
||||
return False, None
|
||||
|
||||
def live(self, engine, **kwargs):
|
||||
loop = True
|
||||
|
Reference in New Issue
Block a user