From 907e4bc6d95f566cf62f392298c6d8d4fb8345d7 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 28 Apr 2020 21:08:40 +0300 Subject: [PATCH] - disabled a skip_quotes method in ToolShell.FCShell class so I can now use quotes to enclose file paths with spaces inside --- CHANGELOG.md | 2 +- flatcamGUI/GUIElements.py | 3 +-- flatcamTools/ToolShell.py | 32 +++++++++++++++------------ tclCommands/TclCommandOpenExcellon.py | 6 ++--- tclCommands/TclCommandOpenGCode.py | 6 ++--- tclCommands/TclCommandOpenGerber.py | 4 ---- tclCommands/TclCommandOpenProject.py | 6 ++--- 7 files changed, 29 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e17d742..53814f64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ CHANGELOG for FlatCAM beta - in SVG parser modified some imports to be one on each line - fixed the Tcl Command BBox (leftovers from recent global changes) - fixed some typos in strings reported by @pcb-hobbyst on FlatCAM forum - +- disabled a skip_quotes method in ToolShell.FCShell class so I can now use quotes to enclose file paths with spaces inside 27.04.2020 diff --git a/flatcamGUI/GUIElements.py b/flatcamGUI/GUIElements.py index 6a5d06a2..c43549ff 100644 --- a/flatcamGUI/GUIElements.py +++ b/flatcamGUI/GUIElements.py @@ -2694,8 +2694,7 @@ class _ExpandableTextEdit(QTextEdit): if line_count <= 1: self.historyPrev.emit() return - elif event.matches(QKeySequence.MoveToNextPage) or \ - event.matches(QKeySequence.MoveToPreviousPage): + elif event.matches(QKeySequence.MoveToNextPage) or event.matches(QKeySequence.MoveToPreviousPage): return self._termWidget.browser().keyPressEvent(event) tc = self.textCursor() diff --git a/flatcamTools/ToolShell.py b/flatcamTools/ToolShell.py index 6dc3e73b..eef2a465 100644 --- a/flatcamTools/ToolShell.py +++ b/flatcamTools/ToolShell.py @@ -107,25 +107,25 @@ class TermWidget(QWidget): mtype = text[:idx+1].upper() mtype = mtype.replace('_NOTCL', '') body = text[idx+1:] - if style == 'in': + if style.lower() == 'in': text = '%s' % text - elif style == 'err': + elif style.lower() == 'err': text = '%s'\ '%s'\ % (mtype, body) - elif style == 'warning': + elif style.lower() == 'warning': # text = '%s' % text text = '%s' \ '%s' \ % (mtype, body) - elif style == 'success': + elif style.lower() == 'success': # text = '%s' % text text = '%s' \ '%s' \ % (mtype, body) - elif style == 'selected': + elif style.lower() == 'selected': text = '' - elif style == 'raw': + elif style.lower() == 'raw': text = text else: # without span
is ignored!!! @@ -226,7 +226,7 @@ class TermWidget(QWidget): def is_command_complete(self, text): """ - Executed by _ExpandableTextEdit. Reimplement this function in the child classes. + Executed by _ExpandableTextEdit. Re-implement this function in the child classes. """ return True @@ -344,19 +344,23 @@ class FCShell(TermWidget): ''') def is_command_complete(self, text): + def skipQuotes(txt): quote = txt[0] text_val = txt[1:] endIndex = str(text_val).index(quote) return text[endIndex:] - while text: - if text[0] in ('"', "'"): - try: - text = skipQuotes(text) - except ValueError: - return False - text = text[1:] + # I'm disabling this because I need to be able to load paths that have spaces by + # enclosing them in quotes --- Marius Stanciu + # while text: + # if text[0] in ('"', "'"): + # try: + # text = skipQuotes(text) + # except ValueError: + # return False + # text = text[1:] + return True def child_exec_command(self, text): diff --git a/tclCommands/TclCommandOpenExcellon.py b/tclCommands/TclCommandOpenExcellon.py index 41f23a4b..8c187f26 100644 --- a/tclCommands/TclCommandOpenExcellon.py +++ b/tclCommands/TclCommandOpenExcellon.py @@ -53,9 +53,9 @@ class TclCommandOpenExcellon(TclCommandSignaled): filename = args.pop('filename') - if ' ' in filename: - return "The absolute path to the project file contain spaces which is not allowed.\n" \ - "Please enclose the path within quotes." + # if ' ' in filename: + # return "The absolute path to the project file contain spaces which is not allowed.\n" \ + # "Please enclose the path within quotes." args['plot'] = False args['from_tcl'] = True diff --git a/tclCommands/TclCommandOpenGCode.py b/tclCommands/TclCommandOpenGCode.py index 86da6cd8..489e253b 100644 --- a/tclCommands/TclCommandOpenGCode.py +++ b/tclCommands/TclCommandOpenGCode.py @@ -53,8 +53,8 @@ class TclCommandOpenGCode(TclCommandSignaled): args['plot'] = False args['from_tcl'] = True filename = args["filename"] - if ' ' in filename: - return "The absolute path to the project file contain spaces which is not allowed.\n" \ - "Please enclose the path within quotes." + # if ' ' in filename: + # return "The absolute path to the project file contain spaces which is not allowed.\n" \ + # "Please enclose the path within quotes." self.app.open_gcode(filename, **args) diff --git a/tclCommands/TclCommandOpenGerber.py b/tclCommands/TclCommandOpenGerber.py index 35114108..f13cc87a 100644 --- a/tclCommands/TclCommandOpenGerber.py +++ b/tclCommands/TclCommandOpenGerber.py @@ -55,10 +55,6 @@ class TclCommandOpenGerber(TclCommandSignaled): filename = args.pop('filename') - if ' ' in filename: - return "The absolute path to the project file contain spaces which is not allowed.\n" \ - "Please enclose the path within quotes." - if 'outname' in args: outname = args['outname'] else: diff --git a/tclCommands/TclCommandOpenProject.py b/tclCommands/TclCommandOpenProject.py index 48af1974..64477b71 100644 --- a/tclCommands/TclCommandOpenProject.py +++ b/tclCommands/TclCommandOpenProject.py @@ -49,8 +49,8 @@ class TclCommandOpenProject(TclCommandSignaled): :return: None or exception """ filename = args['filename'] - if ' ' in filename: - return "The absolute path to the project file contain spaces which is not allowed.\n" \ - "Please enclose the path within quotes." + # if ' ' in filename: + # return "The absolute path to the project file contain spaces which is not allowed.\n" \ + # "Please enclose the path within quotes." self.app.open_project(filename, cli=True, plot=False, from_tcl=True)