Document _uniqueName

This function should really just be moved to ContainerRegistry... I'll do that later.

Contributes to issues CURA-340 and CURA-1278.
This commit is contained in:
Ghostkeeper 2016-06-07 11:55:07 +02:00
parent dff94b4559
commit 66bf0831f3
No known key found for this signature in database
GPG Key ID: 701948C5954A7385

View File

@ -176,7 +176,14 @@ class ExtruderManager(QObject):
container_registry.addContainer(container_stack)
## Creates a new unique name for a container that doesn't exist yet.
#
# It tries if the original name you provide exists, and if it doesn't
# it'll add a " #1" or " #2" after the name to make it unique.
#
# \param original The original name that may not be unique.
# \return A unique name that looks a lot like the original but may have
# a number behind it to make it unique.
def _uniqueName(self, original):
container_registry = UM.Settings.ContainerRegistry.getInstance()
@ -189,8 +196,7 @@ class ExtruderManager(QObject):
unique_name = name
i = 1
while container_registry.findContainers(id=unique_name) or container_registry.findContainers(
name=unique_name): # A container already has this name.
while container_registry.findContainers(id = unique_name) or container_registry.findContainers(name = unique_name): # A container already has this name.
i += 1 # Try next numbering.
unique_name = "%s #%d" % (name, i) # Fill name like this: "Extruder #2".
return unique_name