mumuki-python-runner 1.7.1 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7ac08925c7c447effe33a7cdadc6d8135d2a3d412586c546550630afe76e5db
4
- data.tar.gz: 8b64922903b757f02e1df5714ee78c7dad8dfa5556d32a351396aab73e03c044
3
+ metadata.gz: f4a1cf971f4ce948e0e251e05f92672ca1c01e2b7f4441b60f57634c8cd89c68
4
+ data.tar.gz: 6bf96e4e38f596547ed4258c8447e8f6be826a8afedb75989fef278ea70a1664
5
5
  SHA512:
6
- metadata.gz: cb86a2680d68c97a33028bf367b07918b8b64b41e85b8a588819bffe69afa621e033fcd2501ffe5fa0651c15de01e4851e31cc9e3d4084df80f820977f1dc6c1
7
- data.tar.gz: c189e9eb01ea000eac2a8f24f8c4bd4b68e57cf4701f49e4984bd3b9be8f17eef47e4108be03ebd5124aa655138038adeb8c5442ca75f472d8a95b2dd12502c6
6
+ metadata.gz: f6340927de462b077cda6f61ea5dfb8b3bdc7ff1419abd8d59f623c33cac2f7c40eba7770a92b5a20c560b2e1e7b98d1343f668f93d9e6441e7c4d63c2b5669d
7
+ data.tar.gz: e5858f8ff89f2a13e1a1f65e265f4467a1e4017ed2c42bbbd92986e22436d54c46994c79e684384e1288a44ec3bb3dc492aaf305ab65adad08fc8223ceb5284b
@@ -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
- <<~python
49
- try:
50
- #{statement}
51
- except:
52
- pass
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
@@ -1,4 +1,4 @@
1
1
 
2
2
  module BasePythonVersionHook
3
- VERSION = '1.7.1'
3
+ VERSION = '1.8.0'
4
4
  end
@@ -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
@@ -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
@@ -45,4 +45,9 @@ python
45
45
  def to_query_result(result, status)
46
46
  { result: result, status: status }
47
47
  end
48
+
49
+ def checker_options
50
+ { strip_mode: :right_only }
51
+ end
52
+
48
53
  end
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.7.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-01-19 00:00:00.000000000 Z
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.30'
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.30'
26
+ version: '2.41'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement