mumuki-python-runner 1.7.0 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '039cd7e8daf34032853b80ad08223b1af629432395e1036d0c141bcd2a81cb4c'
4
- data.tar.gz: eb45b266b689d2d13a18d54a1815a6d2f1b5d255c0dea700f67a17b5a34a5b40
3
+ metadata.gz: 1699ae67a23fd927d959d11b67c4dd207a4fec5154b177f30a90289a9ef21df3
4
+ data.tar.gz: 43de189d35459491ba444eccfe14f259802e4ac2bfd9fbd9f80d223fc62bc7d7
5
5
  SHA512:
6
- metadata.gz: a154c8202c04203bfd5a577d2a70d407ebfd98f24a3050fc524f97bbcb60c724f6944fd613911869160418590a80acf9abdf0aef3dd5b3a7e41904e752cb41f7
7
- data.tar.gz: b609e0a9fa6624bb99e1e3b5a2db1ed63d5c131af554feee56e488eb6da67fcfb41abe607a8d2ada3ef0dbd38cfd583be8503388bcb1c658408cf64281b26dbc
6
+ metadata.gz: 9d228f450cac70734257c24dea6a0c47865dd0df166a4ea823d01494b75c592410852fcf7ac0c6fa355b778cc4fafcdcfa3fe9d6589e1568ee4cf0ff54e727f1
7
+ data.tar.gz: e4c330e7545fa34c3d2cd5ffabef570cc9acf9af4b075c5be58fc071dacb94aac578488fe872ee348203618e971c535f1852f9a9686ed1eb8f6c0bfc4ba29e83
@@ -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 *(\(| ).*|^[a-zA-Z_]\w*\s*=[^=].*|^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.0'
3
+ VERSION = '1.8.2'
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
@@ -1,6 +1,5 @@
1
1
  class Python3TryHook < Mumukit::Templates::TryHook
2
2
  isolated true
3
- attr_reader :query_hook
4
3
 
5
4
  def initialize(config = nil)
6
5
  super config
@@ -9,16 +8,20 @@ class Python3TryHook < Mumukit::Templates::TryHook
9
8
 
10
9
  def compile_file_content(r)
11
10
  <<python
12
- #{query_hook.compile_file_header(r)}
11
+ #{@query_hook.compile_file_header(r)}
13
12
  print("#{query_separator}");
14
- #{query_hook.compile_query(r.query, '')}
13
+ #{@query_hook.compile_query(r.query, '')}
15
14
  print("#{goal_separator}");
16
- #{query_hook.compile_query(r.goal.indifferent_get(:query) || 'None', '')}
15
+ #{@query_hook.compile_query(r.goal.indifferent_get(:query) || 'None', '')}
17
16
  python
18
17
  end
19
18
 
20
- delegate :tempfile_extension, to: :query_hook
21
- delegate :command_line, to: :query_hook
19
+ delegate :tempfile_extension, to: :@query_hook
20
+ delegate :command_line, to: :@query_hook
21
+
22
+ def post_process_file(file, result, status)
23
+ super file, *@query_hook.post_process_file(file, result, status)
24
+ end
22
25
 
23
26
  def query_separator
24
27
  '!!!MUMUKI-QUERY-START!!!'
@@ -29,15 +32,14 @@ python
29
32
  end
30
33
 
31
34
  def to_structured_results(_file, result, status)
32
- /#{query_separator}
33
- ?(.*)
34
- #{goal_separator}
35
- ?(.*)
36
- /m =~ result
35
+ result_match = result[/#{query_separator}
36
+ \K.*?(?=(#{goal_separator})|\z)/m]&.rstrip
37
+ goal_match = result[/#{goal_separator}
38
+ \K.*\z/m]&.rstrip
37
39
 
38
40
  {
39
- query: to_query_result($1, status),
40
- goal: $2,
41
+ query: to_query_result(result_match, status),
42
+ goal: goal_match,
41
43
  status: status
42
44
  }
43
45
  end
@@ -45,4 +47,9 @@ python
45
47
  def to_query_result(result, status)
46
48
  { result: result, status: status }
47
49
  end
50
+
51
+ def checker_options
52
+ { strip_mode: :right_only }
53
+ end
54
+
48
55
  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.0
4
+ version: 1.8.2
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: 2020-09-12 00:00:00.000000000 Z
11
+ date: 2022-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit
@@ -16,42 +16,48 @@ 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: mulang
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '6.0'
31
34
  - - ">="
32
35
  - !ruby/object:Gem::Version
33
- version: '4.5'
36
+ version: 6.0.8
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '6.0'
38
44
  - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: '4.5'
46
+ version: 6.0.8
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '1.7'
53
+ version: '2.0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '1.7'
60
+ version: '2.0'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rake
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -170,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
176
  - !ruby/object:Gem::Version
171
177
  version: '0'
172
178
  requirements: []
173
- rubygems_version: 3.0.8
179
+ rubygems_version: 3.0.3
174
180
  signing_key:
175
181
  specification_version: 4
176
182
  summary: Python Runner for Mumuki