Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions solvebio/cli/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,21 +955,40 @@ def ls(args):


def _ls(full_path, recursive=False, follow_shortcuts=False):

if follow_shortcuts:
full_path = full_path[:-1] if full_path.endswith("*") else full_path

files = list(Object.all(glob=full_path, limit=1000))

for file_ in files:
if follow_shortcuts and file_.is_shortcut:
shortcut = file_.full_path
try:
resolved_file = file_.get_target()
print(
"{} {} {} from shortcut: {}".format(
resolved_file.last_modified,
resolved_file.object_type.ljust(8),
resolved_file.full_path.ljust(50),
shortcut
resolved_file_data = resolved_file[0] if isinstance(resolved_file, tuple) else resolved_file

if resolved_file_data['class_name'] == "Vault":
print(
"{} {} from shortcut: {}".format(
resolved_file_data.updated_at,
resolved_file_data.full_path.ljust(50),
shortcut
)
)
)
if recursive and resolved_file_data['class_name'] == "Vault":
_ls(resolved_file_data.full_path + "/*", recursive=True, follow_shortcuts=follow_shortcuts)
else:
print(
"{} {} {} from shortcut: {}".format(
resolved_file_data.last_modified,
resolved_file_data.object_type.ljust(8),
resolved_file_data.full_path.ljust(50),
shortcut
)
)
if recursive and resolved_file_data.object_type == "folder":
_ls(resolved_file_data.full_path + "/*", recursive=True, follow_shortcuts=follow_shortcuts)
except NotFoundError:
print(
"Shortcut {} could not be resolved: "
Expand All @@ -979,12 +998,12 @@ def _ls(full_path, recursive=False, follow_shortcuts=False):
resolved_file = file_
print(
"{} {} {}".format(
resolved_file.last_modified, resolved_file.object_type.ljust(8), resolved_file.full_path
resolved_file.last_modified,
resolved_file.object_type.ljust(8), resolved_file.full_path
)
)

if recursive and resolved_file.object_type == "folder":
_ls(resolved_file.full_path + "/*", recursive=True)
if recursive and resolved_file.object_type == "folder":
_ls(resolved_file.full_path + "/*", recursive=True)

return files

Expand Down