robotframework-debug 3.9.0__tar.gz → 3.10.0__tar.gz
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.
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/PKG-INFO +1 -1
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/cmdcompleter.py +64 -5
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/debugcmd.py +3 -7
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/lexer.py +44 -37
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/prompttoolkitcmd.py +48 -21
- robotframework-debug-3.10.0/RobotDebug/version.py +1 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/robotframework_debug.egg-info/PKG-INFO +1 -1
- robotframework-debug-3.9.0/RobotDebug/version.py +0 -1
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/.coveragerc +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/.gitpod.yml +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/ChangeLog +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/CreateWheel.sh +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/LICENSE +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/MANIFEST.in +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/README.rst +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/__init__.py +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/globals.py +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/keywords.py +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/robotkeyword.py +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/robotlib.py +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/shell.py +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/sourcelines.py +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/steplistener.py +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/RobotDebug/styles.py +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/_config.yml +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/robotframework_debug.egg-info/SOURCES.txt +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/robotframework_debug.egg-info/dependency_links.txt +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/robotframework_debug.egg-info/entry_points.txt +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/robotframework_debug.egg-info/not-zip-safe +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/robotframework_debug.egg-info/requires.txt +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/robotframework_debug.egg-info/top_level.txt +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/setup.cfg +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/setup.py +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/tests/__init__.py +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/tests/step.robot +0 -0
- {robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/tests/test_debuglibrary.py +0 -0
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
import re
|
|
2
2
|
|
|
3
3
|
from prompt_toolkit.completion import Completer, Completion
|
|
4
|
+
from robot.libraries.BuiltIn import BuiltIn
|
|
5
|
+
from robot.parsing.parser.parser import _tokens_to_statements
|
|
4
6
|
|
|
7
|
+
from .lexer import get_robot_token, get_variable_token
|
|
8
|
+
from .prompttoolkitcmd import set_toolbar_key
|
|
5
9
|
from .robotkeyword import normalize_kw, parse_keyword
|
|
6
10
|
from .styles import _get_style_completions
|
|
7
11
|
|
|
8
12
|
|
|
13
|
+
def find_token_at_cursor(cursor_col, cursor_row, statement):
|
|
14
|
+
statement_type = None
|
|
15
|
+
for token in statement.tokens:
|
|
16
|
+
if token.type in ["KEYWORD", "IF", "FOR", "ELSE", "ELSE IF"]:
|
|
17
|
+
statement_type = token.type
|
|
18
|
+
if (
|
|
19
|
+
token.lineno == cursor_row + 1
|
|
20
|
+
and token.col_offset <= cursor_col <= token.end_col_offset
|
|
21
|
+
):
|
|
22
|
+
return statement_type, token, cursor_col - token.col_offset
|
|
23
|
+
return None, None, None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def find_statement_details_at_cursor(cursor_col, cursor_row, statements):
|
|
27
|
+
for statement in statements:
|
|
28
|
+
if not statement:
|
|
29
|
+
continue
|
|
30
|
+
if (
|
|
31
|
+
statement.lineno <= cursor_row + 1 <= statement.end_lineno
|
|
32
|
+
and statement.col_offset <= cursor_col <= statement.end_col_offset
|
|
33
|
+
):
|
|
34
|
+
statement_type, token, cursor_pos = find_token_at_cursor(
|
|
35
|
+
cursor_col, cursor_row, statement
|
|
36
|
+
)
|
|
37
|
+
if token:
|
|
38
|
+
return statement, statement_type, token, cursor_pos
|
|
39
|
+
return None, None, None, None
|
|
40
|
+
|
|
41
|
+
|
|
9
42
|
class CmdCompleter(Completer):
|
|
10
43
|
"""Completer for debug shell."""
|
|
11
44
|
|
|
@@ -59,7 +92,15 @@ class CmdCompleter(Completer):
|
|
|
59
92
|
"""Compute suggestions."""
|
|
60
93
|
# RobotFrameworkLocalLexer().parse_doc(document)
|
|
61
94
|
text = document.current_line_before_cursor
|
|
62
|
-
|
|
95
|
+
cursor_col = document.cursor_position_col
|
|
96
|
+
cursor_row = document.cursor_position_row
|
|
97
|
+
token_list = list(get_robot_token(document.text))
|
|
98
|
+
statements = list(_tokens_to_statements(token_list))
|
|
99
|
+
statement, statement_type, token, cursor_pos = find_statement_details_at_cursor(
|
|
100
|
+
cursor_col, cursor_row, statements
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
# variables, keyword, args = parse_keyword(text.strip())
|
|
63
104
|
if "FOR".startswith(text):
|
|
64
105
|
yield from [
|
|
65
106
|
Completion(
|
|
@@ -101,7 +142,25 @@ class CmdCompleter(Completer):
|
|
|
101
142
|
yield from _get_style_completions(text.lower())
|
|
102
143
|
elif text.startswith("*"):
|
|
103
144
|
yield from self._get_resource_completions(text.lower())
|
|
104
|
-
elif
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
145
|
+
elif token:
|
|
146
|
+
vars = list(get_variable_token([token]))
|
|
147
|
+
for var in vars:
|
|
148
|
+
if var.col_offset <= cursor_col <= var.end_col_offset:
|
|
149
|
+
token = var
|
|
150
|
+
cursor_pos = cursor_col - var.col_offset
|
|
151
|
+
set_toolbar_key(statement_type, token, cursor_pos)
|
|
152
|
+
if token.type in ["ASSIGN", "VARIABLE"] or (
|
|
153
|
+
token.type == "KEYWORD" and re.fullmatch(r"[$&@]\{.[^}]}", token.value)
|
|
154
|
+
):
|
|
155
|
+
yield from [
|
|
156
|
+
Completion(
|
|
157
|
+
f"{var[:-1]}",
|
|
158
|
+
-cursor_pos,
|
|
159
|
+
display=var,
|
|
160
|
+
display_meta=repr(val),
|
|
161
|
+
)
|
|
162
|
+
for var, val in BuiltIn().get_variables().items()
|
|
163
|
+
if normalize_kw(var[1:]).startswith(normalize_kw(token.value[1:cursor_pos]))
|
|
164
|
+
]
|
|
165
|
+
elif token.type == "KEYWORD":
|
|
166
|
+
yield from self._get_command_completions(token.value.lower())
|
|
@@ -109,20 +109,16 @@ Access https://github.com/imbus/robotframework-debug for more details.\
|
|
|
109
109
|
|
|
110
110
|
keywords: List[KeywordDoc] = get_keywords()
|
|
111
111
|
for keyword in keywords:
|
|
112
|
-
name = "{
|
|
112
|
+
name = f"{keyword.parent.name}.{keyword.name}"
|
|
113
113
|
commands.append(
|
|
114
114
|
(
|
|
115
115
|
name,
|
|
116
116
|
keyword.name,
|
|
117
|
-
|
|
117
|
+
keyword.shortdoc,
|
|
118
118
|
)
|
|
119
119
|
)
|
|
120
120
|
commands.append(
|
|
121
|
-
(
|
|
122
|
-
keyword.name,
|
|
123
|
-
keyword.name,
|
|
124
|
-
"Keyword[{0}.]: {1}".format(keyword.parent.name, keyword.shortdoc),
|
|
125
|
-
)
|
|
121
|
+
(keyword.name, keyword.name, f"{keyword.shortdoc} [{keyword.parent.name}]")
|
|
126
122
|
)
|
|
127
123
|
|
|
128
124
|
return CmdCompleter(commands, self)
|
|
@@ -3,7 +3,46 @@ from contextlib import suppress
|
|
|
3
3
|
|
|
4
4
|
from pygments.lexer import Lexer
|
|
5
5
|
from pygments.token import Token
|
|
6
|
-
from robot.parsing import get_tokens
|
|
6
|
+
from robot.parsing import get_model, get_tokens
|
|
7
|
+
from robot.parsing.parser.parser import _tokens_to_statements
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_robot_token(text):
|
|
11
|
+
if text.strip().startswith("**"):
|
|
12
|
+
yield from get_tokens(text)
|
|
13
|
+
else:
|
|
14
|
+
marker_len = 20
|
|
15
|
+
new_line_start = " " * marker_len
|
|
16
|
+
if "\n" in text:
|
|
17
|
+
text = f"\n{new_line_start}".join(text.split("\n"))
|
|
18
|
+
suite_str = f"*** Test Cases ***\nFake Test\n{new_line_start}{text}"
|
|
19
|
+
for token in list(get_tokens(suite_str))[6:]:
|
|
20
|
+
if (
|
|
21
|
+
token.type in ["SEPARATOR", "EOL"]
|
|
22
|
+
and token.col_offset == 0
|
|
23
|
+
and token.end_col_offset >= marker_len
|
|
24
|
+
):
|
|
25
|
+
if token.end_col_offset == marker_len:
|
|
26
|
+
continue
|
|
27
|
+
token.value = token.value[marker_len:]
|
|
28
|
+
token.col_offset = 0
|
|
29
|
+
token.lineno = token.lineno - 2
|
|
30
|
+
else:
|
|
31
|
+
token.col_offset = token.col_offset - marker_len
|
|
32
|
+
token.lineno = token.lineno - 2
|
|
33
|
+
yield token
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def get_variable_token(token_list):
|
|
37
|
+
for token in token_list:
|
|
38
|
+
if len(token.value) == 0:
|
|
39
|
+
continue
|
|
40
|
+
try:
|
|
41
|
+
var_tokens = token.tokenize_variables()
|
|
42
|
+
except Exception:
|
|
43
|
+
var_tokens = [token]
|
|
44
|
+
for v_token in var_tokens:
|
|
45
|
+
yield v_token
|
|
7
46
|
|
|
8
47
|
|
|
9
48
|
class RobotFrameworkLocalLexer(Lexer):
|
|
@@ -199,44 +238,12 @@ class RobotFrameworkLocalLexer(Lexer):
|
|
|
199
238
|
# break
|
|
200
239
|
# return statement_at_cursor, token_at_cursor
|
|
201
240
|
|
|
202
|
-
def get_robot_token(self, text):
|
|
203
|
-
if text.strip().startswith("**"):
|
|
204
|
-
yield from get_tokens(text)
|
|
205
|
-
else:
|
|
206
|
-
marker_len = 20
|
|
207
|
-
new_line_start = " " * marker_len
|
|
208
|
-
if "\n" in text:
|
|
209
|
-
text = f"\n{new_line_start}".join(text.split("\n"))
|
|
210
|
-
suite_str = f"*** Test Cases ***\nFake Test\n{new_line_start}{text}"
|
|
211
|
-
for token in list(get_tokens(suite_str))[6:]:
|
|
212
|
-
if (
|
|
213
|
-
token.type in ["SEPARATOR", "EOL"]
|
|
214
|
-
and token.col_offset == 0
|
|
215
|
-
and token.end_col_offset >= marker_len
|
|
216
|
-
):
|
|
217
|
-
if token.end_col_offset == marker_len:
|
|
218
|
-
continue
|
|
219
|
-
token.value = token.value[marker_len:]
|
|
220
|
-
token.col_offset = 0
|
|
221
|
-
token.lineno = token.lineno - 2
|
|
222
|
-
else:
|
|
223
|
-
token.col_offset = token.col_offset - marker_len
|
|
224
|
-
token.lineno = token.lineno - 2
|
|
225
|
-
yield token
|
|
226
|
-
|
|
227
241
|
def get_tokens_unprocessed(self, text):
|
|
228
|
-
token_list =
|
|
242
|
+
token_list = get_robot_token(text)
|
|
229
243
|
index = 0
|
|
230
|
-
for
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
try:
|
|
234
|
-
var_tokens = token.tokenize_variables()
|
|
235
|
-
except Exception:
|
|
236
|
-
var_tokens = [token]
|
|
237
|
-
for v_token in var_tokens:
|
|
238
|
-
yield index, self.to_pygments_token_type(v_token), v_token.value
|
|
239
|
-
index += len(v_token.value)
|
|
244
|
+
for v_token in get_variable_token(token_list):
|
|
245
|
+
yield index, self.to_pygments_token_type(v_token), v_token.value
|
|
246
|
+
index += len(v_token.value)
|
|
240
247
|
|
|
241
248
|
def to_pygments_token_type(self, token):
|
|
242
249
|
if token.type == "VARIABLE":
|
|
@@ -2,26 +2,17 @@ import cmd
|
|
|
2
2
|
import os
|
|
3
3
|
import re
|
|
4
4
|
|
|
5
|
-
from prompt_toolkit import HTML
|
|
6
5
|
from prompt_toolkit.application import get_app
|
|
7
6
|
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
|
|
8
7
|
from prompt_toolkit.buffer import Buffer
|
|
9
8
|
from prompt_toolkit.clipboard.pyperclip import PyperclipClipboard
|
|
10
9
|
from prompt_toolkit.cursor_shapes import CursorShape
|
|
11
|
-
from prompt_toolkit.filters import
|
|
12
|
-
Condition,
|
|
13
|
-
has_completions,
|
|
14
|
-
has_selection,
|
|
15
|
-
in_paste_mode,
|
|
16
|
-
is_multiline,
|
|
17
|
-
)
|
|
10
|
+
from prompt_toolkit.filters import Condition, has_completions, has_selection
|
|
18
11
|
from prompt_toolkit.history import FileHistory
|
|
19
12
|
from prompt_toolkit.key_binding import KeyBindings
|
|
20
13
|
from prompt_toolkit.lexers import PygmentsLexer
|
|
21
14
|
from prompt_toolkit.output import ColorDepth
|
|
22
15
|
from prompt_toolkit.shortcuts import CompleteStyle, prompt
|
|
23
|
-
from pygments.lexer import Lexer
|
|
24
|
-
from pygments.lexers.robotframework import RobotFrameworkLexer
|
|
25
16
|
|
|
26
17
|
from .lexer import RobotFrameworkLocalLexer
|
|
27
18
|
from .robotkeyword import get_rprompt_text
|
|
@@ -168,6 +159,50 @@ def _(event):
|
|
|
168
159
|
b.exit_selection()
|
|
169
160
|
|
|
170
161
|
|
|
162
|
+
@kb.add("{")
|
|
163
|
+
def _(event):
|
|
164
|
+
b = event.current_buffer
|
|
165
|
+
b.insert_text("{")
|
|
166
|
+
b.insert_text("}", move_cursor=False)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
@kb.add("[")
|
|
170
|
+
def _(event):
|
|
171
|
+
b = event.current_buffer
|
|
172
|
+
b.insert_text("[")
|
|
173
|
+
b.insert_text("]", move_cursor=False)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
MOUSE_SUPPORT = True
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
@kb.add("f12")
|
|
180
|
+
def _(event):
|
|
181
|
+
global MOUSE_SUPPORT
|
|
182
|
+
MOUSE_SUPPORT = not MOUSE_SUPPORT
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
TOOLBAR_KEY = ("", None, None)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def set_toolbar_key(statement_type, token, cursor_pos):
|
|
189
|
+
global TOOLBAR_KEY
|
|
190
|
+
TOOLBAR_KEY = statement_type, token, cursor_pos
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def bottom_toolbar():
|
|
194
|
+
return [
|
|
195
|
+
("class:bottom-toolbar-key", "STATEMENT: "),
|
|
196
|
+
("class:bottom-toolbar", f"{TOOLBAR_KEY[0]} "),
|
|
197
|
+
("class:bottom-toolbar-key", "value: "),
|
|
198
|
+
("class:bottom-toolbar", f"{TOOLBAR_KEY[1].value if TOOLBAR_KEY[1] else ''} "),
|
|
199
|
+
("class:bottom-toolbar-key", "TOKEN: "),
|
|
200
|
+
("class:bottom-toolbar", f"{TOOLBAR_KEY[1].type if TOOLBAR_KEY[1] else ''} "),
|
|
201
|
+
("class:bottom-toolbar-key", "TOKEN: "),
|
|
202
|
+
("class:bottom-toolbar", f"{TOOLBAR_KEY[2] if TOOLBAR_KEY[2] else ''} "),
|
|
203
|
+
]
|
|
204
|
+
|
|
205
|
+
|
|
171
206
|
class BaseCmd(cmd.Cmd):
|
|
172
207
|
"""Basic REPL tool."""
|
|
173
208
|
|
|
@@ -291,14 +326,6 @@ Type "help" for more information.\
|
|
|
291
326
|
def prompt_continuation(self, width, line_number, is_soft_wrap):
|
|
292
327
|
return " " * width
|
|
293
328
|
|
|
294
|
-
def bottom_toolbar(self):
|
|
295
|
-
return [
|
|
296
|
-
("class:bottom-toolbar-key", "more features"),
|
|
297
|
-
("class:bottom-toolbar", " coming soon... "),
|
|
298
|
-
("class:bottom-toolbar-key", "Shift+ArrowDown"),
|
|
299
|
-
("class:bottom-toolbar", " to insert a new line."),
|
|
300
|
-
]
|
|
301
|
-
|
|
302
329
|
def get_input(self):
|
|
303
330
|
kwargs = {}
|
|
304
331
|
if self.get_prompt_tokens:
|
|
@@ -309,7 +336,7 @@ Type "help" for more information.\
|
|
|
309
336
|
try:
|
|
310
337
|
line = prompt(
|
|
311
338
|
auto_suggest=AutoSuggestFromHistory(),
|
|
312
|
-
bottom_toolbar=
|
|
339
|
+
bottom_toolbar=bottom_toolbar,
|
|
313
340
|
clipboard=PyperclipClipboard(),
|
|
314
341
|
color_depth=ColorDepth.DEPTH_24_BIT,
|
|
315
342
|
completer=self.get_completer(),
|
|
@@ -321,10 +348,10 @@ Type "help" for more information.\
|
|
|
321
348
|
key_bindings=kb,
|
|
322
349
|
lexer=PygmentsLexer(RobotFrameworkLocalLexer),
|
|
323
350
|
message=prompt_str,
|
|
324
|
-
mouse_support=
|
|
351
|
+
mouse_support=MOUSE_SUPPORT,
|
|
325
352
|
prompt_continuation=self.prompt_continuation,
|
|
326
353
|
rprompt=get_rprompt_text(),
|
|
327
|
-
**kwargs
|
|
354
|
+
**kwargs,
|
|
328
355
|
)
|
|
329
356
|
except EOFError:
|
|
330
357
|
line = "EOF"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "3.10.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = "3.9.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{robotframework-debug-3.9.0 → robotframework-debug-3.10.0}/robotframework_debug.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|