mumuki-python-runner 1.6.0 → 1.8.1

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: dcb623be34bb249818161740a8eeb299fb3d8db1c0513c76769a5379f3c959e6
4
- data.tar.gz: ec5e53117030aa1228715ae86a43f9670b0878aa0c1db16f7a49f9b3d2689a4c
3
+ metadata.gz: 89a420abcb59de7ed38a51511b8fb5ec96c3649c89e2ae59f703927204934871
4
+ data.tar.gz: 2d08a9831ed7b49972fcf1d863a9b0ec0284cc200fd104a5c79cf1f006db8e8a
5
5
  SHA512:
6
- metadata.gz: 6e4610071f25ff2e3d50825c745fad561247375c63e8edcbde1ece7cbc9665f82583612fa01a264bc79226c5fc37e55713af7e38e577bba40ba9ddb3213aaf51
7
- data.tar.gz: c82f05190f3a999bdbbf0bcc1b531398b649912b1f3db61835a9e9ee0fa6cceee5741514e225b0a04ca92833bf0edfc9d18530be4a70bc72294965ab0badea18
6
+ metadata.gz: b0a1dab1ce1ebfd01db007ee8b0b56bff51b2217679a1018901d396ec05c544edb8cf9a4e508da02cc226590b78e926e61b9e2cb664a1540ce3e9da553818750
7
+ data.tar.gz: 6d85cdf41b0c5fb71395ec128b657f2b5923b9cf50618f8a4e6d034c21c604a68a9e63c4f3c065b80134385042922283ad77e2b4bd5612bedc8351e74bdf88f6
@@ -23,21 +23,13 @@ sys.stdout = sys.__stdout__
23
23
  python
24
24
  end
25
25
 
26
- def compile_query(query, output_prefix = "=> ", output_var = "__mumuki_query_result__")
27
- if query.match /print *(\(| ).*|^[a-zA-Z_]\w*\s*=.*|^raise\b/
28
- query
29
- else
30
- "print(string.Template(\"#{output_prefix}$#{output_var}\").substitute(#{output_var} = #{query}))"
31
- end
32
- end
33
-
34
26
  def compile_state(cookie)
35
27
  (cookie||[]).map do |statement|
36
- <<~python
37
- try:
38
- #{statement}
39
- except:
40
- pass
28
+ <<~python
29
+ try:
30
+ #{statement}
31
+ except:
32
+ pass
41
33
  python
42
34
  end
43
35
  end
@@ -53,13 +45,6 @@ python
53
45
  end
54
46
 
55
47
  def syntax_error_regexp
56
- /\A File .*\n(?m)(?=.*(SyntaxError|IndentationError))/
48
+ /(SyntheticMumukiSyntaxError: )|((\A File .*\n)?(?m)(?=.*(SyntaxError|IndentationError)))/
57
49
  end
58
50
  end
59
-
60
-
61
-
62
-
63
-
64
-
65
-
data/lib/base/version.rb CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  module BasePythonVersionHook
2
- VERSION = '1.6.0'
3
+ VERSION = '1.8.1'
3
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', '', '__mumuki_goal_query_result__')}
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.6.0
4
+ version: 1.8.1
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-05-08 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit
@@ -16,56 +16,42 @@ 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'
27
- - !ruby/object:Gem::Dependency
28
- name: mulang
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '4.5'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '4.5'
26
+ version: '2.41'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '1.7'
33
+ version: '2.0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '1.7'
40
+ version: '2.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '10.0'
47
+ version: '12.3'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '10.0'
54
+ version: '12.3'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rspec
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -170,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
156
  - !ruby/object:Gem::Version
171
157
  version: '0'
172
158
  requirements: []
173
- rubyforge_project:
174
- rubygems_version: 2.7.7
159
+ rubygems_version: 3.0.3
175
160
  signing_key:
176
161
  specification_version: 4
177
162
  summary: Python Runner for Mumuki