mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
Type-checks, not just type comments, and static- over class-method.
CURA-8014
This commit is contained in:
parent
98ed2bc8b6
commit
f95c09db37
@ -19,9 +19,9 @@ class WhatsNewPagesModel(WelcomePagesModel):
|
|||||||
image_key = "image"
|
image_key = "image"
|
||||||
text_key = "text"
|
text_key = "text"
|
||||||
|
|
||||||
@classmethod
|
@staticmethod
|
||||||
def _collectOrdinalFiles(cls, resource_type: int, include: List[str]) -> Tuple[Dict[int, str], int]:
|
def _collectOrdinalFiles(resource_type: int, include: List[str]) -> Tuple[Dict[int, str], int]:
|
||||||
result = {} # Dict[int, str]
|
result = {} #type: Dict[int, str]
|
||||||
highest = -1
|
highest = -1
|
||||||
try:
|
try:
|
||||||
folder_path = Resources.getPath(resource_type, "whats_new")
|
folder_path = Resources.getPath(resource_type, "whats_new")
|
||||||
@ -38,8 +38,8 @@ class WhatsNewPagesModel(WelcomePagesModel):
|
|||||||
Logger.logException("w", "Could not find 'whats_new' folder for resource-type {0}".format(resource_type))
|
Logger.logException("w", "Could not find 'whats_new' folder for resource-type {0}".format(resource_type))
|
||||||
return result, highest
|
return result, highest
|
||||||
|
|
||||||
@classmethod
|
@staticmethod
|
||||||
def _loadText(cls, filename: str) -> str:
|
def _loadText(filename: str) -> str:
|
||||||
result = ""
|
result = ""
|
||||||
try:
|
try:
|
||||||
with open(filename, "r", encoding="utf-8") as file:
|
with open(filename, "r", encoding="utf-8") as file:
|
||||||
@ -65,7 +65,7 @@ class WhatsNewPagesModel(WelcomePagesModel):
|
|||||||
texts, max_text = WhatsNewPagesModel._collectOrdinalFiles(Resources.Texts, WhatsNewPagesModel.text_formats)
|
texts, max_text = WhatsNewPagesModel._collectOrdinalFiles(Resources.Texts, WhatsNewPagesModel.text_formats)
|
||||||
highest = max(max_image, max_text)
|
highest = max(max_image, max_text)
|
||||||
|
|
||||||
self._subpages = [] # List[Dict[str, str]]
|
self._subpages = [] #type: List[Dict[str, str]]
|
||||||
for n in range(0, highest + 1):
|
for n in range(0, highest + 1):
|
||||||
self._subpages.append({
|
self._subpages.append({
|
||||||
WhatsNewPagesModel.image_key: None if n not in images else images[n],
|
WhatsNewPagesModel.image_key: None if n not in images else images[n],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user