liveConsole 1.7.1__tar.gz → 1.7.3__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.

Potentially problematic release.


This version of liveConsole might be problematic. Click here for more details.

Files changed (24) hide show
  1. {liveconsole-1.7.1/src/liveConsole.egg-info → liveconsole-1.7.3}/PKG-INFO +1 -1
  2. {liveconsole-1.7.1 → liveconsole-1.7.3}/pyproject.toml +1 -1
  3. {liveconsole-1.7.1 → liveconsole-1.7.3/src/liveConsole.egg-info}/PKG-INFO +1 -1
  4. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/mainConsole.py +24 -20
  5. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/pysole.py +66 -37
  6. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/settings.json +1 -1
  7. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/themes.json +4 -4
  8. {liveconsole-1.7.1 → liveconsole-1.7.3}/LICENSE +0 -0
  9. {liveconsole-1.7.1 → liveconsole-1.7.3}/MANIFEST.in +0 -0
  10. {liveconsole-1.7.1 → liveconsole-1.7.3}/README.md +0 -0
  11. {liveconsole-1.7.1 → liveconsole-1.7.3}/setup.cfg +0 -0
  12. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/liveConsole.egg-info/SOURCES.txt +0 -0
  13. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/liveConsole.egg-info/dependency_links.txt +0 -0
  14. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/liveConsole.egg-info/entry_points.txt +0 -0
  15. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/liveConsole.egg-info/requires.txt +0 -0
  16. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/liveConsole.egg-info/top_level.txt +0 -0
  17. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/__init__.py +0 -0
  18. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/__main__.py +0 -0
  19. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/commandHistory.py +0 -0
  20. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/helpTab.py +0 -0
  21. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/liveConsole.py +0 -0
  22. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/styledTextbox.py +0 -0
  23. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/suggestionManager.py +0 -0
  24. {liveconsole-1.7.1 → liveconsole-1.7.3}/src/pysole/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: liveConsole
3
- Version: 1.7.1
3
+ Version: 1.7.3
4
4
  Summary: An IDLE-like debugger to allow for real-time command injection for debugging and testing python code
5
5
  Author-email: Tzur Soffer <tzur.soffer@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "liveConsole"
3
- version = "1.7.1"
3
+ version = "1.7.3"
4
4
  description = "An IDLE-like debugger to allow for real-time command injection for debugging and testing python code"
5
5
  authors = [{ name="Tzur Soffer", email="tzur.soffer@gmail.com" }]
6
6
  license = {text = "MIT"}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: liveConsole
3
- Version: 1.7.1
3
+ Version: 1.7.3
4
4
  Summary: An IDLE-like debugger to allow for real-time command injection for debugging and testing python code
5
5
  Author-email: Tzur Soffer <tzur.soffer@gmail.com>
6
6
  License: MIT
@@ -50,6 +50,10 @@ class InteractiveConsoleText(StyledTextWindow):
50
50
  self.bind("<Up>", self.onUp)
51
51
  self.bind("<Down>", self.onDown)
52
52
 
53
+ def getPromptPosition(self):
54
+ """Get the position right after the prompt on current command line."""
55
+ return(f"{self.currentCommandLine}.{self.PROMPT_LENGTH}")
56
+
53
57
  def getCurrentLineNumber(self):
54
58
  """Get the line number where current command starts."""
55
59
  return(int(self.index("end-1c").split(".")[0]))
@@ -60,30 +64,35 @@ class InteractiveConsoleText(StyledTextWindow):
60
64
  def getCommandStartPosition(self):
61
65
  """Get the starting position of the current command."""
62
66
  return(f"{self.currentCommandLine}.0")
67
+
68
+ def writeToPrompt(self, text):
69
+ """Write text to the prompt of the console"""
70
+ if self.isExecuting:
71
+ return
72
+
73
+ if text:
74
+ self.insert("end", text)
75
+ self.mark_set("insert", "end")
76
+ self.see("end")
77
+ self.updateStyling(start=self.getPromptPosition()) #< Ensure styling/lexer applied after programmatic change:
63
78
 
64
79
  def replaceCurrentCommand(self, newCommand):
65
80
  """Replace the current command with new text."""
66
- if self.isExecuting:
67
- return
68
-
69
81
  start = self.getPromptPosition()
70
82
  end = "end-1c"
71
-
72
83
  self.delete(start, end)
73
- if newCommand:
74
- self.insert(start, newCommand)
75
- self.mark_set("insert", "end")
76
- self.see("end")
77
- # Ensure styling/lexer applied after programmatic change:
78
- self.updateStyling(start=self.getPromptPosition())
84
+ self.writeToPrompt(newCommand)
79
85
 
