robotframework-debug 4.4.0__tar.gz → 4.5.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.
Files changed (38) hide show
  1. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/PKG-INFO +1 -1
  2. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/RobotDebug.py +1 -1
  3. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/cmdcompleter.py +36 -23
  4. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/debugcmd.py +7 -5
  5. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/globals.py +2 -0
  6. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/history_app.py +7 -3
  7. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/lexer.py +1 -2
  8. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/prompttoolkitcmd.py +1 -1
  9. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/robotkeyword.py +1 -3
  10. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/robotlib.py +3 -1
  11. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/sourcelines.py +6 -2
  12. robotframework-debug-4.5.0/RobotDebug/version.py +1 -0
  13. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/pyproject.toml +3 -3
  14. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/robotframework_debug.egg-info/PKG-INFO +1 -1
  15. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/robotframework_debug.egg-info/SOURCES.txt +1 -0
  16. robotframework-debug-4.5.0/tests/debug.robot +4 -0
  17. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/tests/step.robot +1 -0
  18. robotframework-debug-4.4.0/RobotDebug/version.py +0 -1
  19. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/.coveragerc +0 -0
  20. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/.gitpod.yml +0 -0
  21. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/ChangeLog +0 -0
  22. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/CreateWheel.sh +0 -0
  23. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/LICENSE +0 -0
  24. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/MANIFEST.in +0 -0
  25. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/README.rst +0 -0
  26. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/__init__.py +0 -0
  27. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/shell.py +0 -0
  28. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/RobotDebug/styles.py +0 -0
  29. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/_config.yml +0 -0
  30. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/robotframework_debug.egg-info/dependency_links.txt +0 -0
  31. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/robotframework_debug.egg-info/entry_points.txt +0 -0
  32. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/robotframework_debug.egg-info/not-zip-safe +0 -0
  33. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/robotframework_debug.egg-info/requires.txt +0 -0
  34. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/robotframework_debug.egg-info/top_level.txt +0 -0
  35. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/setup.cfg +0 -0
  36. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/setup.py +0 -0
  37. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/tests/__init__.py +0 -0
  38. {robotframework-debug-4.4.0 → robotframework-debug-4.5.0}/tests/test_debuglibrary.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: robotframework-debug
3
- Version: 4.4.0
3
+ Version: 4.5.0
4
4
  Summary: RobotFramework debug shell
5
5
  Home-page: https://github.com/imbus/robotframework-debug/
6
6
  Author: René Rohner
@@ -44,7 +44,7 @@ class Listener:
44
44
 
45
45
  path = attrs["source"]
46
46
  if path and Path(path).exists() and path not in self.source_files:
47
- self.source_files[path] = Path(path).open().readlines()
47
+ self.source_files[path] = Path(path).open().readlines() # noqa: SIM115
48
48
  lineno = attrs["lineno"]
49
49
  self.library.current_source_path = path
50
50
  self.library.current_source_line = lineno
@@ -8,7 +8,7 @@ from prompt_toolkit.document import Document
8
8
  from robot.libraries.BuiltIn import BuiltIn
9
9
  from robot.parsing.parser.parser import _tokens_to_statements
10
10
 
11
- from .globals import IS_RF_7
11
+ from .globals import IS_RF_7, KEYWORD_SEP
12
12
  from .lexer import get_robot_token, get_variable_token
13
13
  from .prompttoolkitcmd import PromptToolkitCmd
14
14
  from .robotkeyword import normalize_kw
@@ -69,9 +69,16 @@ class StatementInformation:
69
69
 
70
70
  def _find_token_at_cursor(self):
71
71
  for token in self.statement.tokens:
72
- if (
73
- token.type
74
- ): # in ["KEYWORD", "IF", "FOR", "ELSE", "ELSE IF"]: TODO: Commented to get all tokens in debug. lets see the impact
72
+ if token.type in [
73
+ "KEYWORD",
74
+ "IF",
75
+ "FOR",
76
+ "ELSE",
77
+ "ELSE IF",
78
+ "TRY",
79
+ "WHILE",
80
+ "VAR",
81
+ ]: # TODO: Commented to get all tokens in debug. lets see the impact
75
82
  self.statement_type = token.type
