forked from hhu-stups/prolog-jupyter-kernel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
logtalk_kernel_config.py
229 lines (222 loc) · 8.03 KB
/
logtalk_kernel_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#############################################################################
#
# Copyright (c) 2022-2024 Paulo Moura
# Copyright (c) 2022 Anne Brecklinghaus, Michael Leuschel, dgelessus
# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#############################################################################
import platform
import os
c = get_config()
## If set to True, the logging level is set to DEBUG by the kernel so that Python debugging messages are logged.
# Default:
# c.LogtalkKernel.jupyter_logging = False
## If set to True, a log file is created by the Logtalk server
# Default:
# c.LogtalkKernel.server_logging = False
## The Prolog backend integration script with which the server is started.
# Default:
if platform.system() == 'Windows':
#c.LogtalkKernel.backend = "eclipselgt.ps1"
#c.LogtalkKernel.backend = "gplgt.ps1"
#c.LogtalkKernel.backend = "sicstuslgt.ps1"
c.LogtalkKernel.backend = "swilgt.ps1"
#c.LogtalkKernel.backend = "tplgt.ps1"
#c.LogtalkKernel.backend = "xvmlgt.ps1"
#c.LogtalkKernel.backend = "yaplgt.ps1"
elif 'LOGTALKHOME' in os.environ and 'LOGTALKUSER' in os.environ and os.environ['LOGTALKHOME'] == os.environ['LOGTALKUSER']:
#c.LogtalkKernel.backend = "eclipselgt.sh"
#c.LogtalkKernel.backend = "gplgt.sh"
#c.LogtalkKernel.backend = "sicstuslgt.sh"
c.LogtalkKernel.backend = "swilgt.sh"
#c.LogtalkKernel.backend = "tplgt.sh"
#c.LogtalkKernel.backend = "xvmlgt.sh"
#c.LogtalkKernel.backend = "yaplgt.sh"
else:
#c.LogtalkKernel.backend = "eclipselgt"
#c.LogtalkKernel.backend = "gplgt"
#c.LogtalkKernel.backend = "sicstuslgt"
c.LogtalkKernel.backend = "swilgt"
#c.LogtalkKernel.backend = "tplgt"
#c.LogtalkKernel.backend = "xvmlgt"
#c.LogtalkKernel.backend = "yaplgt"
## The implementation specific data which is needed to run the Logtalk server for code execution.
## This is required to be a dictionary containing at least an entry for the configured backend.
## Each entry needs to define values for
## - "failure_response": The output which is displayed if a query fails
## - "success_response": The output which is displayed if a query succeeds without any variable bindings
## - "error_prefix": The prefix output for error messages
## - "informational_prefix": The prefix output for informational messages
## - "program_arguments": The command line arguments (a list of strings) with which the Logtalk server can be started
## For all backends, the default Logtalk server can be used by configuring the string "default"
## Additionally, a "kernel_backend_path" can be provided, which needs to be an absolute path to a Python file.
## The corresponding module is required to define a subclass of LogtalkKernelBaseImplementation named LogtalkKernelImplementation.
## This can be used to override some of the kernel's basic behavior.
# Default:
c.LogtalkKernel.backend_data = {
"eclipselgt": {
"failure_response": "No",
"success_response": "Yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"eclipselgt.sh": {
"failure_response": "No",
"success_response": "Yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"eclipselgt.ps1": {
"failure_response": "No",
"success_response": "Yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"gplgt": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"gplgt.sh": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"gplgt.ps1": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"sicstuslgt": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"sicstuslgt.sh": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"sicstuslgt.ps1": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"swilgt": {
"failure_response": "false",
"success_response": "true",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"swilgt.sh": {
"failure_response": "false",
"success_response": "true",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"swilgt.ps1": {
"failure_response": "false",
"success_response": "true",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"tplgt": {
"failure_response": "false",
"success_response": "true",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"tplgt.sh": {
"failure_response": "false",
"success_response": "true",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"tplgt.ps1": {
"failure_response": "false",
"success_response": "true",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"xvmlgt": {
"failure_response": "false",
"success_response": "true",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"xvmlgt.sh": {
"failure_response": "false",
"success_response": "true",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"xvmlgt.ps1": {
"failure_response": "false",
"success_response": "true",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"yaplgt": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"yaplgt.sh": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
},
"yaplgt.ps1": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": "! ",
"informational_prefix": "% ",
"program_arguments": "default"
}
}