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

ENH: Adds FileDictMixin #347

Merged
merged 23 commits into from
Feb 11, 2025
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
removed separator
  • Loading branch information
VinzentRisch committed Oct 17, 2024
commit a9cc86367c0ba65bca0c67f658e9076483a2ea15
8 changes: 3 additions & 5 deletions q2_types/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _validate_mag_ids(


class FileDictMixin:
def file_dict(self, relative=False, suffixes=None, separator=None):
def file_dict(self, relative=False, suffixes=None):
"""
For per sample directories it returns a mapping of sample id to
another dictionary where keys represent the file name and values
Expand Down Expand Up @@ -177,7 +177,6 @@ def file_dict(self, relative=False, suffixes=None, separator=None):
relative=relative,
dir_format=self,
suffixes=suffixes,
separator=separator
)

ids[outer_id][inner_id] = str(file_path)
Expand All @@ -188,15 +187,14 @@ def file_dict(self, relative=False, suffixes=None, separator=None):
relative=relative,
dir_format=self,
suffixes=suffixes,
separator=separator
)

ids[inner_id] = str(file_path)

return dict(sorted(ids.items()))


def _process_path(path, relative, dir_format, suffixes, separator):
def _process_path(path, relative, dir_format, suffixes):
"""
This function processes the input file path to generate an absolute or
relative path string and the ID derived from the file name. The ID is
Expand Down Expand Up @@ -228,7 +226,7 @@ def _process_path(path, relative, dir_format, suffixes, separator):
if suffixes:
for suffix in suffixes:
if file_name.endswith(suffix):
_id = file_name[:-(len(suffix)+len(separator))]
_id = file_name[:-len(suffix)]
break

path_dict = (
Expand Down