76
83
  if (
77
84
  token.lineno == self.cursor_row + 1
@@ -93,6 +100,12 @@ class CmdCompleter(Completer):
93
100
  self.helps = helps
94
101
  self.libs = libs
95
102
  self.keywords = list(keywords)
103
+ self.keywords_catalog = {}
104
+ for keyword in self.keywords:
105
+ self.keywords_catalog[normalize_kw(keyword.name)] = keyword
106
+ self.keywords_catalog[
107
+ f"{normalize_kw(keyword.parent.name)}.{normalize_kw(keyword.name)}"
108
+ ] = keyword
96
109
  self.current_statement = None
97
110
  for name, display, display_meta in self.get_commands():
98
111
  self.names.append(name)
@@ -163,28 +176,28 @@ class CmdCompleter(Completer):
163
176
  )
164
177
 
165
178
  def _get_argument_completer(self, text):
166
- for keyword in self.keywords:
167
- if normalize_kw(keyword.name) == normalize_kw(
168
- self.current_statement.statement.keyword
169
- ) or f"{normalize_kw(keyword.parent.name)}.{normalize_kw(keyword.name)}" == normalize_kw(
170
- self.current_statement.statement.keyword
171
- ):
172
- data_tokens = self.current_statement.statement.data_tokens
173
- args = keyword.args
174
- set_named_args, set_pos_args = self.get_set_args(args, data_tokens)
175
- if set_named_args:
176
- yield from self.get_named_arg_completion(args, set_named_args, set_pos_args)
177
- else:
178
- yield from self.get_pos_arg_completion(args, set_pos_args)
179
+ keyword = self.keywords_catalog.get(
180
+ normalize_kw(self.current_statement.statement.keyword), None
181
+ )
182
+ if keyword:
183
+ data_tokens = self.current_statement.statement.data_tokens
184
+ args = keyword.args
185
+ set_named_args, set_pos_args = self.get_set_args(args, data_tokens)
186
+ if set_named_args:
187
+ yield from self.get_named_arg_completion(args, set_named_args, set_pos_args)
188
+ else:
189
+ yield from self.get_pos_arg_completion(args, set_pos_args)
179
190
 
180
- def get_pos_arg_completion(self, args, set_pos_args):
191
+ def get_pos_arg_completion(
192
+ self, args, set_pos_args
193
+ ): # TODO: here is an issue. if more positional args are set, than existing, named_only will be removed from proposal
181
194
  for index, arg in enumerate([*args.positional_or_named, *args.named_only]):
182
195
  if index + 1 > len(set_pos_args):
183
- suffix = "=" if arg in [*args.positional_or_named, *args.named_only] else ""
196
+ # suffix = "=" if arg in [*args.positional_or_named, *args.named_only] else ""
184
197
  yield Completion(
185
- f"{arg}",
198
+ f"{arg}=",
186
199
  0,
187
- display=f"{arg}{suffix}",
200
+ display=f"{arg}=",
188
201
  display_meta=str(args.defaults.get(arg, "")),
189
202
  )
190
203
 
@@ -338,7 +351,7 @@ class CmdCompleter(Completer):
338
351
  ):
339
352
  yield from [
340
353
  Completion(
341
- f"{var[:-1]}",
354
+ var,
342
355
  -cursor_pos,
343
356
  display=var,
344
357
  display_meta=repr(val),
@@ -365,7 +378,7 @@ class KeywordAutoSuggestion(AutoSuggest):
365
378
  def get_suggestion(self, buffer: Buffer, document: Document) -> Union[Suggestion, None]:
366
379
  text = document.text
367
380
  completions = [compl.text for compl in self.completer.get_completions(document, None)]
368
- last_word = text.split(" ")[-1]
381
+ last_word = KEYWORD_SEP.split(text)[-1]
369
382
  matches = [kw for kw in completions if kw.startswith(last_word)]
370
383
  matches.extend([kw for kw in completions if kw.lower().startswith(last_word.lower())])
371
384
  return Suggestion(matches[0][len(last_word) :] if matches else "")
@@ -8,6 +8,8 @@ from prompt_toolkit.styles import merge_styles
8
8
  from robot.api import logger
9
9
  from robot.errors import ExecutionFailed, HandlerExecutionFailed
10
10
  from robot.libraries.BuiltIn import BuiltIn
11
+ from robot.running import Keyword
12
+ from robot.running.context import _ExecutionContext
11
13
  from robot.running.signalhandler import STOP_SIGNAL_MONITOR
12
14
  from robot.variables import is_variable
13
15
 
@@ -100,7 +102,7 @@ Access https://github.com/imbus/robotframework-debug for more details.\
100
102
  self.run_robot_command(command)
101
103
 
102
104
  def run_robot_command(self, command):
103
- """Run command in robotframewrk environment."""
105
+ """Run command in robotframework environment."""
104
106
  if not command:
105
107
  return
106
108
  result = []
@@ -309,8 +311,8 @@ def run_command(dbg_cmd, command: str) -> List[Tuple[str, str]]:
309
311
  return []
310
312
 
311
313
 
312
- def run_keyword(keyword, context):
313
- if IS_RF_7 and context.steps:
314
- data, result = context.steps[-1]
315
- return keyword.run(result, context)
314
+ def run_keyword(keyword: Keyword, context: _ExecutionContext):
315
+ if IS_RF_7:
316
+ test = context.test or context.suite
317
+ return keyword.run(test, context)
316
318
  return keyword.run(context)
@@ -1,3 +1,4 @@
1
+ import re
1
2
  from enum import Enum
2
3
 
3
4
  from robot.version import get_version
@@ -25,3 +26,4 @@ class StepMode(str, Enum):
25
26
 
26
27
 
27
28
  IS_RF_7 = int(get_version().split(".", 1)[0]) >= 7 # noqa: PLR2004
29
+ KEYWORD_SEP = re.compile(r"[ \t]{2,}|\t")
@@ -136,10 +136,14 @@ def get_history_content(his, pure_commands: bool = True):
136
136
  [
137
137
  e
138
138
  for e in dict.fromkeys(
139
- reversed([re.sub(r" {2,}", " " * 4, v).strip() for v in his.get_strings()])
139
+ reversed(
140
+ [
141
+ re.sub(r"(?:(?<![\n ])(?:[ \t]{2,}|\t))", " " * 4, v).strip()
142
+ for v in his.get_strings()
143
+ ]
144
+ )
140
145
  )
141
- if (not HEADER_MATCHER.match(e) and pure_commands)
142
- or (HEADER_MATCHER.match(e) and not pure_commands)
146
+ if bool(HEADER_MATCHER.match(e)) != pure_commands
143
147
  ]
144
148
  )
145
149
  )
@@ -50,8 +50,7 @@ def get_variable_token(token_list):
50
50
  var_tokens = list(token.tokenize_variables())
51
51
  except Exception:
52
52
  var_tokens = [token]
53
- for v_token in var_tokens:
54
- yield v_token
53
+ yield from var_tokens
55
54
 
56
55
 
57
56
  class RobotFrameworkLocalLexer(Lexer):
@@ -304,7 +304,7 @@ class BaseCmd(cmd.Cmd):
304
304
  if line is None:
305
305
  return None
306
306
 
307
- if line == "exit" or line == "EOF":
307
+ if line in ["exit", "EOF"]:
308
308
  line = "EOF"
309
309
  return True
310
310
 
@@ -1,4 +1,3 @@
1
- import re
2
1
  import tempfile
3
2
  from pathlib import Path
4
3
  from typing import Iterator, List, Tuple
@@ -14,10 +13,9 @@ except ImportError:
14
13
  from robot.running import ResourceFile
15
14
  from robot.variables.search import is_variable
16
15
 
16
+ from .globals import KEYWORD_SEP
17
17
  from .robotlib import ImportedLibraryDocBuilder, ImportedResourceDocBuilder, get_libs
18
18
 
