Coder Social home page Coder Social logo

Comments (8)

cpburnz avatar cpburnz commented on July 1, 2024

@029xue Try switching the order of your patterns to:

*.txt
!test1/

If you have !test1/ first, the files under that directory will be ignored first, but with *.txt following it will then re-include the .txt files within test1/.

A second possibility is that the Windows paths are not matching properly. Can you try just using:

!test1/

And let me know if that excludes the test1/ directory.

from python-pathspec.

wangxuepeng avatar wangxuepeng commented on July 1, 2024

Hi,
Thanks for the quick response.

I tested
*.txt
!test1/

and it shows no difference with

!test1/
*.txt

and, if just leave
!test1/

The result is empty, no any files is selected.

from python-pathspec.

cpburnz avatar cpburnz commented on July 1, 2024

The underlying issue is that Windows file paths are not being matched properly because Windows tends to use \ instead of / to separate directories. I will work on fix for this.

from python-pathspec.

wangxuepeng avatar wangxuepeng commented on July 1, 2024

Thanks very much, waiting your updates :)

from python-pathspec.

cpburnz avatar cpburnz commented on July 1, 2024

@029xue I made some changes, and with my testing it should work now. Please note that the order of your patterns should be:

*.txt
!test1/

To first include all *.txt files, and then to exclude the ones from the test1/ directory.

Also, spec.match_tree() and spec.match_files() now return an iterable instead of a set, so you'll have to convert it to a list or set manually. E.g.,

list(spec.match_tree('d:\dev\eclipse_workspace\test_scan'))

The changes are only reflected on Github right now. If my changes work for you, let me know and I'll update the version on PyPI.

from python-pathspec.

wangxuepeng avatar wangxuepeng commented on July 1, 2024

Thanks, works like charm now.

So the patterns are working like filters from up to down? or just the excludes need be put in the last?

from python-pathspec.

cpburnz avatar cpburnz commented on July 1, 2024

Yes, the filters work from up to down. The order is what really matters. This is so that you can include (or exclude) a large amount of files, but then further down you really want to include (or exclude) a specific directory or smaller set of files.

from python-pathspec.

wangxuepeng avatar wangxuepeng commented on July 1, 2024

That make sense, thanks very much for the good library :)

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.