chg: cleanup get_user_agents

Related: #262
pull/263/head
Raphaël Vinot 2021-09-13 22:31:58 +02:00
parent 258ccde937
commit d6982392ef
1 changed files with 2 additions and 4 deletions

View File

@ -7,7 +7,6 @@ import pickle
from datetime import datetime, timedelta from datetime import datetime, timedelta
from enum import IntEnum, unique from enum import IntEnum, unique
from functools import lru_cache from functools import lru_cache
from glob import glob
from io import BufferedIOBase from io import BufferedIOBase
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Optional, Set, Tuple, Union from typing import Any, Dict, List, Optional, Set, Tuple, Union
@ -167,9 +166,8 @@ def get_socket_path(name: str) -> str:
def get_user_agents(directory: str='user_agents') -> Dict[str, Any]: def get_user_agents(directory: str='user_agents') -> Dict[str, Any]:
ua_files_path = str(get_homedir() / directory / '*' / '*' / '*.json') ua_files_path = sorted((get_homedir() / directory).glob('**/*.json'), reverse=True)
paths = sorted(glob(ua_files_path), reverse=True) with ua_files_path[0].open() as f:
with open(paths[0]) as f:
return json.load(f) return json.load(f)