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

Recursively search directory tree for requirement files based on some unix-stlye glob pattern #9

Open
zacharymostowsky opened this issue Aug 27, 2021 · 6 comments

Comments

@zacharymostowsky
Copy link

Hello,

Thanks a bunch for this library. I have a use case where there are many requirements.txt (and requirements-devel.txt) in my repo. I was was wondering if you would be open to functionality for recursively searching a directory tree, finding the files that match the glob, and then do the checks on those?

Thanks,
Zach

@rehandalal
Copy link
Owner

Hi! Thanks for the suggestion. I think this is generally better handled by your terminals own globbing. What shell/OS are you running?

Would something like this work?:

sort-requirements requirements/**/requirements*.txt

@zacharymostowsky
Copy link
Author

Hey thanks for the quick response. I am using bash shell on a mixture of ubuntu and Windows (use Git Bash in Windows). We can certainly use find or another utility to glob on command line and that works well for a CI pipeline or some other script. But, I was hoping to make life a little easier for developers where the functionality would work in a manner similar to pylama and black. These tools recursively search a given path for python files. I thought we could do something similar where by default the tool searches for *requirements.txt but a user could override to provide any glob you want essentially.

@zacharymostowsky
Copy link
Author

zacharymostowsky commented Aug 27, 2021

This worked for me btw, in case others are interested.

find . -iname 'requirements*.txt' -exec sort-requirements {} +

@rehandalal
Copy link
Owner

Let me take some time to explore how black and pylama handle this. I assume they use something like --include and --exclude options to specify pattern matching?

I think I want to come up with a spec that feels consistent with out Python CLI tools so that the functionality is more intuitive.

My other concern is making sure I can do this easily in Python without adding dependencies. My goal with this tool was to have it be free from dependence on other libraries. I think Python's built-in glob should work but I need to poke around and find out for certain.

@rehandalal
Copy link
Owner

In the meanwhile (and at the risk of shameless self promotion) another solution that could give your developers a more consistent easy interface is to use this tool my other project: https://github.com/rehandalal/therapist

@zacharymostowsky
Copy link
Author

zacharymostowsky commented Aug 30, 2021

Thanks, @rehandalal. I will check out therapist as well. If you didn't want to change the default functionality of sort-requirements, maybe just an optional flag you can provide a , separated list of globs to or something like that. Agreed about dependencies. I think the glob module would work fine for this.

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

No branches or pull requests

2 participants