Coder Social home page Coder Social logo

Comments (3)

cpburnz avatar cpburnz commented on July 18, 2024

Can you provide an example file tree, and the results that differ from what you expect? My example below works for me. Perhaps there's an edge case I'm missing.


Say you have the following file tree:

a.log
b.txt
important
important/d.log
important/e.txt
trace.c

And match against that using:

import pathspec

spec = pathspec.PathSpec.from_lines('gitwildmatch', """
*.log
!important/*.log
trace.*
""".splitlines())

matched_files = set(spec.match_tree_files("."))
for path in matched_files:
    print(path)

That will output:

a.log
trace.c

If you remove those matched files against the whole tree:

import pathspec.util

all_files = set(pathspec.util.iter_tree_files("."))
for path in all_files - matched_files:
    print(path)

That will finally output:

b.txt
important/d.log
important/e.txt

I think that matches the desired behavior of the ".gitignore" file you described.

from python-pathspec.

cpburnz avatar cpburnz commented on July 18, 2024

@darrenhaken Are you still having this problem?

from python-pathspec.

cpburnz avatar cpburnz commented on July 18, 2024

I'm closing this due to lack of feedback about the issue.

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.