mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Move automatic file name generating to separate function
This will make it easier to have multiple nodes here in the future. I'll have to modify this function for that, but I'll do that in a separate commit. Contributes to issue CURA-2617.
This commit is contained in:
parent
e2d32ef963
commit
b3e3053323
1 changed files with 16 additions and 9 deletions
|
@ -50,15 +50,7 @@ class RemovableDriveOutputDevice(OutputDevice):
|
|||
extension = file_formats[0]["extension"]
|
||||
|
||||
if file_name is None:
|
||||
for n in BreadthFirstIterator(node):
|
||||
if n.getMeshData():
|
||||
file_name = n.getName()
|
||||
if file_name:
|
||||
break
|
||||
|
||||
if not file_name:
|
||||
Logger.log("e", "Could not determine a proper file name when trying to write to %s, aborting", self.getName())
|
||||
raise OutputDeviceError.WriteRequestFailedError()
|
||||
file_name = self._automaticFileName(node)
|
||||
|
||||
if extension: # Not empty string.
|
||||
extension = "." + extension
|
||||
|
@ -88,6 +80,21 @@ 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", "Could not save to <filename>{0}</filename>: <message>{1}</message>").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 root A node for which to generate a file name.
|
||||
def _automaticFileName(self, root):
|
||||
for child in BreadthFirstIterator(root):
|
||||
if child.getMeshData():
|
||||
name = child.getName()
|
||||
if name:
|
||||
return name
|
||||
raise OutputDeviceError.WriteRequestFailedError("Could not find a file name when trying to write to {device}.".format(device = self.getName()))
|
||||
|
||||
def _onProgress(self, job, progress):
|
||||
if hasattr(job, "_message"):
|
||||
job._message.setProgress(progress)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue