From a09cd0e63e6b5cffba068c9f704b01280b2313e7 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Fri, 8 May 2020 17:37:49 +0200 Subject: [PATCH] Convert doxygen to rst for Prepare, Preview, RemovableOutputDevice --- plugins/PrepareStage/PrepareStage.py | 38 ++++++++++--------- plugins/PreviewStage/PreviewStage.py | 38 +++++++++++-------- .../LinuxRemovableDrivePlugin.py | 12 +++--- .../OSXRemovableDrivePlugin.py | 4 +- .../RemovableDriveOutputDevice.py | 36 +++++++++--------- .../WindowsRemovableDrivePlugin.py | 3 +- 6 files changed, 74 insertions(+), 57 deletions(-) diff --git a/plugins/PrepareStage/PrepareStage.py b/plugins/PrepareStage/PrepareStage.py index c2dee9693b..2d7ee9ee4f 100644 --- a/plugins/PrepareStage/PrepareStage.py +++ b/plugins/PrepareStage/PrepareStage.py @@ -1,19 +1,21 @@ -# Copyright (c) 2019 Ultimaker B.V. -# Cura is released under the terms of the LGPLv3 or higher. - -import os.path -from UM.Application import Application -from UM.PluginRegistry import PluginRegistry -from cura.Stages.CuraStage import CuraStage - -## Stage for preparing model (slicing). -class PrepareStage(CuraStage): - def __init__(self, parent = None): - super().__init__(parent) - Application.getInstance().engineCreatedSignal.connect(self._engineCreated) - - def _engineCreated(self): - menu_component_path = os.path.join(PluginRegistry.getInstance().getPluginPath("PrepareStage"), "PrepareMenu.qml") - main_component_path = os.path.join(PluginRegistry.getInstance().getPluginPath("PrepareStage"), "PrepareMain.qml") - self.addDisplayComponent("menu", menu_component_path) +# Copyright (c) 2019 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + +import os.path +from UM.Application import Application +from UM.PluginRegistry import PluginRegistry +from cura.Stages.CuraStage import CuraStage + + +class PrepareStage(CuraStage): + """Stage for preparing model (slicing).""" + + def __init__(self, parent = None): + super().__init__(parent) + Application.getInstance().engineCreatedSignal.connect(self._engineCreated) + + def _engineCreated(self): + menu_component_path = os.path.join(PluginRegistry.getInstance().getPluginPath("PrepareStage"), "PrepareMenu.qml") + main_component_path = os.path.join(PluginRegistry.getInstance().getPluginPath("PrepareStage"), "PrepareMain.qml") + self.addDisplayComponent("menu", menu_component_path) self.addDisplayComponent("main", main_component_path) \ No newline at end of file diff --git a/plugins/PreviewStage/PreviewStage.py b/plugins/PreviewStage/PreviewStage.py index 1c487c8340..deec8b4197 100644 --- a/plugins/PreviewStage/PreviewStage.py +++ b/plugins/PreviewStage/PreviewStage.py @@ -12,37 +12,45 @@ if TYPE_CHECKING: from UM.View.View import View -## Displays a preview of what you're about to print. -# -# The Python component of this stage just loads PreviewMain.qml for display -# when the stage is selected, and makes sure that it reverts to the previous -# view when the previous stage is activated. class PreviewStage(CuraStage): + """Displays a preview of what you're about to print. + + The Python component of this stage just loads PreviewMain.qml for display + when the stage is selected, and makes sure that it reverts to the previous + view when the previous stage is activated. + """ + def __init__(self, application: QtApplication, parent = None) -> None: super().__init__(parent) self._application = application self._application.engineCreatedSignal.connect(self._engineCreated) self._previously_active_view = None # type: Optional[View] - ## When selecting the stage, remember which was the previous view so that - # we can revert to that view when we go out of the stage later. def onStageSelected(self) -> None: + """When selecting the stage, remember which was the previous view so that + + we can revert to that view when we go out of the stage later. + """ self._previously_active_view = self._application.getController().getActiveView() - ## Called when going to a different stage (away from the Preview Stage). - # - # When going to a different stage, the view should be reverted to what it - # was before. Normally, that just reverts it to solid view. def onStageDeselected(self) -> None: + """Called when going to a different stage (away from the Preview Stage). + + When going to a different stage, the view should be reverted to what it + was before. Normally, that just reverts it to solid view. + """ + if self._previously_active_view is not None: self._application.getController().setActiveView(self._previously_active_view.getPluginId()) self._previously_active_view = None - ## Delayed load of the QML files. - # - # We need to make sure that the QML engine is running before we can load - # these. def _engineCreated(self) -> None: + """Delayed load of the QML files. + + We need to make sure that the QML engine is running before we can load + these. + """ + plugin_path = self._application.getPluginRegistry().getPluginPath(self.getPluginId()) if plugin_path is not None: menu_component_path = os.path.join(plugin_path, "PreviewMenu.qml") diff --git a/plugins/RemovableDriveOutputDevice/LinuxRemovableDrivePlugin.py b/plugins/RemovableDriveOutputDevice/LinuxRemovableDrivePlugin.py index cf889ebb12..3661bfa63c 100644 --- a/plugins/RemovableDriveOutputDevice/LinuxRemovableDrivePlugin.py +++ b/plugins/RemovableDriveOutputDevice/LinuxRemovableDrivePlugin.py @@ -10,12 +10,14 @@ import glob import os import subprocess -## Support for removable devices on Linux. -# -# TODO: This code uses the most basic interfaces for handling this. -# We should instead use UDisks2 to handle mount/unmount and hotplugging events. -# + class LinuxRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin): + """Support for removable devices on Linux. + + TODO: This code uses the most basic interfaces for handling this. + We should instead use UDisks2 to handle mount/unmount and hotplugging events. + """ + def checkRemovableDrives(self): drives = {} for volume in glob.glob("/media/*"): diff --git a/plugins/RemovableDriveOutputDevice/OSXRemovableDrivePlugin.py b/plugins/RemovableDriveOutputDevice/OSXRemovableDrivePlugin.py index 0d2c474e42..70e2107898 100644 --- a/plugins/RemovableDriveOutputDevice/OSXRemovableDrivePlugin.py +++ b/plugins/RemovableDriveOutputDevice/OSXRemovableDrivePlugin.py @@ -9,8 +9,10 @@ import os import plistlib -## Support for removable devices on Mac OSX + class OSXRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin): + """Support for removable devices on Mac OSX""" + def checkRemovableDrives(self): drives = {} p = subprocess.Popen(["system_profiler", "SPUSBDataType", "-xml"], stdout = subprocess.PIPE, stderr = subprocess.PIPE) diff --git a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py index c81e4a76bc..a4fe7309f7 100644 --- a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py +++ b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py @@ -28,17 +28,19 @@ class RemovableDriveOutputDevice(OutputDevice): self._writing = False self._stream = None - ## Request the specified nodes to be written to the removable drive. - # - # \param nodes A collection of scene nodes that should be written to the - # removable drive. - # \param file_name \type{string} A suggestion for the file name to write - # to. If none is provided, a file name will be made from the names of the - # meshes. - # \param limit_mimetypes Should we limit the available MIME types to the - # MIME types available to the currently active machine? - # def requestWrite(self, nodes, file_name = None, filter_by_machine = False, file_handler = None, **kwargs): + """Request the specified nodes to be written to the removable drive. + + :param nodes: A collection of scene nodes that should be written to the + removable drive. + :param file_name: :type{string} A suggestion for the file name to write to. + If none is provided, a file name will be made from the names of the + meshes. + :param limit_mimetypes: Should we limit the available MIME types to the + MIME types available to the currently active machine? + + """ + filter_by_machine = True # This plugin is intended to be used by machine (regardless of what it was told to do) if self._writing: raise OutputDeviceError.DeviceBusyError() @@ -106,14 +108,14 @@ class RemovableDriveOutputDevice(OutputDevice): Logger.log("e", "Operating system would not let us write to %s: %s", file_name, str(e)) raise OutputDeviceError.WriteRequestFailedError(catalog.i18nc("@info:status Don't translate the XML tags or !", "Could not save to {0}: {1}").format(file_name, str(e))) from e - ## Generate a file name automatically for the specified nodes to be saved - # in. - # - # The name generated will be the name of one of the nodes. Which node that - # is can not be guaranteed. - # - # \param nodes A collection of nodes for which to generate a file name. def _automaticFileName(self, nodes): + """Generate a file name automatically for the specified nodes to be saved in. + + The name generated will be the name of one of the nodes. Which node that + is can not be guaranteed. + + :param nodes: A collection of nodes for which to generate a file name. + """ for root in nodes: for child in BreadthFirstIterator(root): if child.getMeshData(): diff --git a/plugins/RemovableDriveOutputDevice/WindowsRemovableDrivePlugin.py b/plugins/RemovableDriveOutputDevice/WindowsRemovableDrivePlugin.py index 8a183c25f4..ddcabd7311 100644 --- a/plugins/RemovableDriveOutputDevice/WindowsRemovableDrivePlugin.py +++ b/plugins/RemovableDriveOutputDevice/WindowsRemovableDrivePlugin.py @@ -42,8 +42,9 @@ ctypes.windll.kernel32.DeviceIoControl.argtypes = [ #type: ignore ctypes.windll.kernel32.DeviceIoControl.restype = wintypes.BOOL #type: ignore -## Removable drive support for windows class WindowsRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin): + """Removable drive support for windows""" + def checkRemovableDrives(self): drives = {}