From d5b3f18da8b96bc46779abb8d04f6a85a024780e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 18 Dec 2017 11:00:55 +0100 Subject: [PATCH] Split all non-word characters for making abbreviations So now cases like CR-10 are more appropriately split into ['CR', '10']. Fixes #2910. --- cura/PrintInformation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index ca5433f305..5e64413d27 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -16,6 +16,7 @@ import math import os.path import unicodedata import json +import re #To create abbreviations for printer names. from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") @@ -316,15 +317,14 @@ class PrintInformation(QObject): return global_stack_name = global_container_stack.getName() - split_name = global_stack_name.split(" ") abbr_machine = "" - for word in split_name: + for word in re.findall(r"[\w']+", global_stack_name): if word.lower() == "ultimaker": abbr_machine += "UM" elif word.isdigit(): abbr_machine += word 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 the whole word if it's not too long (<= 3 characters) if len(stripped_word) > 3: