30 lines
834 B
Python
30 lines
834 B
Python
from pathlib import Path
|
|
from typing import List
|
|
|
|
|
|
def scan_auth_tokens_directory(dir_path: str):
|
|
path = Path(dir_path).expanduser().resolve()
|
|
|
|
if not path.exists():
|
|
path = Path.cwd() / dir_path
|
|
if not path.exists():
|
|
raise FileNotFoundError(f"Path not found: {dir_path}")
|
|
|
|
if path.is_file():
|
|
return [path]
|
|
|
|
token_files = list(path.glob('*.txt'))
|
|
return sorted(token_files)
|
|
|
|
|
|
def read_auth_tokens_from_file(file_path: Path) -> List[tuple]:
|
|
try:
|
|
content = file_path.read_text(encoding='utf-8').strip()
|
|
tokens = []
|
|
for line_num, line in enumerate(content.split('\n'), start=1):
|
|
line = line.strip()
|
|
if line:
|
|
tokens.append((line_num, line))
|
|
return tokens
|
|
except Exception:
|
|
return []
|