forked from hhu-stups/prolog-jupyter-kernel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogtalk_kernel_config.py
227 lines (219 loc) · 8.92 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
#############################################################################
#
# Copyright (c) 2022-2025 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.
#
#############################################################################
"""Logtalk Jupyter Kernel Configuration.
This module contains default configuration settings for the Logtalk Jupyter
kernel, including backend-specific settings and logging options.
"""
import platform
import os
# Constants
DEFAULT_ERROR_PREFIX = "! "
DEFAULT_INFORMATIONAL_PREFIX = "% "
DEFAULT_PROGRAM_ARGS = "default"
c = get_config()
# If set to True, the logging level is set to DEBUG by the kernel so that Python debugging messages are logged.
c.LogtalkKernel.jupyter_logging = False
# If set to True, a log file is created by the Logtalk server
c.LogtalkKernel.server_logging = False
# The Prolog backend integration script with which the server is started.
if platform.system() == "Windows":
EXTENSION = ".ps1"
elif (
"LOGTALKHOME" in os.environ
and "LOGTALKUSER" in os.environ
and os.environ["LOGTALKHOME"] == os.environ["LOGTALKUSER"]
):
EXTENSION = ".sh"
else:
EXTENSION = ""
# c.LogtalkKernel.backend = "eclipselgt" + EXTENSION
# c.LogtalkKernel.backend = "gplgt" + EXTENSION
# c.LogtalkKernel.backend = "sicstuslgt" + EXTENSION
c.LogtalkKernel.backend = "swilgt" + EXTENSION
# c.LogtalkKernel.backend = "tplgt" + EXTENSION
# c.LogtalkKernel.backend = "xvmlgt" + EXTENSION
# c.LogtalkKernel.backend = "yaplgt" + EXTENSION
# 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.
c.LogtalkKernel.backend_data = {
"eclipselgt": {
"failure_response": "No",
"success_response": "Yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"eclipselgt.sh": {
"failure_response": "No",
"success_response": "Yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"eclipselgt.ps1": {
"failure_response": "No",
"success_response": "Yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"gplgt": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"gplgt.sh": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"gplgt.ps1": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"sicstuslgt": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"sicstuslgt.sh": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"sicstuslgt.ps1": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"swilgt": {
"failure_response": "false",
"success_response": "true",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"swilgt.sh": {
"failure_response": "false",
"success_response": "true",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"swilgt.ps1": {
"failure_response": "false",
"success_response": "true",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"tplgt": {
"failure_response": "false",
"success_response": "true",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"tplgt.sh": {
"failure_response": "false",
"success_response": "true",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"tplgt.ps1": {
"failure_response": "false",
"success_response": "true",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"xvmlgt": {
"failure_response": "false",
"success_response": "true",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"xvmlgt.sh": {
"failure_response": "false",
"success_response": "true",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"xvmlgt.ps1": {
"failure_response": "false",
"success_response": "true",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"yaplgt": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"yaplgt.sh": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
"yaplgt.ps1": {
"failure_response": "no",
"success_response": "yes",
"error_prefix": DEFAULT_ERROR_PREFIX,
"informational_prefix": DEFAULT_INFORMATIONAL_PREFIX,
"program_arguments": DEFAULT_PROGRAM_ARGS,
},
}