ignore-python 0.1.2__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ignore_python-0.1.2 → ignore_python-0.2.0}/.github/workflows/CI.yml +103 -18
- {ignore_python-0.1.2 → ignore_python-0.2.0}/.github/workflows/docs.yml +1 -1
- {ignore_python-0.1.2 → ignore_python-0.2.0}/.gitignore +0 -67
- {ignore_python-0.1.2 → ignore_python-0.2.0}/Cargo.lock +54 -54
- {ignore_python-0.1.2 → ignore_python-0.2.0}/Cargo.toml +2 -2
- {ignore_python-0.1.2 → ignore_python-0.2.0}/PKG-INFO +2 -2
- {ignore_python-0.1.2 → ignore_python-0.2.0}/ignore/__init__.pyi +1 -1
- ignore_python-0.2.0/src/lib.rs +348 -0
- ignore_python-0.2.0/tests/test_root.py +61 -0
- ignore_python-0.1.2/src/lib.rs +0 -315
- {ignore_python-0.1.2 → ignore_python-0.2.0}/LICENSE.txt +0 -0
- {ignore_python-0.1.2 → ignore_python-0.2.0}/README.md +0 -0
- {ignore_python-0.1.2 → ignore_python-0.2.0}/ignore/__init__.py +0 -0
- {ignore_python-0.1.2 → ignore_python-0.2.0}/ignore/overrides/__init__.pyi +0 -0
- {ignore_python-0.1.2 → ignore_python-0.2.0}/ignore/overrides/py.typed +0 -0
- {ignore_python-0.1.2 → ignore_python-0.2.0}/ignore/py.typed +0 -0
- {ignore_python-0.1.2 → ignore_python-0.2.0}/pyproject.toml +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# This file is autogenerated by maturin v1.
|
|
1
|
+
# This file is autogenerated by maturin v1.8.3
|
|
2
2
|
# To update, run
|
|
3
3
|
#
|
|
4
|
-
# maturin generate-ci github
|
|
4
|
+
# maturin generate-ci github --pytest
|
|
5
5
|
#
|
|
6
6
|
name: CI
|
|
7
7
|
|
|
@@ -24,17 +24,17 @@ jobs:
|
|
|
24
24
|
strategy:
|
|
25
25
|
matrix:
|
|
26
26
|
platform:
|
|
27
|
-
- runner: ubuntu-
|
|
27
|
+
- runner: ubuntu-22.04
|
|
28
28
|
target: x86_64
|
|
29
|
-
- runner: ubuntu-
|
|
29
|
+
- runner: ubuntu-22.04
|
|
30
30
|
target: x86
|
|
31
|
-
- runner: ubuntu-
|
|
31
|
+
- runner: ubuntu-22.04
|
|
32
32
|
target: aarch64
|
|
33
|
-
- runner: ubuntu-
|
|
33
|
+
- runner: ubuntu-22.04
|
|
34
34
|
target: armv7
|
|
35
|
-
- runner: ubuntu-
|
|
35
|
+
- runner: ubuntu-22.04
|
|
36
36
|
target: s390x
|
|
37
|
-
- runner: ubuntu-
|
|
37
|
+
- runner: ubuntu-22.04
|
|
38
38
|
target: ppc64le
|
|
39
39
|
steps:
|
|
40
40
|
- uses: actions/checkout@v4
|
|
@@ -46,26 +46,51 @@ jobs:
|
|
|
46
46
|
with:
|
|
47
47
|
target: ${{ matrix.platform.target }}
|
|
48
48
|
args: --release --out dist --find-interpreter
|
|
49
|
-
sccache: '
|
|
49
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
50
50
|
manylinux: auto
|
|
51
51
|
- name: Upload wheels
|
|
52
52
|
uses: actions/upload-artifact@v4
|
|
53
53
|
with:
|
|
54
54
|
name: wheels-linux-${{ matrix.platform.target }}
|
|
55
55
|
path: dist
|
|
56
|
+
- name: pytest
|
|
57
|
+
if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
|
|
58
|
+
shell: bash
|
|
59
|
+
run: |
|
|
60
|
+
set -e
|
|
61
|
+
python3 -m venv .venv
|
|
62
|
+
source .venv/bin/activate
|
|
63
|
+
pip install ignore-python --find-links dist --force-reinstall
|
|
64
|
+
pip install pytest
|
|
65
|
+
pytest
|
|
66
|
+
- name: pytest
|
|
67
|
+
if: ${{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' }}
|
|
68
|
+
uses: uraimo/run-on-arch-action@v2
|
|
69
|
+
with:
|
|
70
|
+
arch: ${{ matrix.platform.target }}
|
|
71
|
+
distro: ubuntu22.04
|
|
72
|
+
githubToken: ${{ github.token }}
|
|
73
|
+
install: |
|
|
74
|
+
apt-get update
|
|
75
|
+
apt-get install -y --no-install-recommends python3 python3-pip
|
|
76
|
+
pip3 install -U pip pytest
|
|
77
|
+
run: |
|
|
78
|
+
set -e
|
|
79
|
+
pip3 install ignore-python --find-links dist --force-reinstall
|
|
80
|
+
pytest
|
|
56
81
|
|
|
57
82
|
musllinux:
|
|
58
83
|
runs-on: ${{ matrix.platform.runner }}
|
|
59
84
|
strategy:
|
|
60
85
|
matrix:
|
|
61
86
|
platform:
|
|
62
|
-
- runner: ubuntu-
|
|
87
|
+
- runner: ubuntu-22.04
|
|
63
88
|
target: x86_64
|
|
64
|
-
- runner: ubuntu-
|
|
89
|
+
- runner: ubuntu-22.04
|
|
65
90
|
target: x86
|
|
66
|
-
- runner: ubuntu-
|
|
91
|
+
- runner: ubuntu-22.04
|
|
67
92
|
target: aarch64
|
|
68
|
-
- runner: ubuntu-
|
|
93
|
+
- runner: ubuntu-22.04
|
|
69
94
|
target: armv7
|
|
70
95
|
steps:
|
|
71
96
|
- uses: actions/checkout@v4
|
|
@@ -77,13 +102,43 @@ jobs:
|
|
|
77
102
|
with:
|
|
78
103
|
target: ${{ matrix.platform.target }}
|
|
79
104
|
args: --release --out dist --find-interpreter
|
|
80
|
-
sccache: '
|
|
105
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
81
106
|
manylinux: musllinux_1_2
|
|
82
107
|
- name: Upload wheels
|
|
83
108
|
uses: actions/upload-artifact@v4
|
|
84
109
|
with:
|
|
85
110
|
name: wheels-musllinux-${{ matrix.platform.target }}
|
|
86
111
|
path: dist
|
|
112
|
+
- name: pytest
|
|
113
|
+
if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
|
|
114
|
+
uses: addnab/docker-run-action@v3
|
|
115
|
+
with:
|
|
116
|
+
image: alpine:latest
|
|
117
|
+
options: -v ${{ github.workspace }}:/io -w /io
|
|
118
|
+
run: |
|
|
119
|
+
set -e
|
|
120
|
+
apk add py3-pip py3-virtualenv
|
|
121
|
+
python3 -m virtualenv .venv
|
|
122
|
+
source .venv/bin/activate
|
|
123
|
+
pip install ignore-python --no-index --find-links dist --force-reinstall
|
|
124
|
+
pip install pytest
|
|
125
|
+
pytest
|
|
126
|
+
- name: pytest
|
|
127
|
+
if: ${{ !startsWith(matrix.platform.target, 'x86') }}
|
|
128
|
+
uses: uraimo/run-on-arch-action@v2
|
|
129
|
+
with:
|
|
130
|
+
arch: ${{ matrix.platform.target }}
|
|
131
|
+
distro: alpine_latest
|
|
132
|
+
githubToken: ${{ github.token }}
|
|
133
|
+
install: |
|
|
134
|
+
apk add py3-virtualenv
|
|
135
|
+
run: |
|
|
136
|
+
set -e
|
|
137
|
+
python3 -m virtualenv .venv
|
|
138
|
+
source .venv/bin/activate
|
|
139
|
+
pip install pytest
|
|
140
|
+
pip install ignore-python --find-links dist --force-reinstall
|
|
141
|
+
pytest
|
|
87
142
|
|
|
88
143
|
windows:
|
|
89
144
|
runs-on: ${{ matrix.platform.runner }}
|
|
@@ -105,19 +160,29 @@ jobs:
|
|
|
105
160
|
with:
|
|
106
161
|
target: ${{ matrix.platform.target }}
|
|
107
162
|
args: --release --out dist --find-interpreter
|
|
108
|
-
sccache: '
|
|
163
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
109
164
|
- name: Upload wheels
|
|
110
165
|
uses: actions/upload-artifact@v4
|
|
111
166
|
with:
|
|
112
167
|
name: wheels-windows-${{ matrix.platform.target }}
|
|
113
168
|
path: dist
|
|
169
|
+
- name: pytest
|
|
170
|
+
if: ${{ !startsWith(matrix.platform.target, 'aarch64') }}
|
|
171
|
+
shell: bash
|
|
172
|
+
run: |
|
|
173
|
+
set -e
|
|
174
|
+
python3 -m venv .venv
|
|
175
|
+
source .venv/Scripts/activate
|
|
176
|
+
pip install ignore-python --find-links dist --force-reinstall
|
|
177
|
+
pip install pytest
|
|
178
|
+
pytest
|
|
114
179
|
|
|
115
180
|
macos:
|
|
116
181
|
runs-on: ${{ matrix.platform.runner }}
|
|
117
182
|
strategy:
|
|
118
183
|
matrix:
|
|
119
184
|
platform:
|
|
120
|
-
- runner: macos-
|
|
185
|
+
- runner: macos-13
|
|
121
186
|
target: x86_64
|
|
122
187
|
- runner: macos-14
|
|
123
188
|
target: aarch64
|
|
@@ -131,12 +196,20 @@ jobs:
|
|
|
131
196
|
with:
|
|
132
197
|
target: ${{ matrix.platform.target }}
|
|
133
198
|
args: --release --out dist --find-interpreter
|
|
134
|
-
sccache: '
|
|
199
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
135
200
|
- name: Upload wheels
|
|
136
201
|
uses: actions/upload-artifact@v4
|
|
137
202
|
with:
|
|
138
203
|
name: wheels-macos-${{ matrix.platform.target }}
|
|
139
204
|
path: dist
|
|
205
|
+
- name: pytest
|
|
206
|
+
run: |
|
|
207
|
+
set -e
|
|
208
|
+
python3 -m venv .venv
|
|
209
|
+
source .venv/bin/activate
|
|
210
|
+
pip install ignore-python --find-links dist --force-reinstall
|
|
211
|
+
pip install pytest
|
|
212
|
+
pytest
|
|
140
213
|
|
|
141
214
|
sdist:
|
|
142
215
|
runs-on: ubuntu-latest
|
|
@@ -156,11 +229,23 @@ jobs:
|
|
|
156
229
|
release:
|
|
157
230
|
name: Release
|
|
158
231
|
runs-on: ubuntu-latest
|
|
159
|
-
if:
|
|
232
|
+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
|
|
160
233
|
needs: [linux, musllinux, windows, macos, sdist]
|
|
234
|
+
permissions:
|
|
235
|
+
# Use to sign the release artifacts
|
|
236
|
+
id-token: write
|
|
237
|
+
# Used to upload release artifacts
|
|
238
|
+
contents: write
|
|
239
|
+
# Used to generate artifact attestation
|
|
240
|
+
attestations: write
|
|
161
241
|
steps:
|
|
162
242
|
- uses: actions/download-artifact@v4
|
|
243
|
+
- name: Generate artifact attestation
|
|
244
|
+
uses: actions/attest-build-provenance@v2
|
|
245
|
+
with:
|
|
246
|
+
subject-path: 'wheels-*/*'
|
|
163
247
|
- name: Publish to PyPI
|
|
248
|
+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
164
249
|
uses: PyO3/maturin-action@v1
|
|
165
250
|
env:
|
|
166
251
|
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -253,70 +253,3 @@ Cargo.lock
|
|
|
253
253
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
254
254
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
255
255
|
#.idea/# -*- mode: gitignore; -*-
|
|
256
|
-
*~
|
|
257
|
-
\#*\#
|
|
258
|
-
/.emacs.desktop
|
|
259
|
-
/.emacs.desktop.lock
|
|
260
|
-
*.elc
|
|
261
|
-
auto-save-list
|
|
262
|
-
tramp
|
|
263
|
-
.\#*
|
|
264
|
-
|
|
265
|
-
# Org-mode
|
|
266
|
-
.org-id-locations
|
|
267
|
-
*_archive
|
|
268
|
-
|
|
269
|
-
# flymake-mode
|
|
270
|
-
*_flymake.*
|
|
271
|
-
|
|
272
|
-
# eshell files
|
|
273
|
-
/eshell/history
|
|
274
|
-
/eshell/lastdir
|
|
275
|
-
|
|
276
|
-
# elpa packages
|
|
277
|
-
/elpa/
|
|
278
|
-
|
|
279
|
-
# reftex files
|
|
280
|
-
*.rel
|
|
281
|
-
|
|
282
|
-
# AUCTeX auto folder
|
|
283
|
-
/auto/
|
|
284
|
-
|
|
285
|
-
# cask packages
|
|
286
|
-
.cask/
|
|
287
|
-
dist/
|
|
288
|
-
|
|
289
|
-
# Flycheck
|
|
290
|
-
flycheck_*.el
|
|
291
|
-
|
|
292
|
-
# server auth directory
|
|
293
|
-
/server/
|
|
294
|
-
|
|
295
|
-
# projectiles files
|
|
296
|
-
.projectile
|
|
297
|
-
|
|
298
|
-
# directory configuration
|
|
299
|
-
.dir-locals.el
|
|
300
|
-
|
|
301
|
-
# network security
|
|
302
|
-
/network-security.data
|
|
303
|
-
|
|
304
|
-
# Swap
|
|
305
|
-
[._]*.s[a-v][a-z]
|
|
306
|
-
!*.svg # comment out if you don't need vector files
|
|
307
|
-
[._]*.sw[a-p]
|
|
308
|
-
[._]s[a-rt-v][a-z]
|
|
309
|
-
[._]ss[a-gi-z]
|
|
310
|
-
[._]sw[a-p]
|
|
311
|
-
|
|
312
|
-
# Session
|
|
313
|
-
Session.vim
|
|
314
|
-
Sessionx.vim
|
|
315
|
-
|
|
316
|
-
# Temporary
|
|
317
|
-
.netrwhist
|
|
318
|
-
*~
|
|
319
|
-
# Auto-generated tag files
|
|
320
|
-
tags
|
|
321
|
-
# Persistent undo
|
|
322
|
-
[._]*.un~
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This file is automatically @generated by Cargo.
|
|
2
2
|
# It is not intended for manual editing.
|
|
3
|
-
version =
|
|
3
|
+
version = 4
|
|
4
4
|
|
|
5
5
|
[[package]]
|
|
6
6
|
name = "aho-corasick"
|
|
@@ -13,15 +13,15 @@ dependencies = [
|
|
|
13
13
|
|
|
14
14
|
[[package]]
|
|
15
15
|
name = "autocfg"
|
|
16
|
-
version = "1.
|
|
16
|
+
version = "1.4.0"
|
|
17
17
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
-
checksum = "
|
|
18
|
+
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
|
19
19
|
|
|
20
20
|
[[package]]
|
|
21
21
|
name = "bstr"
|
|
22
|
-
version = "1.
|
|
22
|
+
version = "1.11.3"
|
|
23
23
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
24
|
-
checksum = "
|
|
24
|
+
checksum = "531a9155a481e2ee699d4f98f43c0ca4ff8ee1bfd55c31e9e98fb29d2b176fe0"
|
|
25
25
|
dependencies = [
|
|
26
26
|
"memchr",
|
|
27
27
|
"serde",
|
|
@@ -35,9 +35,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
|
35
35
|
|
|
36
36
|
[[package]]
|
|
37
37
|
name = "crossbeam-deque"
|
|
38
|
-
version = "0.8.
|
|
38
|
+
version = "0.8.6"
|
|
39
39
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
40
|
-
checksum = "
|
|
40
|
+
checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
|
|
41
41
|
dependencies = [
|
|
42
42
|
"crossbeam-epoch",
|
|
43
43
|
"crossbeam-utils",
|
|
@@ -54,15 +54,15 @@ dependencies = [
|
|
|
54
54
|
|
|
55
55
|
[[package]]
|
|
56
56
|
name = "crossbeam-utils"
|
|
57
|
-
version = "0.8.
|
|
57
|
+
version = "0.8.21"
|
|
58
58
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
59
|
-
checksum = "
|
|
59
|
+
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
|
60
60
|
|
|
61
61
|
[[package]]
|
|
62
62
|
name = "globset"
|
|
63
|
-
version = "0.4.
|
|
63
|
+
version = "0.4.16"
|
|
64
64
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
65
|
-
checksum = "
|
|
65
|
+
checksum = "54a1028dfc5f5df5da8a56a73e6c153c9a9708ec57232470703592a3f18e49f5"
|
|
66
66
|
dependencies = [
|
|
67
67
|
"aho-corasick",
|
|
68
68
|
"bstr",
|
|
@@ -79,9 +79,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
|
79
79
|
|
|
80
80
|
[[package]]
|
|
81
81
|
name = "ignore"
|
|
82
|
-
version = "0.4.
|
|
82
|
+
version = "0.4.23"
|
|
83
83
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
84
|
-
checksum = "
|
|
84
|
+
checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b"
|
|
85
85
|
dependencies = [
|
|
86
86
|
"crossbeam-deque",
|
|
87
87
|
"globset",
|
|
@@ -95,7 +95,7 @@ dependencies = [
|
|
|
95
95
|
|
|
96
96
|
[[package]]
|
|
97
97
|
name = "ignore-python"
|
|
98
|
-
version = "0.
|
|
98
|
+
version = "0.2.0"
|
|
99
99
|
dependencies = [
|
|
100
100
|
"ignore",
|
|
101
101
|
"pyo3",
|
|
@@ -103,21 +103,21 @@ dependencies = [
|
|
|
103
103
|
|
|
104
104
|
[[package]]
|
|
105
105
|
name = "indoc"
|
|
106
|
-
version = "2.0.
|
|
106
|
+
version = "2.0.6"
|
|
107
107
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
108
|
-
checksum = "
|
|
108
|
+
checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
|
|
109
109
|
|
|
110
110
|
[[package]]
|
|
111
111
|
name = "libc"
|
|
112
|
-
version = "0.2.
|
|
112
|
+
version = "0.2.171"
|
|
113
113
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
114
|
-
checksum = "
|
|
114
|
+
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
|
|
115
115
|
|
|
116
116
|
[[package]]
|
|
117
117
|
name = "log"
|
|
118
|
-
version = "0.4.
|
|
118
|
+
version = "0.4.27"
|
|
119
119
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
120
|
-
checksum = "
|
|
120
|
+
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
|
121
121
|
|
|
122
122
|
[[package]]
|
|
123
123
|
name = "memchr"
|
|
@@ -136,30 +136,30 @@ dependencies = [
|
|
|
136
136
|
|
|
137
137
|
[[package]]
|
|
138
138
|
name = "once_cell"
|
|
139
|
-
version = "1.
|
|
139
|
+
version = "1.21.3"
|
|
140
140
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
141
|
-
checksum = "
|
|
141
|
+
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
142
142
|
|
|
143
143
|
[[package]]
|
|
144
144
|
name = "portable-atomic"
|
|
145
|
-
version = "1.
|
|
145
|
+
version = "1.11.0"
|
|
146
146
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
147
|
-
checksum = "
|
|
147
|
+
checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
|
|
148
148
|
|
|
149
149
|
[[package]]
|
|
150
150
|
name = "proc-macro2"
|
|
151
|
-
version = "1.0.
|
|
151
|
+
version = "1.0.94"
|
|
152
152
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
153
|
-
checksum = "
|
|
153
|
+
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
|
|
154
154
|
dependencies = [
|
|
155
155
|
"unicode-ident",
|
|
156
156
|
]
|
|
157
157
|
|
|
158
158
|
[[package]]
|
|
159
159
|
name = "pyo3"
|
|
160
|
-
version = "0.
|
|
160
|
+
version = "0.24.1"
|
|
161
161
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
162
|
-
checksum = "
|
|
162
|
+
checksum = "17da310086b068fbdcefbba30aeb3721d5bb9af8db4987d6735b2183ca567229"
|
|
163
163
|
dependencies = [
|
|
164
164
|
"cfg-if",
|
|
165
165
|
"indoc",
|
|
@@ -175,9 +175,9 @@ dependencies = [
|
|
|
175
175
|
|
|
176
176
|
[[package]]
|
|
177
177
|
name = "pyo3-build-config"
|
|
178
|
-
version = "0.
|
|
178
|
+
version = "0.24.1"
|
|
179
179
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
180
|
-
checksum = "
|
|
180
|
+
checksum = "e27165889bd793000a098bb966adc4300c312497ea25cf7a690a9f0ac5aa5fc1"
|
|
181
181
|
dependencies = [
|
|
182
182
|
"once_cell",
|
|
183
183
|
"target-lexicon",
|
|
@@ -185,9 +185,9 @@ dependencies = [
|
|
|
185
185
|
|
|
186
186
|
[[package]]
|
|
187
187
|
name = "pyo3-ffi"
|
|
188
|
-
version = "0.
|
|
188
|
+
version = "0.24.1"
|
|
189
189
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
190
|
-
checksum = "
|
|
190
|
+
checksum = "05280526e1dbf6b420062f3ef228b78c0c54ba94e157f5cb724a609d0f2faabc"
|
|
191
191
|
dependencies = [
|
|
192
192
|
"libc",
|
|
193
193
|
"pyo3-build-config",
|
|
@@ -195,9 +195,9 @@ dependencies = [
|
|
|
195
195
|
|
|
196
196
|
[[package]]
|
|
197
197
|
name = "pyo3-macros"
|
|
198
|
-
version = "0.
|
|
198
|
+
version = "0.24.1"
|
|
199
199
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
200
|
-
checksum = "
|
|
200
|
+
checksum = "5c3ce5686aa4d3f63359a5100c62a127c9f15e8398e5fdeb5deef1fed5cd5f44"
|
|
201
201
|
dependencies = [
|
|
202
202
|
"proc-macro2",
|
|
203
203
|
"pyo3-macros-backend",
|
|
@@ -207,9 +207,9 @@ dependencies = [
|
|
|
207
207
|
|
|
208
208
|
[[package]]
|
|
209
209
|
name = "pyo3-macros-backend"
|
|
210
|
-
version = "0.
|
|
210
|
+
version = "0.24.1"
|
|
211
211
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
212
|
-
checksum = "
|
|
212
|
+
checksum = "f4cf6faa0cbfb0ed08e89beb8103ae9724eb4750e3a78084ba4017cbe94f3855"
|
|
213
213
|
dependencies = [
|
|
214
214
|
"heck",
|
|
215
215
|
"proc-macro2",
|
|
@@ -220,18 +220,18 @@ dependencies = [
|
|
|
220
220
|
|
|
221
221
|
[[package]]
|
|
222
222
|
name = "quote"
|
|
223
|
-
version = "1.0.
|
|
223
|
+
version = "1.0.40"
|
|
224
224
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
225
|
-
checksum = "
|
|
225
|
+
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
|
226
226
|
dependencies = [
|
|
227
227
|
"proc-macro2",
|
|
228
228
|
]
|
|
229
229
|
|
|
230
230
|
[[package]]
|
|
231
231
|
name = "regex-automata"
|
|
232
|
-
version = "0.4.
|
|
232
|
+
version = "0.4.9"
|
|
233
233
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
234
|
-
checksum = "
|
|
234
|
+
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
|
235
235
|
dependencies = [
|
|
236
236
|
"aho-corasick",
|
|
237
237
|
"memchr",
|
|
@@ -240,9 +240,9 @@ dependencies = [
|
|
|
240
240
|
|
|
241
241
|
[[package]]
|
|
242
242
|
name = "regex-syntax"
|
|
243
|
-
version = "0.8.
|
|
243
|
+
version = "0.8.5"
|
|
244
244
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
245
|
-
checksum = "
|
|
245
|
+
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
|
246
246
|
|
|
247
247
|
[[package]]
|
|
248
248
|
name = "same-file"
|
|
@@ -255,18 +255,18 @@ dependencies = [
|
|
|
255
255
|
|
|
256
256
|
[[package]]
|
|
257
257
|
name = "serde"
|
|
258
|
-
version = "1.0.
|
|
258
|
+
version = "1.0.219"
|
|
259
259
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
260
|
-
checksum = "
|
|
260
|
+
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
|
261
261
|
dependencies = [
|
|
262
262
|
"serde_derive",
|
|
263
263
|
]
|
|
264
264
|
|
|
265
265
|
[[package]]
|
|
266
266
|
name = "serde_derive"
|
|
267
|
-
version = "1.0.
|
|
267
|
+
version = "1.0.219"
|
|
268
268
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
269
|
-
checksum = "
|
|
269
|
+
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
|
270
270
|
dependencies = [
|
|
271
271
|
"proc-macro2",
|
|
272
272
|
"quote",
|
|
@@ -275,9 +275,9 @@ dependencies = [
|
|
|
275
275
|
|
|
276
276
|
[[package]]
|
|
277
277
|
name = "syn"
|
|
278
|
-
version = "2.0.
|
|
278
|
+
version = "2.0.100"
|
|
279
279
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
280
|
-
checksum = "
|
|
280
|
+
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
|
|
281
281
|
dependencies = [
|
|
282
282
|
"proc-macro2",
|
|
283
283
|
"quote",
|
|
@@ -286,21 +286,21 @@ dependencies = [
|
|
|
286
286
|
|
|
287
287
|
[[package]]
|
|
288
288
|
name = "target-lexicon"
|
|
289
|
-
version = "0.
|
|
289
|
+
version = "0.13.2"
|
|
290
290
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
291
|
-
checksum = "
|
|
291
|
+
checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a"
|
|
292
292
|
|
|
293
293
|
[[package]]
|
|
294
294
|
name = "unicode-ident"
|
|
295
|
-
version = "1.0.
|
|
295
|
+
version = "1.0.18"
|
|
296
296
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
297
|
-
checksum = "
|
|
297
|
+
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
|
298
298
|
|
|
299
299
|
[[package]]
|
|
300
300
|
name = "unindent"
|
|
301
|
-
version = "0.2.
|
|
301
|
+
version = "0.2.4"
|
|
302
302
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
303
|
-
checksum = "
|
|
303
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
304
304
|
|
|
305
305
|
[[package]]
|
|
306
306
|
name = "walkdir"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "ignore-python"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
|
|
6
6
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
@@ -9,5 +9,5 @@ name = "ignore"
|
|
|
9
9
|
crate-type = ["cdylib"]
|
|
10
10
|
|
|
11
11
|
[dependencies]
|
|
12
|
-
pyo3 = "0.
|
|
12
|
+
pyo3 = "0.24.1"
|
|
13
13
|
ignore-rust = { version = "0.4.22", package = "ignore" }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ignore-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -67,7 +67,7 @@ class WalkBuilder:
|
|
|
67
67
|
|
|
68
68
|
def same_file_system(self, yes: bool) -> Self: ...
|
|
69
69
|
|
|
70
|
-
def max_depth(self, depth: int | None
|
|
70
|
+
def max_depth(self, depth: int | None) -> Self: ...
|
|
71
71
|
|
|
72
72
|
def add_custom_ignore_filename(self, file_name: str) -> Self: ...
|
|
73
73
|
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
use pyo3::{create_exception, prelude::*, types::PyAny};
|
|
2
|
+
|
|
3
|
+
fn register_child_module<'a>(
|
|
4
|
+
parent_module: &'a Bound<'a, PyModule>,
|
|
5
|
+
name: &'a str,
|
|
6
|
+
) -> PyResult<Bound<'a, PyModule>> {
|
|
7
|
+
let child_module = PyModule::new(parent_module.py(), name)?;
|
|
8
|
+
|
|
9
|
+
parent_module.add_submodule(&child_module)?;
|
|
10
|
+
|
|
11
|
+
let parent_module_name = parent_module.name()?;
|
|
12
|
+
let mut parent_module_name = parent_module_name.to_str()?;
|
|
13
|
+
|
|
14
|
+
if let Some(dot_index) = parent_module_name.find(".") {
|
|
15
|
+
parent_module_name = &parent_module_name[..dot_index];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
parent_module
|
|
19
|
+
.py()
|
|
20
|
+
.import("sys")?
|
|
21
|
+
.getattr("modules")?
|
|
22
|
+
.set_item(String::from(parent_module_name) + "." + name, &child_module)?;
|
|
23
|
+
|
|
24
|
+
Ok(child_module)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
struct PathBuf(std::path::PathBuf);
|
|
28
|
+
|
|
29
|
+
impl FromPyObject<'_> for PathBuf {
|
|
30
|
+
fn extract_bound(path: &Bound<'_, PyAny>) -> PyResult<Self> {
|
|
31
|
+
let builtins = PyModule::import(path.py(), "builtins")?;
|
|
32
|
+
|
|
33
|
+
let path = builtins.getattr("str")?.call((path,), None)?;
|
|
34
|
+
let path: &str = path.extract()?;
|
|
35
|
+
|
|
36
|
+
Ok(PathBuf(std::path::PathBuf::from(path)))
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
impl<'py> IntoPyObject<'py> for PathBuf {
|
|
41
|
+
type Target = PyAny;
|
|
42
|
+
type Output = Bound<'py, Self::Target>;
|
|
43
|
+
type Error = PyErr;
|
|
44
|
+
|
|
45
|
+
fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
|
|
46
|
+
let pathlib = PyModule::import(py, "pathlib").expect("no `pathlib`");
|
|
47
|
+
let path = pathlib
|
|
48
|
+
.getattr("Path")
|
|
49
|
+
.expect("no `pathlib.Path`")
|
|
50
|
+
.call1((self.0,))
|
|
51
|
+
.expect("wrong call to `Path`");
|
|
52
|
+
|
|
53
|
+
Ok(path)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
struct Path<'a>(&'a std::path::Path);
|
|
58
|
+
|
|
59
|
+
impl<'py> IntoPyObject<'py> for Path<'_> {
|
|
60
|
+
type Target = PyAny;
|
|
61
|
+
type Output = Bound<'py, Self::Target>;
|
|
62
|
+
type Error = PyErr;
|
|
63
|
+
|
|
64
|
+
fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
|
|
65
|
+
let pathlib = PyModule::import(py, "pathlib").expect("no `pathlib`");
|
|
66
|
+
let path = pathlib
|
|
67
|
+
.getattr("Path")
|
|
68
|
+
.expect("no `pathlib.Path`")
|
|
69
|
+
.call1((self.0,))
|
|
70
|
+
.expect("wrong call to `Path`");
|
|
71
|
+
|
|
72
|
+
Ok(path)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
create_exception!(ignore, Error, pyo3::exceptions::PyException);
|
|
77
|
+
|
|
78
|
+
#[pymodule]
|
|
79
|
+
mod ignore {
|
|
80
|
+
use std::io;
|
|
81
|
+
|
|
82
|
+
use super::*;
|
|
83
|
+
|
|
84
|
+
struct ErrorWrapper(ignore_rust::Error);
|
|
85
|
+
|
|
86
|
+
#[pyclass(extends=pyo3::exceptions::PyException)]
|
|
87
|
+
struct IOError {
|
|
88
|
+
#[pyo3(get)]
|
|
89
|
+
errno: u32,
|
|
90
|
+
|
|
91
|
+
strerror: String,
|
|
92
|
+
|
|
93
|
+
#[pyo3(get)]
|
|
94
|
+
filename: String,
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#[pymethods]
|
|
98
|
+
impl IOError {
|
|
99
|
+
#[new]
|
|
100
|
+
fn new(errno: u32, strerror: String, filename: String) -> Self {
|
|
101
|
+
Self {
|
|
102
|
+
errno,
|
|
103
|
+
strerror,
|
|
104
|
+
filename,
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
fn __str__(&self) -> String {
|
|
109
|
+
self.strerror.clone()
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
impl From<ErrorWrapper> for PyErr {
|
|
114
|
+
fn from(error: ErrorWrapper) -> Self {
|
|
115
|
+
match &error.0 {
|
|
116
|
+
ignore_rust::Error::WithPath { path, err } => match err.as_ref() {
|
|
117
|
+
ignore_rust::Error::Io(io_error) => match io_error.kind() {
|
|
118
|
+
io::ErrorKind::NotFound => Python::with_gil(|py| {
|
|
119
|
+
let errno = py
|
|
120
|
+
.import("errno")
|
|
121
|
+
.expect("`errno` module")
|
|
122
|
+
.getattr("ENOENT")
|
|
123
|
+
.expect("`errno.ENOENT` constant")
|
|
124
|
+
.extract()
|
|
125
|
+
.expect("`int` value");
|
|
126
|
+
let strerror = error.0.to_string();
|
|
127
|
+
let filename =
|
|
128
|
+
path.clone().into_os_string().into_string().expect("a path");
|
|
129
|
+
|
|
130
|
+
PyErr::from_value(
|
|
131
|
+
Bound::new(
|
|
132
|
+
py,
|
|
133
|
+
IOError {
|
|
134
|
+
errno,
|
|
135
|
+
strerror,
|
|
136
|
+
filename,
|
|
137
|
+
},
|
|
138
|
+
)
|
|
139
|
+
.unwrap()
|
|
140
|
+
.into_any(),
|
|
141
|
+
)
|
|
142
|
+
}),
|
|
143
|
+
_ => PyErr::new::<Error, _>(error.0.to_string()),
|
|
144
|
+
},
|
|
145
|
+
_ => PyErr::new::<Error, _>(error.0.to_string()),
|
|
146
|
+
},
|
|
147
|
+
_ => PyErr::new::<Error, _>(error.0.to_string()),
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
impl From<ignore_rust::Error> for ErrorWrapper {
|
|
153
|
+
fn from(other: ignore_rust::Error) -> Self {
|
|
154
|
+
Self(other)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
#[pymodule_init]
|
|
159
|
+
fn init(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
160
|
+
m.add("Error", m.py().get_type::<Error>())?;
|
|
161
|
+
|
|
162
|
+
let overrides = register_child_module(m, "overrides")?;
|
|
163
|
+
|
|
164
|
+
overrides.add_class::<overrides::OverrideBuilder>()?;
|
|
165
|
+
overrides.add_class::<overrides::Override>()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#[pyclass]
|
|
169
|
+
struct DirEntry(ignore_rust::DirEntry);
|
|
170
|
+
|
|
171
|
+
#[pymethods]
|
|
172
|
+
impl DirEntry {
|
|
173
|
+
fn path(&self) -> Path {
|
|
174
|
+
Path(self.0.path())
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
fn depth(&self) -> usize {
|
|
178
|
+
self.0.depth()
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
#[pyclass]
|
|
183
|
+
struct WalkBuilder(ignore_rust::WalkBuilder);
|
|
184
|
+
|
|
185
|
+
#[pymethods]
|
|
186
|
+
impl WalkBuilder {
|
|
187
|
+
#[new]
|
|
188
|
+
fn new(path: PathBuf) -> PyResult<Self> {
|
|
189
|
+
Ok(Self(ignore_rust::WalkBuilder::new(path.0)))
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
fn hidden(mut slf: PyRefMut<'_, Self>, yes: bool) -> PyRefMut<'_, Self> {
|
|
193
|
+
slf.0.hidden(yes);
|
|
194
|
+
|
|
195
|
+
slf
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
fn ignore(mut slf: PyRefMut<'_, Self>, yes: bool) -> PyRefMut<'_, Self> {
|
|
199
|
+
slf.0.ignore(yes);
|
|
200
|
+
|
|
201
|
+
slf
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
fn parents(mut slf: PyRefMut<'_, Self>, yes: bool) -> PyRefMut<'_, Self> {
|
|
205
|
+
slf.0.parents(yes);
|
|
206
|
+
|
|
207
|
+
slf
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
fn git_ignore(mut slf: PyRefMut<'_, Self>, yes: bool) -> PyRefMut<'_, Self> {
|
|
211
|
+
slf.0.git_ignore(yes);
|
|
212
|
+
|
|
213
|
+
slf
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
fn git_global(mut slf: PyRefMut<'_, Self>, yes: bool) -> PyRefMut<'_, Self> {
|
|
217
|
+
slf.0.git_global(yes);
|
|
218
|
+
|
|
219
|
+
slf
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
fn git_exclude(mut slf: PyRefMut<'_, Self>, yes: bool) -> PyRefMut<'_, Self> {
|
|
223
|
+
slf.0.git_exclude(yes);
|
|
224
|
+
|
|
225
|
+
slf
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
fn require_git(mut slf: PyRefMut<'_, Self>, yes: bool) -> PyRefMut<'_, Self> {
|
|
229
|
+
slf.0.require_git(yes);
|
|
230
|
+
|
|
231
|
+
slf
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
fn overrides(
|
|
235
|
+
mut slf: PyRefMut<'_, Self>,
|
|
236
|
+
overrides: overrides::Override,
|
|
237
|
+
) -> PyRefMut<'_, Self> {
|
|
238
|
+
slf.0.overrides(overrides.0);
|
|
239
|
+
|
|
240
|
+
slf
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
fn follow_links(mut slf: PyRefMut<'_, Self>, yes: bool) -> PyRefMut<'_, Self> {
|
|
244
|
+
slf.0.follow_links(yes);
|
|
245
|
+
|
|
246
|
+
slf
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
fn same_file_system(mut slf: PyRefMut<'_, Self>, yes: bool) -> PyRefMut<'_, Self> {
|
|
250
|
+
slf.0.same_file_system(yes);
|
|
251
|
+
|
|
252
|
+
slf
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
fn max_depth(mut slf: PyRefMut<'_, Self>, depth: Option<usize>) -> PyRefMut<'_, Self> {
|
|
256
|
+
slf.0.max_depth(depth);
|
|
257
|
+
|
|
258
|
+
slf
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
fn add_custom_ignore_filename<'a>(
|
|
262
|
+
mut slf: PyRefMut<'a, Self>,
|
|
263
|
+
file_name: &str,
|
|
264
|
+
) -> PyRefMut<'a, Self> {
|
|
265
|
+
slf.0.add_custom_ignore_filename(file_name);
|
|
266
|
+
|
|
267
|
+
slf
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
fn add(mut slf: PyRefMut<'_, Self>, path: PathBuf) -> PyRefMut<'_, Self> {
|
|
271
|
+
slf.0.add(path.0);
|
|
272
|
+
|
|
273
|
+
slf
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
fn add_ignore(&mut self, path: PathBuf) -> PyResult<()> {
|
|
277
|
+
if let Some(e) = self.0.add_ignore(path.0) {
|
|
278
|
+
Err(ErrorWrapper(e).into())
|
|
279
|
+
} else {
|
|
280
|
+
Ok(())
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
fn build(&self) -> Walk {
|
|
285
|
+
Walk(self.0.build())
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
#[pyclass]
|
|
290
|
+
struct Walk(ignore_rust::Walk);
|
|
291
|
+
|
|
292
|
+
#[pymethods]
|
|
293
|
+
impl Walk {
|
|
294
|
+
#[new]
|
|
295
|
+
fn new(path: PathBuf) -> Self {
|
|
296
|
+
Self(ignore_rust::Walk::new(path.0))
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
fn __iter__(slf: PyRef<'_, Self>) -> PyRef<'_, Self> {
|
|
300
|
+
slf
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
fn __next__(mut slf: PyRefMut<'_, Self>) -> Option<Result<DirEntry, ErrorWrapper>> {
|
|
304
|
+
slf.0
|
|
305
|
+
.next()
|
|
306
|
+
.map(|res| res.map(DirEntry).map_err(ErrorWrapper))
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
mod overrides {
|
|
311
|
+
use super::*;
|
|
312
|
+
|
|
313
|
+
#[pyclass]
|
|
314
|
+
#[derive(Clone)]
|
|
315
|
+
pub struct Override(pub ignore_rust::overrides::Override);
|
|
316
|
+
|
|
317
|
+
#[pyclass]
|
|
318
|
+
pub struct OverrideBuilder(ignore_rust::overrides::OverrideBuilder);
|
|
319
|
+
|
|
320
|
+
#[pymethods]
|
|
321
|
+
impl OverrideBuilder {
|
|
322
|
+
#[new]
|
|
323
|
+
fn new(py: Python<'_>, path: &Bound<'_, PyAny>) -> Result<Self, PyErr> {
|
|
324
|
+
let builtins = PyModule::import(py, "builtins")?;
|
|
325
|
+
|
|
326
|
+
let path = builtins.getattr("str")?.call1((path,))?;
|
|
327
|
+
let path: &str = path.extract()?;
|
|
328
|
+
let path = std::path::Path::new(path);
|
|
329
|
+
|
|
330
|
+
Ok(Self(ignore_rust::overrides::OverrideBuilder::new(path)))
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
fn build(&self) -> Result<Override, ErrorWrapper> {
|
|
334
|
+
self.0.build().map(Override).map_err(ErrorWrapper)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
fn add<'a>(
|
|
338
|
+
mut slf: PyRefMut<'a, Self>,
|
|
339
|
+
glob: &'a str,
|
|
340
|
+
) -> Result<PyRefMut<'a, Self>, ErrorWrapper> {
|
|
341
|
+
match slf.0.add(glob) {
|
|
342
|
+
Ok(_) => Ok(slf),
|
|
343
|
+
Err(e) => Err(ErrorWrapper(e)),
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import ignore
|
|
2
|
+
from ignore import WalkBuilder, Walk
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import pytest
|
|
5
|
+
from sys import platform
|
|
6
|
+
|
|
7
|
+
PATH = Path("./")
|
|
8
|
+
|
|
9
|
+
def test_build():
|
|
10
|
+
walk = WalkBuilder(PATH).build()
|
|
11
|
+
assert type(walk) == Walk
|
|
12
|
+
assert len(list(walk)) >= 2
|
|
13
|
+
|
|
14
|
+
def test_flags():
|
|
15
|
+
builder = (WalkBuilder(PATH)
|
|
16
|
+
.hidden(True)
|
|
17
|
+
.ignore(True)
|
|
18
|
+
.parents(True)
|
|
19
|
+
.git_ignore(True)
|
|
20
|
+
.git_global(True)
|
|
21
|
+
.git_exclude(True)
|
|
22
|
+
.require_git(True)
|
|
23
|
+
.follow_links(True)
|
|
24
|
+
.same_file_system(True)
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
assert type(builder) == WalkBuilder
|
|
28
|
+
|
|
29
|
+
def test_max_depth():
|
|
30
|
+
builder = (WalkBuilder(PATH)
|
|
31
|
+
.max_depth(None)
|
|
32
|
+
.max_depth(0)
|
|
33
|
+
.max_depth(42)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
assert type(builder) == WalkBuilder
|
|
37
|
+
|
|
38
|
+
with pytest.raises(OverflowError):
|
|
39
|
+
WalkBuilder(PATH).max_depth(-1)
|
|
40
|
+
|
|
41
|
+
def test_add_custom_ignore_filename():
|
|
42
|
+
builder = WalkBuilder(PATH).add_custom_ignore_filename("foo")
|
|
43
|
+
|
|
44
|
+
assert type(builder) == WalkBuilder
|
|
45
|
+
|
|
46
|
+
def test_add():
|
|
47
|
+
builder = WalkBuilder(PATH).add(Path("../bar"))
|
|
48
|
+
|
|
49
|
+
assert type(builder) == WalkBuilder
|
|
50
|
+
|
|
51
|
+
def test_add_ignore():
|
|
52
|
+
builder = WalkBuilder(PATH)
|
|
53
|
+
|
|
54
|
+
if platform == 'win32':
|
|
55
|
+
pstr = "C:\\Windows"
|
|
56
|
+
else:
|
|
57
|
+
pstr = "/"
|
|
58
|
+
|
|
59
|
+
with pytest.raises(ignore.Error):
|
|
60
|
+
builder.add_ignore(Path(pstr))
|
|
61
|
+
|
ignore_python-0.1.2/src/lib.rs
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
use pyo3::{prelude::*, types::PyAny};
|
|
2
|
-
|
|
3
|
-
fn register_child_module<'a>(parent_module: &'a Bound<'a, PyModule>, name: &'a str) -> PyResult<Bound<'a, PyModule>> {
|
|
4
|
-
let child_module = PyModule::new_bound(parent_module.py(), name)?;
|
|
5
|
-
|
|
6
|
-
parent_module.add_submodule(&child_module)?;
|
|
7
|
-
|
|
8
|
-
let parent_module_name = parent_module.name()?;
|
|
9
|
-
let mut parent_module_name = parent_module_name.to_str()?;
|
|
10
|
-
|
|
11
|
-
if let Some(dot_index) = parent_module_name.find(".") {
|
|
12
|
-
parent_module_name = &parent_module_name[..dot_index];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
parent_module.py().import_bound("sys")?.getattr("modules")?.set_item(
|
|
16
|
-
String::from(parent_module_name) + "." + name,
|
|
17
|
-
&child_module
|
|
18
|
-
)?;
|
|
19
|
-
|
|
20
|
-
Ok(child_module)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
struct PathBuf(std::path::PathBuf);
|
|
24
|
-
|
|
25
|
-
impl FromPyObject<'_> for PathBuf {
|
|
26
|
-
fn extract_bound(path: &Bound<'_, PyAny>) -> PyResult<Self> {
|
|
27
|
-
let builtins = PyModule::import_bound(path.py(), "builtins")?;
|
|
28
|
-
|
|
29
|
-
let path = builtins
|
|
30
|
-
.getattr("str")?
|
|
31
|
-
.call((path,), None)?;
|
|
32
|
-
let path: &str = path.extract()?;
|
|
33
|
-
|
|
34
|
-
Ok(PathBuf(std::path::PathBuf::from(path)))
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
impl IntoPy<PyObject> for PathBuf {
|
|
39
|
-
fn into_py(self, py: Python<'_>) -> PyObject {
|
|
40
|
-
let pathlib = PyModule::import_bound(py, "pathlib").expect("no `pathlib`");
|
|
41
|
-
let path = pathlib
|
|
42
|
-
.getattr("Path").expect("no `pathlib.Path`")
|
|
43
|
-
.call1((self.0,)).expect("wrong call to `Path`");
|
|
44
|
-
|
|
45
|
-
path.unbind()
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
struct Path<'a>(&'a std::path::Path);
|
|
50
|
-
|
|
51
|
-
impl IntoPy<PyObject> for Path<'_> {
|
|
52
|
-
fn into_py(self, py: Python<'_>) -> PyObject {
|
|
53
|
-
let pathlib = PyModule::import_bound(py, "pathlib").expect("no `pathlib`");
|
|
54
|
-
let path = pathlib
|
|
55
|
-
.getattr("Path").expect("no `pathlib.Path`")
|
|
56
|
-
.call1((self.0,)).expect("wrong call to `Path`");
|
|
57
|
-
|
|
58
|
-
path.unbind()
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
#[pymodule]
|
|
63
|
-
mod ignore {
|
|
64
|
-
use std::io;
|
|
65
|
-
|
|
66
|
-
use super::*;
|
|
67
|
-
|
|
68
|
-
#[pyclass(extends=pyo3::exceptions::PyException)]
|
|
69
|
-
struct Error(ignore_rust::Error);
|
|
70
|
-
|
|
71
|
-
#[pyclass(extends=pyo3::exceptions::PyException)]
|
|
72
|
-
struct IOError {
|
|
73
|
-
#[pyo3(get)]
|
|
74
|
-
errno: u32,
|
|
75
|
-
|
|
76
|
-
strerror: String,
|
|
77
|
-
|
|
78
|
-
#[pyo3(get)]
|
|
79
|
-
filename: String,
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
#[pymethods]
|
|
83
|
-
impl IOError {
|
|
84
|
-
#[new]
|
|
85
|
-
fn new(errno: u32, strerror: String, filename: String) -> Self {
|
|
86
|
-
Self { errno, strerror, filename }
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
fn __str__(&self) -> String {
|
|
90
|
-
self.strerror.clone()
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
impl From<Error> for PyErr {
|
|
95
|
-
fn from(error: Error) -> Self {
|
|
96
|
-
match &error.0 {
|
|
97
|
-
ignore_rust::Error::WithPath { path, err } => {
|
|
98
|
-
match err.as_ref() {
|
|
99
|
-
ignore_rust::Error::Io(io_error) => {
|
|
100
|
-
match io_error.kind() {
|
|
101
|
-
io::ErrorKind::NotFound => {
|
|
102
|
-
Python::with_gil(|py| {
|
|
103
|
-
let errno = py.import_bound("errno").expect("`errno` module")
|
|
104
|
-
.getattr("ENOENT").expect("`errno.ENOENT` constant")
|
|
105
|
-
.extract().expect("`int` value");
|
|
106
|
-
let strerror = error.0.to_string();
|
|
107
|
-
let filename = path.clone().into_os_string().into_string().expect("a path");
|
|
108
|
-
|
|
109
|
-
PyErr::from_value_bound(Bound::new(py, IOError { errno, strerror, filename }).unwrap().into_any())
|
|
110
|
-
})
|
|
111
|
-
},
|
|
112
|
-
_ => PyErr::new::<Error, _>(error.0.to_string())
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
_ => PyErr::new::<Error, _>(error.0.to_string())
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
_ => PyErr::new::<Error, _>(error.0.to_string())
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
impl From<ignore_rust::Error> for Error {
|
|
124
|
-
fn from(other: ignore_rust::Error) -> Self {
|
|
125
|
-
Self(other)
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
#[pymodule_init]
|
|
130
|
-
fn init(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
131
|
-
let overrides = register_child_module(m, "overrides")?;
|
|
132
|
-
|
|
133
|
-
overrides.add_class::<overrides::OverrideBuilder>()?;
|
|
134
|
-
overrides.add_class::<overrides::Override>()
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
#[pyclass]
|
|
138
|
-
struct DirEntry(ignore_rust::DirEntry);
|
|
139
|
-
|
|
140
|
-
#[pymethods]
|
|
141
|
-
impl DirEntry {
|
|
142
|
-
fn path(&self) -> Path {
|
|
143
|
-
Path(self.0.path())
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
fn depth(&self) -> usize {
|
|
147
|
-
self.0.depth()
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
#[pyclass]
|
|
152
|
-
struct WalkBuilder(ignore_rust::WalkBuilder);
|
|
153
|
-
|
|
154
|
-
#[pymethods]
|
|
155
|
-
impl WalkBuilder {
|
|
156
|
-
#[new]
|
|
157
|
-
fn new(path: PathBuf) -> PyResult<Self> {
|
|
158
|
-
Ok(Self(ignore_rust::WalkBuilder::new(path.0)))
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
fn hidden<'a>(mut slf: PyRefMut<'a, Self>, yes: bool) -> PyRefMut<'a, Self> {
|
|
162
|
-
slf.0.hidden(yes);
|
|
163
|
-
|
|
164
|
-
slf
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
fn ignore<'a>(mut slf: PyRefMut<'a, Self>, yes: bool) -> PyRefMut<'a, Self> {
|
|
168
|
-
slf.0.ignore(yes);
|
|
169
|
-
|
|
170
|
-
slf
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
fn parents<'a>(mut slf: PyRefMut<'a, Self>, yes: bool) -> PyRefMut<'a, Self> {
|
|
174
|
-
slf.0.parents(yes);
|
|
175
|
-
|
|
176
|
-
slf
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
fn git_ignore<'a>(mut slf: PyRefMut<'a, Self>, yes: bool) -> PyRefMut<'a, Self> {
|
|
180
|
-
slf.0.git_ignore(yes);
|
|
181
|
-
|
|
182
|
-
slf
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
fn git_global<'a>(mut slf: PyRefMut<'a, Self>, yes: bool) -> PyRefMut<'a, Self> {
|
|
186
|
-
slf.0.git_global(yes);
|
|
187
|
-
|
|
188
|
-
slf
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
fn git_exclude<'a>(mut slf: PyRefMut<'a, Self>, yes: bool) -> PyRefMut<'a, Self> {
|
|
192
|
-
slf.0.git_exclude(yes);
|
|
193
|
-
|
|
194
|
-
slf
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
fn require_git<'a>(mut slf: PyRefMut<'a, Self>, yes: bool) -> PyRefMut<'a, Self> {
|
|
198
|
-
slf.0.require_git(yes);
|
|
199
|
-
|
|
200
|
-
slf
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
fn overrides<'a>(mut slf: PyRefMut<'a, Self>, overrides: overrides::Override) -> PyRefMut<'a, Self> {
|
|
204
|
-
slf.0.overrides(overrides.0);
|
|
205
|
-
|
|
206
|
-
slf
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
fn follow_links<'a>(mut slf: PyRefMut<'a, Self>, yes: bool) -> PyRefMut<'a, Self> {
|
|
210
|
-
slf.0.follow_links(yes);
|
|
211
|
-
|
|
212
|
-
slf
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
fn same_file_system<'a>(mut slf: PyRefMut<'a, Self>, yes: bool) -> PyRefMut<'a, Self> {
|
|
216
|
-
slf.0.same_file_system(yes);
|
|
217
|
-
|
|
218
|
-
slf
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
#[pyo3(signature = (depth=None))]
|
|
222
|
-
fn max_depth<'a>(mut slf: PyRefMut<'a, Self>, depth: Option<usize>) -> PyRefMut<'a, Self> {
|
|
223
|
-
slf.0.max_depth(depth);
|
|
224
|
-
|
|
225
|
-
slf
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
fn add_custom_ignore_filename<'a>(mut slf: PyRefMut<'a, Self>, file_name: &str) -> PyRefMut<'a, Self> {
|
|
229
|
-
slf.0.add_custom_ignore_filename(file_name);
|
|
230
|
-
|
|
231
|
-
slf
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
fn add<'a>(mut slf: PyRefMut<'a, Self>, path: PathBuf) -> PyRefMut<'a, Self> {
|
|
235
|
-
slf.0.add(path.0);
|
|
236
|
-
|
|
237
|
-
slf
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
fn add_ignore(&mut self, path: PathBuf) -> PyResult<()> {
|
|
241
|
-
if let Some(e) = self.0.add_ignore(path.0) {
|
|
242
|
-
Err(Error(e).into())
|
|
243
|
-
} else {
|
|
244
|
-
Ok(())
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
fn build(&self) -> Walk {
|
|
249
|
-
Walk(self.0.build())
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
#[pyclass]
|
|
254
|
-
struct Walk(ignore_rust::Walk);
|
|
255
|
-
|
|
256
|
-
#[pymethods]
|
|
257
|
-
impl Walk {
|
|
258
|
-
#[new]
|
|
259
|
-
fn new(path: PathBuf) -> Self {
|
|
260
|
-
Self(ignore_rust::Walk::new(path.0))
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
fn __iter__(slf: PyRef<'_, Self>) -> PyRef<'_, Self> {
|
|
264
|
-
slf
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
fn __next__(mut slf: PyRefMut<'_, Self>) -> Option<Result<DirEntry, Error>> {
|
|
268
|
-
slf.0.next()
|
|
269
|
-
.map(|res| res
|
|
270
|
-
.map(|dent| DirEntry(dent))
|
|
271
|
-
.map_err(|e| Error(e)))
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
mod overrides {
|
|
276
|
-
use super::*;
|
|
277
|
-
|
|
278
|
-
#[pyclass]
|
|
279
|
-
#[derive(Clone)]
|
|
280
|
-
pub struct Override(pub ignore_rust::overrides::Override);
|
|
281
|
-
|
|
282
|
-
#[pyclass]
|
|
283
|
-
pub struct OverrideBuilder(ignore_rust::overrides::OverrideBuilder);
|
|
284
|
-
|
|
285
|
-
#[pymethods]
|
|
286
|
-
impl OverrideBuilder {
|
|
287
|
-
#[new]
|
|
288
|
-
fn new(py: Python<'_>, path: &Bound<'_, PyAny>) -> Result<Self, PyErr> {
|
|
289
|
-
let builtins = PyModule::import_bound(py, "builtins")?;
|
|
290
|
-
|
|
291
|
-
let path = builtins
|
|
292
|
-
.getattr("str")?
|
|
293
|
-
.call1((path,))?;
|
|
294
|
-
let path: &str = path
|
|
295
|
-
.extract()?;
|
|
296
|
-
let path = std::path::Path::new(path);
|
|
297
|
-
|
|
298
|
-
Ok(Self(ignore_rust::overrides::OverrideBuilder::new(path)))
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
fn build(&self) -> Result<Override, Error> {
|
|
302
|
-
self.0.build()
|
|
303
|
-
.map(|o| Override(o))
|
|
304
|
-
.map_err(|e| Error(e))
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
fn add<'a>(mut slf: PyRefMut<'a, Self>, glob: &'a str) -> Result<PyRefMut<'a, Self>, Error> {
|
|
308
|
-
match slf.0.add(glob) {
|
|
309
|
-
Ok(_) => Ok(slf),
|
|
310
|
-
Err(e) => Err(Error(e))
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|