mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-20 01:13:56 +08:00
version: dragonpilot v0.8.16 beta for EON/C2 date: 2022-08-11T09:38:43 dp-dev(priv2) master commit: c6cd233f23f60e7a6055d42850bc593c0e69082e
16 lines
507 B
Python
16 lines
507 B
Python
import os
|
|
import urllib.parse
|
|
from 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)
|