Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve usability of Directory datatype #17614

Merged
merged 17 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Drop root_folder metadata from Directory datatype
This should probably go in sub-classes that expect specific directory structures.
davelopez committed Oct 30, 2024

Verified

This commit was signed with the committer’s verified signature.
davelopez David López
commit 5530e154c031bf1217f00f26d6a14cdf840b173a
24 changes: 1 addition & 23 deletions lib/galaxy/datatypes/data.py
Original file line number Diff line number Diff line change
@@ -1217,31 +1217,9 @@ class Directory(Data):
# The behavior of this class is intended to be similar to that of
davelopez marked this conversation as resolved.
Show resolved Hide resolved
# composite types, but with arbitrary structure of extra_files.

# Directories converted from archives, and possibly others, have a single
# root folder inside the directory. The root_folder attribute lets tools
# access that folder without first exploring the directory tree themselves.
# Will be set to the empty string for flat directories.
MetadataElement(
name="root_folder",
default=None,
desc="Name of the root folder of the directory",
readonly=True,
optional=False,
visible=False,
)

def set_meta(self, dataset: DatasetProtocol, **kwd):
efp = dataset.extra_files_path
efp_items = os.listdir(efp)
root_folder_name = efp_items[0]
if len(efp_items) == 1 and os.path.isdir(os.path.join(efp, root_folder_name)):
dataset.metadata.root_folder = root_folder_name
else:
dataset.metadata.root_folder = ""

def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
if not dataset.dataset.purged:
dataset.peek = f"{dataset.metadata.root_folder}"
dataset.peek = f"{dataset.extra_files_path}"
davelopez marked this conversation as resolved.
Show resolved Hide resolved
dataset.blurb = nice_size(dataset.dataset.total_size)
else:
dataset.peek = "file does not exist"