80
- def runCommand(self, command, printCommand=False):
86
+ def runCommand(self, command, printCommand=False, clearPrompt=True):
81
87
  """Insert code into the console prompt and execute it as if Enter was pressed."""
82
88
  if self.isExecuting:
83
89
  return(False)
84
90
  if printCommand:
85
- self.replaceCurrentCommand(command) #< Replace current command with the new code
86
- self.onEnter(None) #< Simulate pressing Enter to run the command
91
+ if clearPrompt:
92
+ self.replaceCurrentCommand(command) #< Replace current command with the new code
93
+ else:
94
+ self.writeToPrompt(command)
95
+ self.onEnter(None, insertWhitespace=False) #< Simulate pressing Enter to run the command
87
96
  else:
88
97
  self.executeCommandThreaded(command, addPrompt=False)
89
98
 
@@ -98,7 +107,7 @@ class InteractiveConsoleText(StyledTextWindow):
98
107
  return((cursorLine >= self.currentCommandLine and
99
108
  (cursorLine > self.currentCommandLine or cursorCol >= self.PROMPT_LENGTH)))
100
109
 
101
- def onEnter(self, event):
110
+ def onEnter(self, event, insertWhitespace=True):
102
111
  """Handle Enter key - execute command."""
103
112
  self.suggestionManager.hideSuggestions()
104
113
 
@@ -119,9 +128,8 @@ class InteractiveConsoleText(StyledTextWindow):
119
128
  return("break")
120
129
 
121
130
  # Check if statement is incomplete
122
- if self.isIncompleteStatement(command):
131
+ if self.isIncompleteStatement(command) and insertWhitespace:
123
132
  return(self.onShiftEnter(event))
124
-
125
133
  # Execute the command
126
134
  self.history.add(command)
127
135
  self.mark_set("insert", "end")
@@ -351,10 +359,6 @@ class InteractiveConsoleText(StyledTextWindow):
351
359
  """Insert a newline at the end."""
352
360
  self.writeOutput("")
353
361
 
354
- def getPromptPosition(self):
355
- """Get the position right after the prompt on current command line."""
356
- return(f"{self.currentCommandLine}.{self.PROMPT_LENGTH}")
357
-
358
362
  def getCurrentCommand(self):
359
363
  """Extract the current command text (without prompt)."""
360
364
  start = self.getPromptPosition()
@@ -96,8 +96,11 @@ class InteractiveConsole(ctk.CTk):
96
96
  with open(filename, "r", encoding="utf-8") as f:
97
97
  lines = f.readlines()
98
98
 
99
- startLine = callerFrame.f_lineno
100
- self.startupCode = lines[startLine:]
99
+ startLineIndex = callerFrame.f_lineno
100
+ startLine = lines[startLineIndex - 1]
101
+ leadingWhitespaceLen = len(startLine) - len(startLine.lstrip())
102
+ self.startupCode = lines[startLineIndex:]
103
+ self.startupCode = [line.rstrip()[leadingWhitespaceLen:] for line in self.startupCode]
101
104
 
102
105
  def _createMenu(self):
103
106
  """Create a menu bar using CTkOptionMenu."""
@@ -257,44 +260,70 @@ class InteractiveConsole(ctk.CTk):
257
260
  sys.stdout = sys.__stdout__
258
261
  sys.stderr = sys.__stderr__
259
262
  self.destroy()
263
+
264
+ def _printWaterMark(self):
265
+ m = (
266
+ "Welcome to Pysole, if you find me useful, please star me on GitHub:\n"
267
+ "https://github.com/TzurSoffer/Pysole"
268
+ )
269
+ stdPrint(m)
270
+ self.console.newline()
271
+ self.console.writeOutput(m, "instruction")
272
+ time.sleep(0.1)
273
+ if self.runRemainingCode:
274
+ if self.printStartupCode:
275
+ self.console.addPrompt()
276
+ else:
277
+ self.console.newline()
278
+ else:
279
+ self.console.addPrompt()
280
+
281
+ def _splitCodeIntoChunks(self):
282
+ codeChunks = []
283
+ currentChunk = []
284
+
285
+ for line in self.startupCode:
286
+ strippedLine = line.lstrip()
287
+ indentLevel = len(line) - len(strippedLine)
288
+
289
+ if not strippedLine: #< Blank line, keep it in current chunk
290
+ currentChunk.append(line)
291
+ continue
292
+
293
+ if indentLevel != 0:
294
+ currentChunk.append(line)
295
+ else:
296
+ codeChunks.append(currentChunk)
297
+ currentChunk = [line]
298
+
299
+ if currentChunk:
300
+ codeChunks.append(currentChunk)
301
+
302
+ return(["\n".join(chunk).strip() for chunk in codeChunks if any(line.strip() for line in chunk)])
303
+
304
+
305
+ def _runStartup(self):
306
+ if self.removeWaterMark == False:
307
+ self._printWaterMark()
308
+
309
+ if self.runRemainingCode == False:
310
+ return
311
+
312
+ if self.printStartupCode == False:
313
+ self.console.newline()
314
+ code = "\n".join(self.startupCode)
315
+ self.console.executeCommandThreaded(code, addPrompt=True)
316
+ return
317
+
318
+ chunks = self._splitCodeIntoChunks()
319
+ for chunk in chunks:
320
+ while self.console.isExecuting:
321
+ time.sleep(0.01)
322
+ self.console.runCommand(chunk, printCommand=True, clearPrompt=True)
260
323
 
