src/eric7/MicroPython/GenericMicroPythonDevices.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
--- a/src/eric7/MicroPython/GenericMicroPythonDevices.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/MicroPython/GenericMicroPythonDevices.py	Wed Jul 13 14:55:47 2022 +0200
@@ -23,10 +23,11 @@
     """
     Class implementing the device interface for generic MicroPython boards.
     """
+
     def __init__(self, microPythonWidget, deviceType, vid, pid, parent=None):
         """
         Constructor
-        
+
         @param microPythonWidget reference to the main MicroPython widget
         @type MicroPythonWidget
         @param deviceType device type assigned to this device interface
@@ -38,124 +39,120 @@
         @param parent reference to the parent object
         @type QObject
         """
-        super().__init__(
-            microPythonWidget, deviceType, parent)
-        
+        super().__init__(microPythonWidget, deviceType, parent)
+
         self.__directAccess = False
         self.__deviceVolumeName = ""
         self.__workspace = ""
         self.__deviceName = ""
-        
+
         for deviceData in Preferences.getMicroPython("ManualDevices"):
-            if (
-                deviceData["vid"] == vid and
-                deviceData["pid"] == pid
-            ):
+            if deviceData["vid"] == vid and deviceData["pid"] == pid:
                 self.__deviceVolumeName = deviceData["data_volume"]
                 self.__directAccess = bool(deviceData["data_volume"])
                 self.__deviceName = deviceData["description"]
-                
+
                 if self.__directAccess:
                     self.__workspace = self.__findWorkspace()
-    
+
     def setButtons(self):
         """
         Public method to enable the supported action buttons.
         """
         super().setButtons()
         self.microPython.setActionButtons(
-            run=True, repl=True, files=True, chart=HAS_QTCHART)
-        
+            run=True, repl=True, files=True, chart=HAS_QTCHART
+        )
+
         if self.__directAccess and self.__deviceVolumeMounted():
             self.microPython.setActionButtons(open=True, save=True)
-    
+
     def deviceName(self):
         """
         Public method to get the name of the device.
-        
+
         @return name of the device
         @rtype str
         """
         return self.__deviceName
-    
+
     def canStartRepl(self):
         """
         Public method to determine, if a REPL can be started.
-        
+
         @return tuple containing a flag indicating it is safe to start a REPL
             and a reason why it cannot.
         @rtype tuple of (bool, str)
         """
         return True, ""
-    
+
     def canStartPlotter(self):
         """
         Public method to determine, if a Plotter can be started.
-        
+
         @return tuple containing a flag indicating it is safe to start a
             Plotter and a reason why it cannot.
         @rtype tuple of (bool, str)
         """
         return True, ""
-    
+
     def canRunScript(self):
         """
         Public method to determine, if a script can be executed.
-        
+
         @return tuple containing a flag indicating it is safe to start a
             Plotter and a reason why it cannot.
         @rtype tuple of (bool, str)
         """
         return True, ""
-    
+
     def runScript(self, script):
         """
         Public method to run the given Python script.
-        
+
         @param script script to be executed
         @type str
         """
         pythonScript = script.split("\n")
         self.sendCommands(pythonScript)
-    
+
     def canStartFileManager(self):
         """
         Public method to determine, if a File Manager can be started.
-        
+
         @return tuple containing a flag indicating it is safe to start a
             File Manager and a reason why it cannot.
         @rtype tuple of (bool, str)
         """
         return True, ""
-    
+
     def supportsLocalFileAccess(self):
         """
         Public method to indicate file access via a local directory.
-        
+
         @return flag indicating file access via local directory
         @rtype bool
         """
         return self.__deviceVolumeMounted()
-    
+
     def __deviceVolumeMounted(self):
         """
         Private method to check, if the device volume is mounted.
-        
+
         @return flag indicated a mounted device
         @rtype bool
         """
         if self.__workspace and not os.path.exists(self.__workspace):
-            self.__workspace = ""       # reset
-        
-        return (
-            self.__directAccess and
-            self.__deviceVolumeName in self.getWorkspace(silent=True)
+            self.__workspace = ""  # reset
+
+        return self.__directAccess and self.__deviceVolumeName in self.getWorkspace(
+            silent=True
         )
-    
+
     def getWorkspace(self, silent=False):
         """
         Public method to get the workspace directory.
-        
+
         @param silent flag indicating silent operations
         @type bool
         @return workspace directory used for saving files
@@ -170,11 +167,11 @@
                 return self.__workspace
         else:
             return super().getWorkspace()
-    
+
     def __findWorkspace(self, silent=False):
         """
         Private method to find the workspace directory.
-        
+
         @param silent flag indicating silent operations
         @type bool
         @return workspace directory used for saving files
@@ -182,9 +179,8 @@
         """
         # Attempts to find the path on the filesystem that represents the
         # plugged in board.
-        deviceDirectories = Utilities.findVolume(self.__deviceVolumeName,
-                                                 findAll=True)
-        
+        deviceDirectories = Utilities.findVolume(self.__deviceVolumeName, findAll=True)
+
         if deviceDirectories:
             if len(deviceDirectories) == 1:
                 return deviceDirectories[0]
@@ -197,11 +193,12 @@
                 EricMessageBox.warning(
                     self.microPython,
                     self.tr("Workspace Directory"),
-                    self.tr("Python files for this generic board can be"
-                            " edited in place, if the device volume is locally"
-                            " available. A volume named '{0}' was not found."
-                            " In place editing will not be available."
-                            ).format(self.__deviceVolumeName)
+                    self.tr(
+                        "Python files for this generic board can be"
+                        " edited in place, if the device volume is locally"
+                        " available. A volume named '{0}' was not found."
+                        " In place editing will not be available."
+                    ).format(self.__deviceVolumeName),
                 )
-            
+
             return super().getWorkspace()

eric ide

mercurial