Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cura/UI
diff options
context:
space:
mode:
authorRemco Burema <r.burema@ultimaker.com>2021-07-16 09:49:46 +0300
committerRemco Burema <r.burema@ultimaker.com>2021-07-16 09:49:46 +0300
commit6c08bbfc9d0c9d035a12f0f029215ce9024de329 (patch)
tree8adf0f8ffadc134b98d6d2335f7fa7d2ccf529a8 /cura/UI
parent88954922d4fbb6d64981842b4f5b71ddf5a31871 (diff)
parent6f6d8d0f93927a202d81100cc203364f0aa01314 (diff)
Merge branch 'master' into libArachne_rebased
Diffstat (limited to 'cura/UI')
-rw-r--r--cura/UI/TextManager.py53
1 files changed, 29 insertions, 24 deletions
diff --git a/cura/UI/TextManager.py b/cura/UI/TextManager.py
index 99c1a55d46..77dadae809 100644
--- a/cura/UI/TextManager.py
+++ b/cura/UI/TextManager.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Ultimaker B.V.
+# Copyright (c) 2021 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import collections
@@ -6,9 +6,11 @@ from typing import Optional, Dict, List, cast
from PyQt5.QtCore import QObject, pyqtSlot
+from UM.i18n import i18nCatalog
from UM.Resources import Resources
from UM.Version import Version
+catalog = i18nCatalog("cura")
#
# This manager provides means to load texts to QML.
@@ -30,32 +32,35 @@ class TextManager(QObject):
# Load change log texts and organize them with a dict
try:
file_path = Resources.getPath(Resources.Texts, "change_log.txt")
- except FileNotFoundError:
+ except FileNotFoundError as e:
# I have no idea how / when this happens, but we're getting crash reports about it.
- return ""
+ return catalog.i18nc("@text:window", "The release notes could not be opened.") + "<br>" + str(e)
change_logs_dict = {} # type: Dict[Version, Dict[str, List[str]]]
- with open(file_path, "r", encoding = "utf-8") as f:
- open_version = None # type: Optional[Version]
- open_header = "" # Initialise to an empty header in case there is no "*" in the first line of the changelog
- for line in f:
- line = line.replace("\n", "")
- if "[" in line and "]" in line:
- line = line.replace("[", "")
- line = line.replace("]", "")
- open_version = Version(line)
- if open_version < Version([0, 0, 1]): # Something went wrong with parsing, assume non-numerical alternate version that should be on top.
- open_version = Version([99, 99, 99])
- if Version([14, 99, 99]) < open_version < Version([16, 0, 0]): # Bit of a hack: We released the 15.x.x versions before 2.x
- open_version = Version([0, open_version.getMinor(), open_version.getRevision(), open_version.getPostfixVersion()])
- open_header = ""
- change_logs_dict[open_version] = collections.OrderedDict()
- elif line.startswith("*"):
- open_header = line.replace("*", "")
- change_logs_dict[cast(Version, open_version)][open_header] = []
- elif line != "":
- if open_header not in change_logs_dict[cast(Version, open_version)]:
+ try:
+ with open(file_path, "r", encoding = "utf-8") as f:
+ open_version = None # type: Optional[Version]
+ open_header = "" # Initialise to an empty header in case there is no "*" in the first line of the changelog
+ for line in f:
+ line = line.replace("\n", "")
+ if "[" in line and "]" in line:
+ line = line.replace("[", "")
+ line = line.replace("]", "")
+ open_version = Version(line)
+ if open_version < Version([0, 0, 1]): # Something went wrong with parsing, assume non-numerical alternate version that should be on top.
+ open_version = Version([99, 99, 99])
+ if Version([14, 99, 99]) < open_version < Version([16, 0, 0]): # Bit of a hack: We released the 15.x.x versions before 2.x
+ open_version = Version([0, open_version.getMinor(), open_version.getRevision(), open_version.getPostfixVersion()])
+ open_header = ""
+ change_logs_dict[open_version] = collections.OrderedDict()
+ elif line.startswith("*"):
+ open_header = line.replace("*", "")
change_logs_dict[cast(Version, open_version)][open_header] = []
- change_logs_dict[cast(Version, open_version)][open_header].append(line)
+ elif line != "":
+ if open_header not in change_logs_dict[cast(Version, open_version)]:
+ change_logs_dict[cast(Version, open_version)][open_header] = []
+ change_logs_dict[cast(Version, open_version)][open_header].append(line)
+ except EnvironmentError as e:
+ return catalog.i18nc("@text:window", "The release notes could not be opened.") + "<br>" + str(e)
# Format changelog text
content = ""