mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-19 03:37:29 +08:00
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:
parent
443e155cf7
commit
d5b3f18da8
@ -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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user