19
- KEYWORD_SEP = re.compile(" +|\t")
20
-
21
19
  _lib_keywords_cache = {}
22
20
  _resource_keywords_cache = {}
23
21
  temp_resources = []
@@ -1,3 +1,5 @@
1
+ from copy import deepcopy
2
+
1
3
  from robot.libdocpkg.model import LibraryDoc
2
4
  from robot.libdocpkg.robotbuilder import (
3
5
  KeywordDocBuilder,
@@ -44,7 +46,7 @@ class ImportedResourceDocBuilder(ResourceDocBuilder):
44
46
  type="RESOURCE",
45
47
  scope="GLOBAL",
46
48
  )
47
- libdoc.keywords = KeywordDocBuilder().build_keywords(resource)
49
+ libdoc.keywords = KeywordDocBuilder().build_keywords(deepcopy(resource))
48
50
  return libdoc
49
51
 
50
52
 
@@ -16,7 +16,9 @@ def print_source_lines(style, source_file, lineno, before_and_after=5):
16
16
  if not source_file or not lineno:
17
17
  return
18
18
 
19
- Path(source_file).open().readlines()
19
+ Path(
20
+ source_file
21
+ ).open().readlines() # noqa: SIM115 TODO: not sure why i did this. Maybe to check if file is actually readable...
20
22
  prefixed_token = get_pygments_token_from_file(lineno, source_file)
21
23
  printable_token = filter_token_by_lineno(
22
24
  prefixed_token, lineno - before_and_after, lineno + before_and_after + 1
@@ -28,7 +30,9 @@ def print_test_case_lines(style, source_file, current_lineno):
28
30
  if not source_file or not current_lineno:
29
31
  return
30
32
 
31
- Path(source_file).open().readlines()
33
+ Path(
34
+ source_file
35
+ ).open().readlines() # noqa: SIM115 TODO: not sure why i did this. Maybe to check if file is actually readable...
32
36
  prefixed_token = get_pygments_token_from_file(current_lineno, source_file)
33
37
  printable_token = filter_token_by_scope(prefixed_token, current_lineno)
34
38
  print_pygments_styles(printable_token, style)
@@ -0,0 +1 @@
1
+ VERSION = "4.5.0"
@@ -3,12 +3,12 @@ target-version = ['py37']
3
3
  line-length = 100
4
4
 
5
5
  [tool.ruff]
6
- unfixable = []
6
+ lint.unfixable = []
7
7
  exclude = [
8
8
  "__pycache__",
9
9
  "tests/"
10
10
  ]
11
- ignore = [
11
+ lint.ignore = [
12
12
  "B008", # do not perform function calls in argument defaults
13
13
  "E501", # line too long
14
14
  "N815", # mixedCase variable in class scope
@@ -19,7 +19,7 @@ ignore = [
19
19
  "PLR0913", # too many arguments
20
20
  ]
21
21
  target-version = "py37"
22
- select = [
22
+ lint.select = [
23
23
  "E",
24
24
  "F",
25
25
  "W",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: robotframework-debug
3
- Version: 4.4.0
3
+ Version: 4.5.0
4
4
  Summary: RobotFramework debug shell
5
5
  Home-page: https://github.com/imbus/robotframework-debug/
6
6
  Author: René Rohner
@@ -31,5 +31,6 @@ robotframework_debug.egg-info/not-zip-safe
31
31
  robotframework_debug.egg-info/requires.txt
32
32
  robotframework_debug.egg-info/top_level.txt
33
33
  tests/__init__.py
34
+ tests/debug.robot
34
35
  tests/step.robot
35
36
  tests/test_debuglibrary.py
@@ -0,0 +1,4 @@
1
+ *** Test Cases ***
2
+ Test
3
+ Import Resource ${CURDIR}/keyword.resource
4
+ kw
@@ -1,5 +1,6 @@
1
1
  *** Settings ***
2
2
  Library RobotDebug
3
+ Suite Setup debug
3
4
 
4
5
  *** Test Cases ***
5
6
  test1
@@ -1 +0,0 @@
1
- VERSION = "4.4.0"