mumuki-python-runner 1.7.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/base/query_hook.rb +6 -33
- data/lib/base/version.rb +1 -1
- data/lib/python2/query_hook.rb +19 -0
- data/lib/python3/query_hook.rb +22 -0
- data/lib/python3/try_hook.rb +5 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4a1cf971f4ce948e0e251e05f92672ca1c01e2b7f4441b60f57634c8cd89c68
|
4
|
+
data.tar.gz: 6bf96e4e38f596547ed4258c8447e8f6be826a8afedb75989fef278ea70a1664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6340927de462b077cda6f61ea5dfb8b3bdc7ff1419abd8d59f623c33cac2f7c40eba7770a92b5a20c560b2e1e7b98d1343f668f93d9e6441e7c4d63c2b5669d
|
7
|
+
data.tar.gz: e5858f8ff89f2a13e1a1f65e265f4467a1e4017ed2c42bbbd92986e22436d54c46994c79e684384e1288a44ec3bb3dc492aaf305ab65adad08fc8223ceb5284b
|
data/lib/base/query_hook.rb
CHANGED
@@ -23,33 +23,13 @@ sys.stdout = sys.__stdout__
|
|
23
23
|
python
|
24
24
|
end
|
25
25
|
|
26
|
-
def compile_query(query, output_prefix = "=> ")
|
27
|
-
if query.match /print *(\(| ).*|.*[^=]=[^=].*|^raise\b/
|
28
|
-
query
|
29
|
-
else
|
30
|
-
<<~python
|
31
|
-
__mumuki_error__ = None
|
32
|
-
try:
|
33
|
-
__mumuki_args__ = {'mumuki_query_result': eval("""#{query.gsub('"', '\"')}""")}
|
34
|
-
print(string.Template(\"#{output_prefix}\${mumuki_query_result}\").safe_substitute(**__mumuki_args__))
|
35
|
-
except SyntaxError as e:
|
36
|
-
__mumuki_error__ = SyntaxError(e.msg, ('<console>', e.lineno, e.offset, e.text))
|
37
|
-
if __mumuki_error__:
|
38
|
-
print(__mumuki_error__.text)
|
39
|
-
print(" "*(__mumuki_error__.offset - 1) + "^")
|
40
|
-
print('SyntheticMumukiSyntaxError: SyntaxError: ' + str(__mumuki_error__))
|
41
|
-
exit(1)
|
42
|
-
python
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
26
|
def compile_state(cookie)
|
47
27
|
(cookie||[]).map do |statement|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
28
|
+
<<~python
|
29
|
+
try:
|
30
|
+
#{statement}
|
31
|
+
except:
|
32
|
+
pass
|
53
33
|
python
|
54
34
|
end
|
55
35
|
end
|
@@ -65,13 +45,6 @@ python
|
|
65
45
|
end
|
66
46
|
|
67
47
|
def syntax_error_regexp
|
68
|
-
/(SyntheticMumukiSyntaxError: )|(\A File .*\n(?m)(?=.*(SyntaxError|IndentationError)))/
|
48
|
+
/(SyntheticMumukiSyntaxError: )|((\A File .*\n)?(?m)(?=.*(SyntaxError|IndentationError)))/
|
69
49
|
end
|
70
50
|
end
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
data/lib/base/version.rb
CHANGED
data/lib/python2/query_hook.rb
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
class Python2QueryHook < BasePythonQueryHook
|
2
|
+
def compile_query(query, output_prefix = "=> ")
|
3
|
+
if query.match /print *(\(| ).*|.*[^=><!]=[^=].*|^raise\b/
|
4
|
+
query
|
5
|
+
else
|
6
|
+
<<~python
|
7
|
+
__mumuki_error__ = None
|
8
|
+
try:
|
9
|
+
__mumuki_args__ = {'mumuki_query_result': eval("""#{query.gsub('"', '\"')}""")}
|
10
|
+
print(string.Template(\"\${mumuki_query_result}\").safe_substitute(**__mumuki_args__))
|
11
|
+
except SyntaxError as e:
|
12
|
+
__mumuki_error__ = SyntaxError(e.msg, ('<console>', e.lineno, e.offset, e.text))
|
13
|
+
if __mumuki_error__:
|
14
|
+
print(__mumuki_error__.text)
|
15
|
+
print(" "*(__mumuki_error__.offset - 1) + "^")
|
16
|
+
print('SyntheticMumukiSyntaxError: SyntaxError: ' + str(__mumuki_error__))
|
17
|
+
exit(1)
|
18
|
+
python
|
19
|
+
end
|
20
|
+
end
|
2
21
|
end
|
3
22
|
|
4
23
|
PythonQueryHook = Python2QueryHook
|
data/lib/python3/query_hook.rb
CHANGED
@@ -1,2 +1,24 @@
|
|
1
1
|
class Python3QueryHook < BasePythonQueryHook
|
2
|
+
def compile_query(query, output_prefix = "=> ")
|
3
|
+
<<~python
|
4
|
+
import code
|
5
|
+
import itertools
|
6
|
+
import traceback
|
7
|
+
import sys
|
8
|
+
|
9
|
+
__mumuki_console__ = code.InteractiveConsole()
|
10
|
+
|
11
|
+
try:
|
12
|
+
__mumuki_result__ = __mumuki_console__.compile("""#{query.gsub('"', '\"')}""")
|
13
|
+
if __mumuki_result__ != None:
|
14
|
+
exec(__mumuki_result__)
|
15
|
+
else:
|
16
|
+
raise SyntaxError('unexpected EOF while parsing')
|
17
|
+
except:
|
18
|
+
error = sys.exc_info()
|
19
|
+
stack = traceback.format_exception(*error)
|
20
|
+
print(*itertools.dropwhile(lambda it: 'File "<input>"' not in it and not it.startswith("SyntaxError"), stack))
|
21
|
+
exit(1)
|
22
|
+
python
|
23
|
+
end
|
2
24
|
end
|
data/lib/python3/try_hook.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumuki-python-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franco Leonardo Bulgarelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mumukit
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.41'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.41'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|