Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
refactor: minor changes - remove redundant imports, change var names
Browse files Browse the repository at this point in the history
  • Loading branch information
seesmof committed Dec 22, 2023
1 parent ca39c64 commit 5e43337
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/util/utils.py
Original file line number Diff line number Diff line change
@@ -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 *
Expand Down Expand Up @@ -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")
Expand All @@ -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))

0 comments on commit 5e43337

Please sign in to comment.