--- a/src/eric7/MicroPython/MicroPythonFileManagerWidget.py Tue Feb 14 11:09:49 2023 +0100 +++ b/src/eric7/MicroPython/MicroPythonFileManagerWidget.py Tue Feb 14 18:10:30 2023 +0100 @@ -44,15 +44,12 @@ Class implementing a file manager for MicroPython devices. """ - def __init__(self, commandsInterface, deviceWithLocalAccess, parent=None): + def __init__(self, device, parent=None): """ Constructor - @param commandsInterface reference to the commands interface object - @type MicroPythonCommandsInterface - @param deviceWithLocalAccess flag indicating the device supports file - access via a local directory - @type bool + @param device MicroPython device object + @type BaseDevice @param parent reference to the parent widget @type QWidget """ @@ -60,7 +57,7 @@ self.setupUi(self) self.__repl = parent - self.__deviceWithLocalAccess = deviceWithLocalAccess + self.__deviceWithLocalAccess = device.supportsLocalFileAccess() self.syncButton.setIcon(EricPixmapCache.getIcon("2rightarrow")) self.putButton.setIcon(EricPixmapCache.getIcon("1rightarrow")) @@ -96,7 +93,7 @@ ) self.__progressInfoDialog = None - self.__fileManager = MicroPythonFileManager(commandsInterface, self) + self.__fileManager = MicroPythonFileManager(device, self) self.__fileManager.longListFiles.connect(self.__handleLongListFiles) self.__fileManager.currentDir.connect(self.__handleCurrentDir) @@ -382,7 +379,7 @@ name = ( cwd + item.text(0) if cwd.endswith("/") - else"{0}/{1}".format(cwd, item.text(0)) + else "{0}/{1}".format(cwd, item.text(0)) ) else: name = item.text(0) @@ -391,7 +388,7 @@ self.__fileManager.cd(name[:-1]) else: data = self.__fileManager.getData(name) - text = data.decode(encoding = "utf-8") + text = data.decode(encoding="utf-8") ericApp().getObject("ViewManager").newEditorWithText( text, "Python3", "device:{0}".format(name) ) @@ -688,13 +685,13 @@ name = ( cwd + filename if cwd.endswith("/") - else"{0}/{1}".format(cwd, filename) + else "{0}/{1}".format(cwd, filename) ) else: name = filename if not name.endswith("/"): data = self.__fileManager.getData(name) - text = data.decode(encoding = "utf-8") + text = data.decode(encoding="utf-8") ericApp().getObject("ViewManager").newEditorWithText( text, "Python3", "device:{0}".format(name) ) @@ -703,6 +700,9 @@ def on_saveButton_clicked(self, saveAs=False): """ Private slot to save the text of the current editor to a file on the device. + + @param saveAs flag indicating to save the file with a new name + @type bool """ aw = ericApp().getObject("ViewManager").activeWindow() if not aw: @@ -739,9 +739,7 @@ action, resultFilename = confirmOverwrite( filename, self.tr("Save File As"), - self.tr( - "The given file exists already (Enter file name only)." - ), + self.tr("The given file exists already (Enter file name only)."), False, self, ) @@ -758,9 +756,7 @@ deviceCwd = self.deviceCwd.text() if deviceCwd: filename = ( - deviceCwd + "/" + filename - if deviceCwd != "/" - else "/" + filename + deviceCwd + "/" + filename if deviceCwd != "/" else "/" + filename ) self.__fileManager.putData(filename, text.encode("utf-8"))