Split all non-word characters for making abbreviations

So now cases like CR-10 are more appropriately split into ['CR', '10'].

Fixes #2910.
This commit is contained in:
Ghostkeeper 2017-12-18 11:00:55 +01:00
parent 443e155cf7
commit d5b3f18da8
No known key found for this signature in database
GPG Key ID: 5252B696FB5E7C7A

View File

@ -16,6 +16,7 @@ import math
import os.path import os.path
import unicodedata import unicodedata
import json import json
import re #To create abbreviations for printer names.
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura") catalog = i18nCatalog("cura")
@ -316,15 +317,14 @@ class PrintInformation(QObject):
return return
global_stack_name = global_container_stack.getName() global_stack_name = global_container_stack.getName()
split_name = global_stack_name.split(" ")
abbr_machine = "" abbr_machine = ""
for word in split_name: for word in re.findall(r"[\w']+", global_stack_name):
if word.lower() == "ultimaker": if word.lower() == "ultimaker":
abbr_machine += "UM" abbr_machine += "UM"
elif word.isdigit(): elif word.isdigit():
abbr_machine += word abbr_machine += word
else: else:
stripped_word = self._stripAccents(word.strip("()[]{}#").upper()) stripped_word = self._stripAccents(word.upper())
# - use only the first character if the word is too long (> 3 characters) # - use only the first character if the word is too long (> 3 characters)
# - use the whole word if it's not too long (<= 3 characters) # - use the whole word if it's not too long (<= 3 characters)
if len(stripped_word) > 3: if len(stripped_word) > 3: