mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 07:18:31 +01:00
dvc: add get_url()/open() API
As a part of this: - DataCloud._cloud was refactored into `.get_remote()` - data stopped using internal _cloud - added a parametrization for remote tests
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
from dvc.repo import Repo
|
||||
|
||||
|
||||
def get_url(path, repo_dir=None, remote=None):
|
||||
"""Returns an url of `path` in default or specified remote"""
|
||||
repo = Repo(repo_dir)
|
||||
out, = repo.find_outs_by_path(path)
|
||||
remote_obj = repo.cloud.get_remote(remote)
|
||||
return str(remote_obj.checksum_to_path_info(out.checksum))
|
||||
|
||||
|
||||
def open(path, repo_dir=None, remote=None, mode="r", encoding=None):
|
||||
"""Opens a specified resource as a file descriptor"""
|
||||
repo = Repo(repo_dir)
|
||||
return repo.open(path, remote=remote, mode=mode, encoding=encoding)
|
||||
Reference in New Issue
Block a user