Comments (8)
@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.
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.
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.
Thanks very much, waiting your updates :)
from python-pathspec.
@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.
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.
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.
That make sense, thanks very much for the good library :)
from python-pathspec.
Related Issues (20)
- `match_files()` is not a pure generator function, and it impacts `tree_*()` gravely HOT 1
- Symlink pathspec_meta.py breaks Windows HOT 1
- test_util.py uses os.symlink which can fail on Windows HOT 1
- Backslashes at start of pattern not handled correctly HOT 1
- `!` doesn't exclude files in directories if the pattern doesn't have a trailing slash HOT 1
- Dist failure for Fedora, CentOS, EPEL HOT 11
- Since version 0.10.0 pure wildcard does not work in some cases HOT 4
- The pattern_to_regex method does not seem to work correctly on windows. HOT 4
- IndexError with my .gitignore file when trying to build a Python package HOT 4
- Checking directories via match_file() does not work on Path objects HOT 5
- Package not marked as `py.typed` HOT 1
- Exports are considered private HOT 1
- `'Self'` string literal type is `Unknown` in pyright HOT 1
- Please consider switching the build-system to flit_core to ease setuptools bootstrap HOT 5
- Include directory should override exclude file HOT 3
- On bracket expression negation HOT 2
- match_files with negated path spec HOT 5
- `GitIgnoreSpec` behaviors differ from git HOT 2
- PathSpec.match_file() returns None since 0.12.0 HOT 3
- Exclusions not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-pathspec.