From 5e43337a1732c2330532b7a99e1860bd2679f5bf Mon Sep 17 00:00:00 2001 From: Oleh Onyshchenko <110289150+seesmof@users.noreply.github.com> Date: Fri, 22 Dec 2023 17:28:15 +0200 Subject: [PATCH] refactor: minor changes - remove redundant imports, change var names --- src/util/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/util/utils.py b/src/util/utils.py index b2a53db..f5438c7 100644 --- a/src/util/utils.py +++ b/src/util/utils.py @@ -1,6 +1,5 @@ from datetime import date from os import path -from pathlib import Path from string import punctuation from rich.console import Console from customtkinter import * @@ -57,7 +56,7 @@ def getCurrentMetrics(text: str) -> tuple[int, int, int, int]: def getTextFromFile() -> str: filePath = CTkInputDialog(text="Enter file path", title="Load Text").get_input() try: - with open(filePath, encoding="utf-8") as file: + with open(filePath, "r", encoding="utf-8") as file: textFromFile = file.read() except: console.log("Failed to read text from file") @@ -75,8 +74,8 @@ def generateFileName(text: str) -> str: def saveCurrentText(text: str) -> None: - text = [line.strip() for line in text.split("\n") if line.strip()] + lines = [line.strip() for line in text.split("\n") if line.strip()] currentDir = path.dirname(path.abspath(__file__)) dataFile = path.join(currentDir, "..", "..", "data", "latest.md") with open(dataFile, "w", encoding="utf-8") as f: - f.write("\n".join(text)) + f.write("\n".join(lines))