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

Add a shortcut for removing file(s) by name #159

Merged
merged 3 commits into from
Jan 19, 2024
Merged

Conversation

liamhuber
Copy link
Member

Introduces the following convenience method to DirectoryObject:

    def remove(self, *files: str):
        for file in files:
            path = self.get_path(file)
            if path.is_file():
                path.unlink()

@liamhuber liamhuber requested a review from samwaseda January 10, 2024 21:33
Copy link

Binder 👈 Launch a binder notebook on branch pyiron/pyiron_workflow/remove_file_method

Copy link

codacy-production bot commented Jan 10, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.03% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (35b6d77) 2572 2195 85.34%
Head commit (33fad04) 2577 (+5) 2200 (+5) 85.37% (+0.03%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#159) 5 5 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

@samwaseda
Copy link
Member

Actually I don't really get the intention of this PR. I think by default people should delete the file from FileObject and not from the directory (except when all files should be erased)

@liamhuber
Copy link
Member Author

Wouldn't that involve importing FoleObject and creating N of these based on the strings used in this shortcut and the DirectoryObject? This isn't horrid, I just wanted something even shorter. You can see the use in Node.__post__ over in the storage PR

Base automatically changed from move_files_module to registration_by_identifier_alone January 15, 2024 21:13
Base automatically changed from registration_by_identifier_alone to main January 15, 2024 21:23
Copy link

Pull Request Test Coverage Report for Build 7534218211

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 90.288%

Totals Coverage Status
Change from base Build 7534135240: 0.02%
Covered Lines: 4676
Relevant Lines: 5179

💛 - Coveralls

@liamhuber
Copy link
Member Author

@samwaseda if, on reflection, you think this is useful, feel free to merge it. However, I came around to your perspective that importing and instantiating a FileObject is also perfectly acceptable, and in my case (since I have only the one file I care about and already import DirectoryObject) not particularly more work. I've dropped it from the history of #160 and don't depend on it.

So if you still dislike it, just close the PR; I still don't hate it, but am quite indifferent now.

@samwaseda samwaseda merged commit 160b848 into main Jan 19, 2024
16 checks passed
@samwaseda samwaseda deleted the remove_file_method branch January 19, 2024 09:31
@samwaseda
Copy link
Member

Still not really sure about this one, but I also don't feel strongly against it, so I merged it :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants