From 4236017ef80fb8fdf79bcbc7fe83dee0f58619c6 Mon Sep 17 00:00:00 2001 From: monosans Date: Fri, 6 Oct 2023 17:42:42 +0300 Subject: [PATCH] Avoid using f.readlines() --- api/db/providerkeys.py | 2 +- api/providers/__main__.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/api/db/providerkeys.py b/api/db/providerkeys.py index a75b95f..4902d80 100644 --- a/api/db/providerkeys.py +++ b/api/db/providerkeys.py @@ -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 diff --git a/api/providers/__main__.py b/api/providers/__main__.py index f61bb47..71b586f 100644 --- a/api/providers/__main__.py +++ b/api/providers/__main__.py @@ -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)