CURA-4891

Scan for 'ultimaker' in the name. If found, add 'UM' to abbreviation, and scan again for a number after 'ultimaker' (e.g. 'ultimaker3'). If found, add the number as well. If 'ultimaker' is not found, take either the first 4 letters of the name or first letter.
This commit is contained in:
Ian Paschal 2018-02-12 14:58:55 +01:00
parent 714c0d09b7
commit 2964bedc28

View File

@ -364,18 +364,23 @@ class PrintInformation(QObject):
active_machine_type_id = global_container_stack.definition.getId() active_machine_type_id = global_container_stack.definition.getId()
abbr_machine = "" abbr_machine = ""
for word in re.findall(r"[\w']+", active_machine_type_id): # If 'ultimaker' is in machine type, we found an ultimaker machine!
if word.lower() == "ultimaker": if re.findall(r"\W*(ultimaker)\W*", active_machine_type_id):
abbr_machine += "UM" abbr_machine += "UM"
elif word.isdigit(): # In this case, also scan for an edition (e.g. 'ultimaker3')
abbr_machine += word edition = re.findall(r"\W*ultimaker([0-9])*\W*", active_machine_type_id)
if edition:
abbr_machine += edition[0]
# Otherwise, just use the first 3 letters of the machine:
else: else:
stripped_word = self._stripAccents(word.upper()) stripped_name = self._stripAccents(active_machine_type_id.upper())
# - use only the first character if the word is too long (> 3 characters) print("WAS ANOTHER TYPE", stripped_name)
# - use the whole word if it's not too long (<= 3 characters) # - use only the first character if the word is too long (> 4 characters)
if len(stripped_word) > 3: # - use the whole word if it's not too long (<= 4 characters)
stripped_word = stripped_word[0] if len(stripped_name) > 4:
abbr_machine += stripped_word stripped_name = stripped_name[0]
abbr_machine += stripped_name
self._abbr_machine = abbr_machine self._abbr_machine = abbr_machine