Files
sunnypilot/tools/lib/filereader.py
Greg Hogan e0469bdde6 filereader cleanup (#30191)
* filereader cleanup

* make name return url

* remove unused imports
old-commit-hash: 86b90a8ba2
2023-10-05 19:45:46 -07:00

16 lines
409 B
Python

import os
from openpilot.tools.lib.url_file import URLFile
DATA_ENDPOINT = os.getenv("DATA_ENDPOINT", "http://data-raw.comma.internal/")
def resolve_name(fn):
if fn.startswith("cd:/"):
return fn.replace("cd:/", DATA_ENDPOINT)
return fn
def FileReader(fn, debug=False):
fn = resolve_name(fn)
if fn.startswith(("http://", "https://")):
return URLFile(fn, debug=debug)
return open(fn, "rb")