filereader cleanup (#30191)

* filereader cleanup

* make name return url

* remove unused imports
old-commit-hash: 86b90a8ba263df067406e0089eb507c3a397640e
This commit is contained in:
Greg Hogan
2023-10-05 19:45:46 -07:00
committed by GitHub
parent 29bb2cf867
commit e0469bdde6
3 changed files with 16 additions and 31 deletions
+6 -2
View File
@@ -3,9 +3,13 @@ from openpilot.tools.lib.url_file import URLFile
DATA_ENDPOINT = os.getenv("DATA_ENDPOINT", "http://data-raw.comma.internal/")
def FileReader(fn, debug=False):
def resolve_name(fn):
if fn.startswith("cd:/"):
fn = fn.replace("cd:/", DATA_ENDPOINT)
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")