Coder Social home page Coder Social logo

Comments (9)

cpburnz avatar cpburnz commented on August 17, 2024

@ftrofin

For (1) it would be straight forward for me to implement a version of match_tree()/match_files() that returns addition information such as which pattern a file or directory was matched with.

For (2) what you're trying to do makes sense. I'll have to evaluate the current code to determine the feasibility of the feature. Currently the patterns are converted to regular expressions and those are matched against the file paths without capturing the matching part.

from python-pathspec.

ftrofin avatar ftrofin commented on August 17, 2024

Thank you so much for the prompt response and for the great news! (too many times I've heard "sorry, we can't do that"). Let me know if I can help in any way.

from python-pathspec.

ftrofin avatar ftrofin commented on August 17, 2024

@cpburnz Hi Caleb, any update on this?

from python-pathspec.

cpburnz avatar cpburnz commented on August 17, 2024

@ftrofin I have a work-in-progress that I should be able to complete this weekend.

from python-pathspec.

cpburnz avatar cpburnz commented on August 17, 2024

@ftrofin

I've made to the master branch that will at least support (1).

I'm not currently sure how to implement the feature for (2). Even if I added passing through the regex match result, the gitwildmatch format would escape any regex capturing groups. So the only way to use this potential feature would be to construct RegexPattern objects directly.

from python-pathspec.

ftrofin avatar ftrofin commented on August 17, 2024

Thank you Caleb for taking the time to address this. Can you please make a git release or bump the version and upload to pypi these changes so I can test them? I might have an idea on how to implement 2. If 1 is working now it means that now I know which pattern matched which SpecEntry (the left side) right? So maybe I could just re-apply the regex used during matching (if I could get it somehow) to that particular entry and get the capturing groups...
I'll have to think more about it.

from python-pathspec.

ftrofin avatar ftrofin commented on August 17, 2024

@cpburnz Looking at the new code I don't see the util.detailed_match_files() being used anywhere...Is this still work in progress?

from python-pathspec.

cpburnz avatar cpburnz commented on August 17, 2024

@ftrofin That function is not being used elsewhere yet. I'm not sure if I'm completely satisfied with its implementation so I would consider it a work in progress. That's why I haven't made a proper release uploaded to PyPI.

Yes, (1) is working now but it's only in that utility function at present.

from python-pathspec.

cpburnz avatar cpburnz commented on August 17, 2024

v0.8.0 has been released. The detailed_match_files() is still only a utility function. I've been delaying too long and might as well release what's available. The way you would use it is:

patterns = ...
files = pathspec.util.iter_tree_files(...) # Or your own file list.
matches = pathspec.util.detailed_match_files(patterns, files)

See:

from python-pathspec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.