Avoid using f.readlines()

This commit is contained in:
monosans 2023-10-06 17:42:42 +03:00
parent 1a858cd47d
commit 4236017ef8
No known key found for this signature in database
2 changed files with 2 additions and 4 deletions

View file

@ -65,7 +65,7 @@ class KeyManager:
for filename in await aiofiles.os.listdir(os.path.join('api', 'secret')):
if filename.endswith('.txt'):
async with aiofiles.open(os.path.join('api', 'secret', 'filename')) as f:
for line in await f.readlines():
async for line in f:
if not line.strip():
continue

View file

@ -5,9 +5,7 @@ from rich import print
def remove_duplicate_keys(file):
with open(file, 'r', encoding='utf8') as f:
lines = f.readlines()
unique_lines = set(lines)
unique_lines = set(f)
with open(file, 'w', encoding='utf8') as f:
f.writelines(unique_lines)