use 'with open' for files
This commit is contained in:
parent
61e25061ab
commit
6bd2ac4f0a
@ -82,15 +82,13 @@ class Nicole:
|
|||||||
def _write_history(self):
|
def _write_history(self):
|
||||||
config_path = path.expanduser("~") + "/.config/nicole/"
|
config_path = path.expanduser("~") + "/.config/nicole/"
|
||||||
|
|
||||||
history_file = open(config_path + "history", "w")
|
with open(config_path + "history", "w") as history_file:
|
||||||
for file in self.history:
|
for file in self.history:
|
||||||
history_file.write(file + "\n")
|
history_file.write(file + "\n")
|
||||||
history_file.close()
|
|
||||||
|
|
||||||
failed_file = open(config_path + "failed", "w")
|
with open(config_path + "failed", "w") as failed_file:
|
||||||
for file in self.failed:
|
for file in self.failed:
|
||||||
failed_file.write(file + "\n")
|
failed_file.write(file + "\n")
|
||||||
failed_file.close()
|
|
||||||
|
|
||||||
def get_urls_azlyrics(self, artist:str, title:str):
|
def get_urls_azlyrics(self, artist:str, title:str):
|
||||||
"""
|
"""
|
||||||
@ -314,6 +312,8 @@ class Nicole:
|
|||||||
else:
|
else:
|
||||||
print(f"✕ {entry}")
|
print(f"✕ {entry}")
|
||||||
print(" " + message)
|
print(" " + message)
|
||||||
|
print("History\n", self.history)
|
||||||
|
print("Failed\n", self.failed)
|
||||||
|
|
||||||
|
|
||||||
elif path.isdir(entry) and self.recursive:
|
elif path.isdir(entry) and self.recursive:
|
||||||
@ -420,10 +420,6 @@ class Nicole:
|
|||||||
else:
|
else:
|
||||||
return (False, f"Could find lyrics but failed to write the tag.")
|
return (False, f"Could find lyrics but failed to write the tag.")
|
||||||
|
|
||||||
# add to history
|
|
||||||
if self.write_history and file not in self.history:
|
|
||||||
self.history.append(file)
|
|
||||||
|
|
||||||
message += f"Written lyrics from {site} to {artist} - {title}"
|
message += f"Written lyrics from {site} to {artist} - {title}"
|
||||||
return (True, message)
|
return (True, message)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user