261
324
  def probe(self, *args, **kwargs):
262
325
  """Start the console main loop."""
263
- def runStartup():
264
- if not self.removeWaterMark:
265
- m = (
266
- "Welcome to Pysole, if you find me useful, please star me on GitHub:\n"
267
- "https://github.com/TzurSoffer/Pysole"
268
- )
269
- stdPrint(m)
270
- self.console.newline()
271
- self.console.writeOutput(m, "instruction")
272
- time.sleep(0.1)
273
- if self.runRemainingCode:
274
- if self.printStartupCode:
275
- self.console.addPrompt()
276
- else:
277
- self.console.newline()
278
- else:
279
- self.console.addPrompt()
280
- elif self.runRemainingCode == True and self.printStartupCode == False:
281
- self.console.newline()
282
-
283
- for line in self.startupCode:
284
- line = line.rstrip()
285
- while self.console.isExecuting:
286
- time.sleep(0.01)
287
- if self.printStartupCode:
288
- # self.console.writeOutput(line)
289
- self.console.runCommand(line, printCommand=True)
290
- else:
291
- # self.console.writeOutput(line)
292
- self.console.runCommand(line, printCommand=False)
293
-
294
- if self.runRemainingCode == True and self.printStartupCode == False:
295
- self.console.resetCurrentLineNumber()
296
- self.console.addPrompt()
297
- threading.Thread(target=runStartup).start()
326
+ self.after(0, threading.Thread(target=self._runStartup).start)
298
327
  self.mainloop(*args, **kwargs)
299
328
 
300
329
  def probe(userGlobals=None, userLocals=None, callerFrame=None,
@@ -11,7 +11,7 @@
11
11
  "OUTPUT": "#ffffff",
12
12
  "ERROR": "#ff0000",
13
13
  "RESULT": "#66ccff",
14
- "INSTRUCTION": "#ffff00",
14
+ "INSTRUCTION": "#ffccdd",
15
15
  "SUGGESTION_BOX_BG": "#2d2d2d",
16
16
  "SUGGESTION_BOX_SELECTION_BG": "#0066cc",
17
17
  "FONT": {
@@ -11,7 +11,7 @@
11
11
  "OUTPUT": "#ffffff",
12
12
  "ERROR": "#ff0000",
13
13
  "RESULT": "#66ccff",
14
- "INSTRUCTION": "#ffff00",
14
+ "INSTRUCTION": "#ffccdd",
15
15
  "SUGGESTION_BOX_BG": "#2d2d2d",
16
16
  "SUGGESTION_BOX_SELECTION_BG": "#0066cc",
17
17
  "FONT": {
@@ -31,7 +31,7 @@
31
31
  "OUTPUT": "#000000",
32
32
  "ERROR": "#ff0000",
33
33
  "RESULT": "#0066cc",
34
- "INSTRUCTION": "#ffff00",
34
+ "INSTRUCTION": "#ffccdd",
35
35
  "SUGGESTION_BOX_BG": "#f0f0f0",
36
36
  "SUGGESTION_BOX_SELECTION_BG": "#cce6ff",
37
37
  "FONT": {
@@ -51,7 +51,7 @@
51
51
  "OUTPUT": "#586e75",
52
52
  "ERROR": "#dc322f",
53
53
  "RESULT": "#2aa198",
54
- "INSTRUCTION": "#ffff00",
54
+ "INSTRUCTION": "#ffccdd",
55
55
  "SUGGESTION_BOX_BG": "#eee8d5",
56
56
  "SUGGESTION_BOX_SELECTION_BG": "#b58900",
57
57
  "FONT": {
@@ -71,7 +71,7 @@
71
71
  "OUTPUT": "#f8f8f2",
72
72
  "ERROR": "#ff5555",
73
73
  "RESULT": "#8be9fd",
74
- "INSTRUCTION": "#ffff00",
74
+ "INSTRUCTION": "#ffccdd",
75
75
  "SUGGESTION_BOX_BG": "#44475a",
76
76
  "SUGGESTION_BOX_SELECTION_BG": "#6272a4",
77
77
  "FONT": {
File without changes
File without changes
File without changes
File without changes