mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-19 20:33:54 +08:00
version: lp-dp v0.9.5 for EON/C2 date: 2023-09-13T13:36:48 commit: 1d59b81c40b93f37d4a341c5d35b1c3cd293543d
16 lines
517 B
Python
16 lines
517 B
Python
import os
|
|
import urllib.parse
|
|
from openpilot.common.file_helpers import mkdirs_exists_ok
|
|
|
|
DEFAULT_CACHE_DIR = os.path.expanduser("~/.commacache")
|
|
|
|
def cache_path_for_file_path(fn, cache_prefix=None):
|
|
dir_ = os.path.join(DEFAULT_CACHE_DIR, "local")
|
|
mkdirs_exists_ok(dir_)
|
|
fn_parsed = urllib.parse.urlparse(fn)
|
|
if fn_parsed.scheme == '':
|
|
cache_fn = os.path.abspath(fn).replace("/", "_")
|
|
else:
|
|
cache_fn = f'{fn_parsed.hostname}_{fn_parsed.path.replace("/", "_")}'
|
|
return os.path.join(dir_, cache_fn)
|