1
0
mirror of https://github.com/yt-dlp/yt-dlp synced 2025-12-18 07:05:41 +07:00

[cleanup] Misc cleanup and refactor (#2173)

This commit is contained in:
pukkandan
2022-04-18 02:28:28 +05:30
parent b6dc37fe2a
commit 19a0394044
31 changed files with 263 additions and 345 deletions

View File

@@ -1,3 +1,4 @@
import contextlib
import errno
import json
import os
@@ -57,7 +58,7 @@ def load(self, section, key, dtype='json', default=None):
return default
cache_fn = self._get_cache_fn(section, key, dtype)
try:
with contextlib.suppress(OSError):
try:
with open(cache_fn, encoding='utf-8') as cachef:
self._ydl.write_debug(f'Loading {section}.{key} from cache')
@@ -68,8 +69,6 @@ def load(self, section, key, dtype='json', default=None):
except OSError as oe:
file_size = str(oe)
self._ydl.report_warning(f'Cache retrieval from {cache_fn} failed ({file_size})')
except OSError:
pass # No cache available
return default