pseek 3.8.0__tar.gz → 3.9.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.
- {pseek-3.8.0 → pseek-3.9.0}/PKG-INFO +113 -47
- {pseek-3.8.0 → pseek-3.9.0}/README.md +112 -46
- {pseek-3.8.0 → pseek-3.9.0}/pseek/cli.py +2 -2
- {pseek-3.8.0 → pseek-3.9.0}/pseek/core/archive.py +3 -3
- pseek-3.9.0/pseek/core/parser.py +1021 -0
- {pseek-3.8.0 → pseek-3.9.0}/pseek/core/search/search.py +86 -21
- {pseek-3.8.0 → pseek-3.9.0}/pseek/core/search/timeout.py +2 -2
- {pseek-3.8.0 → pseek-3.9.0}/pseek/core/walk.py +5 -2
- {pseek-3.8.0 → pseek-3.9.0}/pseek/output.py +13 -10
- {pseek-3.8.0 → pseek-3.9.0}/pseek/structs.py +19 -19
- {pseek-3.8.0 → pseek-3.9.0}/pyproject.toml +3 -3
- pseek-3.8.0/pseek/core/parser.py +0 -435
- {pseek-3.8.0 → pseek-3.9.0}/.gitattributes +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/.github/workflows/publish.yml +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/.gitignore +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/Cargo.lock +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/Cargo.toml +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/LICENSE +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/pseek/__init__.py +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/pseek/compound_extensions +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/pseek/core/search/parallel.py +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/pseek/sorting.py +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/pseek/utils.py +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/scripts/check_version.py +0 -0
- {pseek-3.8.0 → pseek-3.9.0}/src/lib.rs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pseek
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.9.0
|
|
4
4
|
Classifier: Development Status :: 5 - Production/Stable
|
|
5
5
|
Classifier: Environment :: Console
|
|
6
6
|
Classifier: Intended Audience :: Developers
|
|
@@ -34,53 +34,24 @@ Fast and powerful command-line search tool for finding files, directories, and t
|
|
|
34
34
|
|
|
35
35
|
* [Features](#features)
|
|
36
36
|
* [Installation](#installation)
|
|
37
|
-
* [Install from PyPI](#install-from-pypi-recommended)
|
|
38
|
-
* [Install from Source](#install-from-source)
|
|
39
37
|
* [Basic Usage](#basic-usage)
|
|
40
38
|
* [Command Options Table](#command-options)
|
|
41
39
|
* [Specifying the Root Directory](#specifying-the-root-directory)
|
|
42
40
|
* [Search Types](#search-types)
|
|
43
|
-
* [File Names](#search-file-names)
|
|
44
|
-
* [Directory Names](#search-directory-names)
|
|
45
|
-
* [File Contents](#search-file-contents)
|
|
46
|
-
* [All Types Simultaneously](#search-everywhere)
|
|
47
41
|
* [Query Modes](#query-modes)
|
|
48
|
-
* [Case Sensitive](#case-sensitive-search)
|
|
49
|
-
* [Whole Word](#whole-word-search)
|
|
50
|
-
* [Regular Expression (Regex)](#regular-expression-search)
|
|
51
|
-
* [Fuzzy](#fuzzy-search)
|
|
52
|
-
* [Fuzzy Similarity Threshold](#fuzzy-similarity-threshold)
|
|
53
|
-
* [Full Path](#full-path)
|
|
54
|
-
* [Line](#line)
|
|
55
42
|
* [Expression Queries](#expression-queries)
|
|
56
43
|
* [Operators](#supported-operators)
|
|
57
|
-
* [AND](#and)
|
|
58
|
-
* [OR](#or)
|
|
59
|
-
* [NOT](#not)
|
|
60
|
-
* [PARENTHESES](#parentheses)
|
|
61
44
|
* [Prefixes](#expression-prefixes)
|
|
62
|
-
* [Regex](#regex)
|
|
63
|
-
* [Case Sensitive](#case-sensitive)
|
|
64
|
-
* [Whole Word](#whole-word)
|
|
65
|
-
* [Fuzzy](#fuzzy)
|
|
66
|
-
* [Full Path](#full-path-1)
|
|
67
|
-
* [Line](#line-1)
|
|
68
|
-
* [Combined Prefixes](#combined-prefixes)
|
|
69
45
|
* [Automatic Filtering](#automatic-filtering)
|
|
70
46
|
* [Manual Filtering](#manual-filtering)
|
|
71
47
|
* [Globs](#globs)
|
|
72
48
|
* [Extension](#extension-filters)
|
|
73
49
|
* [Path](#path-filters)
|
|
74
|
-
* [Include](#include-paths)
|
|
75
|
-
* [Exclude](#exclude-paths)
|
|
76
50
|
* [Regex Path](#regex-path-filters)
|
|
77
|
-
* [Include](#include)
|
|
78
|
-
* [Exclude](#exclude)
|
|
79
51
|
* [Size](#size-filtering)
|
|
80
52
|
* [Depth](#depth)
|
|
81
53
|
* [Parallel Search](#parallel-search)
|
|
82
54
|
* [Archive Search](#archive-search)
|
|
83
|
-
* [Nested Archives](#nested-archives)
|
|
84
55
|
* [Archive Filters](#archive-filters)
|
|
85
56
|
* [Depth](#archive-depth)
|
|
86
57
|
* [Extension](#extension-filters-1)
|
|
@@ -93,9 +64,6 @@ Fast and powerful command-line search tool for finding files, directories, and t
|
|
|
93
64
|
* [Context](#context)
|
|
94
65
|
* [Timeout](#timeout)
|
|
95
66
|
* [Statistics](#statistics)
|
|
96
|
-
* [Result Statistics](#result-statistics)
|
|
97
|
-
* [Search Statistics](#search-statistics)
|
|
98
|
-
* [Search time](#search-time)
|
|
99
67
|
* [Sorting Results](#sorting-results)
|
|
100
68
|
* [Details](#details)
|
|
101
69
|
* [Requirements](#requirements)
|
|
@@ -486,6 +454,104 @@ psk '("foo" or "bar") and not "baz"' --expr
|
|
|
486
454
|
|
|
487
455
|
Used for grouping expressions.
|
|
488
456
|
|
|
457
|
+
#### Proximity Operators: `NEAR` and `BEFORE`
|
|
458
|
+
|
|
459
|
+
`NEAR` and `BEFORE` allow you to find two search terms based on their distance and relative order within the same line.
|
|
460
|
+
|
|
461
|
+
Unlike `AND`, which only requires both terms to appear somewhere in the line, proximity operators let you control how close the terms must be.
|
|
462
|
+
|
|
463
|
+
**NEAR**
|
|
464
|
+
|
|
465
|
+
`NEAR` matches two terms regardless of their order, provided their distance falls within the specified range.
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
psk '"foo" near/3 "bar"' --expr
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
The terms must be exactly 3 words apart. Either term can appear first.
|
|
472
|
+
|
|
473
|
+
**BEFORE**
|
|
474
|
+
|
|
475
|
+
`BEFORE` requires the left-hand term to appear before the right-hand term.
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
psk '"foo" before/3 "bar"' --expr
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
The terms must appear in the specified order and be exactly 3 words apart.
|
|
482
|
+
|
|
483
|
+
Using `BEFORE` without a distance constraint is also supported:
|
|
484
|
+
|
|
485
|
+
```bash
|
|
486
|
+
psk '"foo" before "bar"' --expr
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
This matches whenever `foo` appears before `bar`, regardless of the distance between them.
|
|
490
|
+
|
|
491
|
+
**Distance Syntax**
|
|
492
|
+
|
|
493
|
+
Both operators support the following distance formats:
|
|
494
|
+
|
|
495
|
+
| Syntax | Meaning |
|
|
496
|
+
|---|---|
|
|
497
|
+
| `NEAR/3` | Exactly 3 words apart |
|
|
498
|
+
| `NEAR/3:` | At least 3 words apart |
|
|
499
|
+
| `NEAR/:3` | At most 3 words apart |
|
|
500
|
+
| `NEAR/2:5` | Between 2 and 5 words apart (inclusive) |
|
|
501
|
+
| `BEFORE/3` | Exactly 3 words apart, in order |
|
|
502
|
+
| `BEFORE/3:` | At least 3 words apart, in order |
|
|
503
|
+
| `BEFORE/:3` | At most 3 words apart, in order |
|
|
504
|
+
| `BEFORE/2:5` | Between 2 and 5 words apart, in order |
|
|
505
|
+
| `BEFORE` | In order, with no distance limit |
|
|
506
|
+
|
|
507
|
+
`NEAR` requires an explicit distance specification. `BEFORE` can be used with or without one.
|
|
508
|
+
|
|
509
|
+
**How Word Distance Is Calculated**
|
|
510
|
+
|
|
511
|
+
Distance is based on word positions, not character counts.
|
|
512
|
+
|
|
513
|
+
- Terms matching within the same word have a distance of `0`.
|
|
514
|
+
- Terms matching in adjacent words have a distance of `1`.
|
|
515
|
+
- One intervening word results in a distance of `2`.
|
|
516
|
+
|
|
517
|
+
For example:
|
|
518
|
+
|
|
519
|
+
```text
|
|
520
|
+
alpha beta
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
The distance between `alpha` and `beta` is `1`.
|
|
524
|
+
|
|
525
|
+
```text
|
|
526
|
+
alpha x beta
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
The distance between `alpha` and `beta` is `2`.
|
|
530
|
+
|
|
531
|
+
Partial matches are also supported. A term does not need to match an entire word to participate in a proximity match.
|
|
532
|
+
|
|
533
|
+
For example, in: `hello123world`
|
|
534
|
+
|
|
535
|
+
The terms `"123"` and `"world"` have a distance of `0`, because both occur within the same word.
|
|
536
|
+
|
|
537
|
+
**Combining with Other Operators**
|
|
538
|
+
|
|
539
|
+
`NEAR` and `BEFORE` can be combined with `AND`, `OR`, and `NOT`, as well as parentheses.
|
|
540
|
+
|
|
541
|
+
```bash
|
|
542
|
+
psk '"error" near/3 "timeout" and "connection"' --expr
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
```bash
|
|
546
|
+
psk '("failed" before/2 "authentication") or "access denied"' --expr
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
```bash
|
|
550
|
+
psk 'not "warning" near/5 "deprecated"' --expr
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
> **Note:** Fuzzy matching is supported only when combined with whole-word matching (`f` and `w` prefixes): `fw"conection" near/3 "timeout"`. Fuzzy substring matching and whole-line matching are not supported with `NEAR` and `BEFORE`. Each operand must be an individual search term rather than a compound logical expression.
|
|
554
|
+
|
|
489
555
|
### Expression Prefixes
|
|
490
556
|
|
|
491
557
|
Each term can have its own search mode.
|
|
@@ -970,7 +1036,7 @@ If the search exceeds the limit, it will be terminated. Results found before the
|
|
|
970
1036
|
Display a summary of the search, including result counts, scanned paths, archive information, and search time.
|
|
971
1037
|
|
|
972
1038
|
```bash
|
|
973
|
-
|
|
1039
|
+
psk config --archive --stats
|
|
974
1040
|
```
|
|
975
1041
|
|
|
976
1042
|
Example output:
|
|
@@ -1024,7 +1090,7 @@ The `--sort` option sorts search results in ascending order. It supports multipl
|
|
|
1024
1090
|
Use the option multiple times to specify the desired order of criteria:
|
|
1025
1091
|
|
|
1026
1092
|
```bash
|
|
1027
|
-
|
|
1093
|
+
psk --sort depth --sort modified
|
|
1028
1094
|
```
|
|
1029
1095
|
|
|
1030
1096
|
Results are sorted by depth first. If two or more results have the same depth, their modification times are used as secondary criteria. The order in which criteria are specified determines their priority.
|
|
@@ -1034,7 +1100,7 @@ By default, sorting is disabled (`none`). Without explicit sorting, results are
|
|
|
1034
1100
|
Use `--sort-rev` to reverse the sorting order (descending):
|
|
1035
1101
|
|
|
1036
1102
|
```bash
|
|
1037
|
-
|
|
1103
|
+
psk --sort size --sort modified --sort-rev
|
|
1038
1104
|
```
|
|
1039
1105
|
|
|
1040
1106
|
Missing values (`None`) are always placed at the end, regardless of the sorting direction.
|
|
@@ -1080,31 +1146,31 @@ Natural path sorting also provides the following features:
|
|
|
1080
1146
|
Sort by path, then by modification time:
|
|
1081
1147
|
|
|
1082
1148
|
```bash
|
|
1083
|
-
|
|
1149
|
+
psk --sort path --sort modified
|
|
1084
1150
|
```
|
|
1085
1151
|
|
|
1086
1152
|
Sort by size in descending order:
|
|
1087
1153
|
|
|
1088
1154
|
```bash
|
|
1089
|
-
|
|
1155
|
+
psk --sort size --sort-rev
|
|
1090
1156
|
```
|
|
1091
1157
|
|
|
1092
1158
|
Sort by depth, then by path, then by access time:
|
|
1093
1159
|
|
|
1094
1160
|
```bash
|
|
1095
|
-
|
|
1161
|
+
psk --sort depth --sort path --sort accessed
|
|
1096
1162
|
```
|
|
1097
1163
|
|
|
1098
1164
|
Use natural path sorting:
|
|
1099
1165
|
|
|
1100
1166
|
```bash
|
|
1101
|
-
|
|
1167
|
+
psk --sort natpath
|
|
1102
1168
|
```
|
|
1103
1169
|
|
|
1104
1170
|
Use natural path sorting followed by descending modification time:
|
|
1105
1171
|
|
|
1106
1172
|
```bash
|
|
1107
|
-
|
|
1173
|
+
psk --sort natpath --sort modified --sort-rev
|
|
1108
1174
|
```
|
|
1109
1175
|
|
|
1110
1176
|
> **Note:** Access times depend on filesystem and operating system behavior. Filesystems may restrict or skip access-time updates through options such as `relatime`, `noatime`, or `nodiratime`. Consequently, access-time sorting may not always reflect the exact time of the most recent access. This behavior is determined by the filesystem, not by `pseek`.
|
|
@@ -1133,31 +1199,31 @@ Available fields:
|
|
|
1133
1199
|
Display all metadata fields:
|
|
1134
1200
|
|
|
1135
1201
|
```bash
|
|
1136
|
-
|
|
1202
|
+
psk query --details
|
|
1137
1203
|
```
|
|
1138
1204
|
|
|
1139
1205
|
Display only file sizes:
|
|
1140
1206
|
|
|
1141
1207
|
```bash
|
|
1142
|
-
|
|
1208
|
+
psk query --details size
|
|
1143
1209
|
```
|
|
1144
1210
|
|
|
1145
1211
|
Display file sizes and modification times:
|
|
1146
1212
|
|
|
1147
1213
|
```bash
|
|
1148
|
-
|
|
1214
|
+
psk query --details size --details modified
|
|
1149
1215
|
```
|
|
1150
1216
|
|
|
1151
1217
|
Display selected fields using explicit assignment:
|
|
1152
1218
|
|
|
1153
1219
|
```bash
|
|
1154
|
-
|
|
1220
|
+
psk --details=size --details=accessed query
|
|
1155
1221
|
```
|
|
1156
1222
|
|
|
1157
1223
|
The special value `all` can also be used explicitly:
|
|
1158
1224
|
|
|
1159
1225
|
```bash
|
|
1160
|
-
|
|
1226
|
+
psk query --details=all
|
|
1161
1227
|
```
|
|
1162
1228
|
|
|
1163
1229
|
**Additional notes:**
|
|
@@ -1166,7 +1232,7 @@ pseek query --details=all
|
|
|
1166
1232
|
- Modification and access times may be unavailable for some archive entries, depending on the archive format and the metadata stored in it.
|
|
1167
1233
|
- Access times may be inaccurate or outdated depending on filesystem settings, such as `relatime`, `noatime`, or `nodiratime`.
|
|
1168
1234
|
- Symbolic link targets do not have a filesystem traversal depth in the same way as their original paths, so their depth may be unavailable.
|
|
1169
|
-
- Match counts may be `0` when match positions are not calculated, such as
|
|
1235
|
+
- Match counts may be `0` when match positions are not calculated, such as fuzzy search.
|
|
1170
1236
|
- Unavailable or inapplicable values are displayed as `—`.
|
|
1171
1237
|
|
|
1172
1238
|
## Requirements
|
|
@@ -6,53 +6,24 @@ Fast and powerful command-line search tool for finding files, directories, and t
|
|
|
6
6
|
|
|
7
7
|
* [Features](#features)
|
|
8
8
|
* [Installation](#installation)
|
|
9
|
-
* [Install from PyPI](#install-from-pypi-recommended)
|
|
10
|
-
* [Install from Source](#install-from-source)
|
|
11
9
|
* [Basic Usage](#basic-usage)
|
|
12
10
|
* [Command Options Table](#command-options)
|
|
13
11
|
* [Specifying the Root Directory](#specifying-the-root-directory)
|
|
14
12
|
* [Search Types](#search-types)
|
|
15
|
-
* [File Names](#search-file-names)
|
|
16
|
-
* [Directory Names](#search-directory-names)
|
|
17
|
-
* [File Contents](#search-file-contents)
|
|
18
|
-
* [All Types Simultaneously](#search-everywhere)
|
|
19
13
|
* [Query Modes](#query-modes)
|
|
20
|
-
* [Case Sensitive](#case-sensitive-search)
|
|
21
|
-
* [Whole Word](#whole-word-search)
|
|
22
|
-
* [Regular Expression (Regex)](#regular-expression-search)
|
|
23
|
-
* [Fuzzy](#fuzzy-search)
|
|
24
|
-
* [Fuzzy Similarity Threshold](#fuzzy-similarity-threshold)
|
|
25
|
-
* [Full Path](#full-path)
|
|
26
|
-
* [Line](#line)
|
|
27
14
|
* [Expression Queries](#expression-queries)
|
|
28
15
|
* [Operators](#supported-operators)
|
|
29
|
-
* [AND](#and)
|
|
30
|
-
* [OR](#or)
|
|
31
|
-
* [NOT](#not)
|
|
32
|
-
* [PARENTHESES](#parentheses)
|
|
33
16
|
* [Prefixes](#expression-prefixes)
|
|
34
|
-
* [Regex](#regex)
|
|
35
|
-
* [Case Sensitive](#case-sensitive)
|
|
36
|
-
* [Whole Word](#whole-word)
|
|
37
|
-
* [Fuzzy](#fuzzy)
|
|
38
|
-
* [Full Path](#full-path-1)
|
|
39
|
-
* [Line](#line-1)
|
|
40
|
-
* [Combined Prefixes](#combined-prefixes)
|
|
41
17
|
* [Automatic Filtering](#automatic-filtering)
|
|
42
18
|
* [Manual Filtering](#manual-filtering)
|
|
43
19
|
* [Globs](#globs)
|
|
44
20
|
* [Extension](#extension-filters)
|
|
45
21
|
* [Path](#path-filters)
|
|
46
|
-
* [Include](#include-paths)
|
|
47
|
-
* [Exclude](#exclude-paths)
|
|
48
22
|
* [Regex Path](#regex-path-filters)
|
|
49
|
-
* [Include](#include)
|
|
50
|
-
* [Exclude](#exclude)
|
|
51
23
|
* [Size](#size-filtering)
|
|
52
24
|
* [Depth](#depth)
|
|
53
25
|
* [Parallel Search](#parallel-search)
|
|
54
26
|
* [Archive Search](#archive-search)
|
|
55
|
-
* [Nested Archives](#nested-archives)
|
|
56
27
|
* [Archive Filters](#archive-filters)
|
|
57
28
|
* [Depth](#archive-depth)
|
|
58
29
|
* [Extension](#extension-filters-1)
|
|
@@ -65,9 +36,6 @@ Fast and powerful command-line search tool for finding files, directories, and t
|
|
|
65
36
|
* [Context](#context)
|
|
66
37
|
* [Timeout](#timeout)
|
|
67
38
|
* [Statistics](#statistics)
|
|
68
|
-
* [Result Statistics](#result-statistics)
|
|
69
|
-
* [Search Statistics](#search-statistics)
|
|
70
|
-
* [Search time](#search-time)
|
|
71
39
|
* [Sorting Results](#sorting-results)
|
|
72
40
|
* [Details](#details)
|
|
73
41
|
* [Requirements](#requirements)
|
|
@@ -458,6 +426,104 @@ psk '("foo" or "bar") and not "baz"' --expr
|
|
|
458
426
|
|
|
459
427
|
Used for grouping expressions.
|
|
460
428
|
|
|
429
|
+
#### Proximity Operators: `NEAR` and `BEFORE`
|
|
430
|
+
|
|
431
|
+
`NEAR` and `BEFORE` allow you to find two search terms based on their distance and relative order within the same line.
|
|
432
|
+
|
|
433
|
+
Unlike `AND`, which only requires both terms to appear somewhere in the line, proximity operators let you control how close the terms must be.
|
|
434
|
+
|
|
435
|
+
**NEAR**
|
|
436
|
+
|
|
437
|
+
`NEAR` matches two terms regardless of their order, provided their distance falls within the specified range.
|
|
438
|
+
|
|
439
|
+
```bash
|
|
440
|
+
psk '"foo" near/3 "bar"' --expr
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
The terms must be exactly 3 words apart. Either term can appear first.
|
|
444
|
+
|
|
445
|
+
**BEFORE**
|
|
446
|
+
|
|
447
|
+
`BEFORE` requires the left-hand term to appear before the right-hand term.
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
psk '"foo" before/3 "bar"' --expr
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
The terms must appear in the specified order and be exactly 3 words apart.
|
|
454
|
+
|
|
455
|
+
Using `BEFORE` without a distance constraint is also supported:
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
psk '"foo" before "bar"' --expr
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
This matches whenever `foo` appears before `bar`, regardless of the distance between them.
|
|
462
|
+
|
|
463
|
+
**Distance Syntax**
|
|
464
|
+
|
|
465
|
+
Both operators support the following distance formats:
|
|
466
|
+
|
|
467
|
+
| Syntax | Meaning |
|
|
468
|
+
|---|---|
|
|
469
|
+
| `NEAR/3` | Exactly 3 words apart |
|
|
470
|
+
| `NEAR/3:` | At least 3 words apart |
|
|
471
|
+
| `NEAR/:3` | At most 3 words apart |
|
|
472
|
+
| `NEAR/2:5` | Between 2 and 5 words apart (inclusive) |
|
|
473
|
+
| `BEFORE/3` | Exactly 3 words apart, in order |
|
|
474
|
+
| `BEFORE/3:` | At least 3 words apart, in order |
|
|
475
|
+
| `BEFORE/:3` | At most 3 words apart, in order |
|
|
476
|
+
| `BEFORE/2:5` | Between 2 and 5 words apart, in order |
|
|
477
|
+
| `BEFORE` | In order, with no distance limit |
|
|
478
|
+
|
|
479
|
+
`NEAR` requires an explicit distance specification. `BEFORE` can be used with or without one.
|
|
480
|
+
|
|
481
|
+
**How Word Distance Is Calculated**
|
|
482
|
+
|
|
483
|
+
Distance is based on word positions, not character counts.
|
|
484
|
+
|
|
485
|
+
- Terms matching within the same word have a distance of `0`.
|
|
486
|
+
- Terms matching in adjacent words have a distance of `1`.
|
|
487
|
+
- One intervening word results in a distance of `2`.
|
|
488
|
+
|
|
489
|
+
For example:
|
|
490
|
+
|
|
491
|
+
```text
|
|
492
|
+
alpha beta
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
The distance between `alpha` and `beta` is `1`.
|
|
496
|
+
|
|
497
|
+
```text
|
|
498
|
+
alpha x beta
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
The distance between `alpha` and `beta` is `2`.
|
|
502
|
+
|
|
503
|
+
Partial matches are also supported. A term does not need to match an entire word to participate in a proximity match.
|
|
504
|
+
|
|
505
|
+
For example, in: `hello123world`
|
|
506
|
+
|
|
507
|
+
The terms `"123"` and `"world"` have a distance of `0`, because both occur within the same word.
|
|
508
|
+
|
|
509
|
+
**Combining with Other Operators**
|
|
510
|
+
|
|
511
|
+
`NEAR` and `BEFORE` can be combined with `AND`, `OR`, and `NOT`, as well as parentheses.
|
|
512
|
+
|
|
513
|
+
```bash
|
|
514
|
+
psk '"error" near/3 "timeout" and "connection"' --expr
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
```bash
|
|
518
|
+
psk '("failed" before/2 "authentication") or "access denied"' --expr
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
```bash
|
|
522
|
+
psk 'not "warning" near/5 "deprecated"' --expr
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
> **Note:** Fuzzy matching is supported only when combined with whole-word matching (`f` and `w` prefixes): `fw"conection" near/3 "timeout"`. Fuzzy substring matching and whole-line matching are not supported with `NEAR` and `BEFORE`. Each operand must be an individual search term rather than a compound logical expression.
|
|
526
|
+
|
|
461
527
|
### Expression Prefixes
|
|
462
528
|
|
|
463
529
|
Each term can have its own search mode.
|
|
@@ -942,7 +1008,7 @@ If the search exceeds the limit, it will be terminated. Results found before the
|
|
|
942
1008
|
Display a summary of the search, including result counts, scanned paths, archive information, and search time.
|
|
943
1009
|
|
|
944
1010
|
```bash
|
|
945
|
-
|
|
1011
|
+
psk config --archive --stats
|
|
946
1012
|
```
|
|
947
1013
|
|
|
948
1014
|
Example output:
|
|
@@ -996,7 +1062,7 @@ The `--sort` option sorts search results in ascending order. It supports multipl
|
|
|
996
1062
|
Use the option multiple times to specify the desired order of criteria:
|
|
997
1063
|
|
|
998
1064
|
```bash
|
|
999
|
-
|
|
1065
|
+
psk --sort depth --sort modified
|
|
1000
1066
|
```
|
|
1001
1067
|
|
|
1002
1068
|
Results are sorted by depth first. If two or more results have the same depth, their modification times are used as secondary criteria. The order in which criteria are specified determines their priority.
|
|
@@ -1006,7 +1072,7 @@ By default, sorting is disabled (`none`). Without explicit sorting, results are
|
|
|
1006
1072
|
Use `--sort-rev` to reverse the sorting order (descending):
|
|
1007
1073
|
|
|
1008
1074
|
```bash
|
|
1009
|
-
|
|
1075
|
+
psk --sort size --sort modified --sort-rev
|
|
1010
1076
|
```
|
|
1011
1077
|
|
|
1012
1078
|
Missing values (`None`) are always placed at the end, regardless of the sorting direction.
|
|
@@ -1052,31 +1118,31 @@ Natural path sorting also provides the following features:
|
|
|
1052
1118
|
Sort by path, then by modification time:
|
|
1053
1119
|
|
|
1054
1120
|
```bash
|
|
1055
|
-
|
|
1121
|
+
psk --sort path --sort modified
|
|
1056
1122
|
```
|
|
1057
1123
|
|
|
1058
1124
|
Sort by size in descending order:
|
|
1059
1125
|
|
|
1060
1126
|
```bash
|
|
1061
|
-
|
|
1127
|
+
psk --sort size --sort-rev
|
|
1062
1128
|
```
|
|
1063
1129
|
|
|
1064
1130
|
Sort by depth, then by path, then by access time:
|
|
1065
1131
|
|
|
1066
1132
|
```bash
|
|
1067
|
-
|
|
1133
|
+
psk --sort depth --sort path --sort accessed
|
|
1068
1134
|
```
|
|
1069
1135
|
|
|
1070
1136
|
Use natural path sorting:
|
|
1071
1137
|
|
|
1072
1138
|
```bash
|
|
1073
|
-
|
|
1139
|
+
psk --sort natpath
|
|
1074
1140
|
```
|
|
1075
1141
|
|
|
1076
1142
|
Use natural path sorting followed by descending modification time:
|
|
1077
1143
|
|
|
1078
1144
|
```bash
|
|
1079
|
-
|
|
1145
|
+
psk --sort natpath --sort modified --sort-rev
|
|
1080
1146
|
```
|
|
1081
1147
|
|
|
1082
1148
|
> **Note:** Access times depend on filesystem and operating system behavior. Filesystems may restrict or skip access-time updates through options such as `relatime`, `noatime`, or `nodiratime`. Consequently, access-time sorting may not always reflect the exact time of the most recent access. This behavior is determined by the filesystem, not by `pseek`.
|
|
@@ -1105,31 +1171,31 @@ Available fields:
|
|
|
1105
1171
|
Display all metadata fields:
|
|
1106
1172
|
|
|
1107
1173
|
```bash
|
|
1108
|
-
|
|
1174
|
+
psk query --details
|
|
1109
1175
|
```
|
|
1110
1176
|
|
|
1111
1177
|
Display only file sizes:
|
|
1112
1178
|
|
|
1113
1179
|
```bash
|
|
1114
|
-
|
|
1180
|
+
psk query --details size
|
|
1115
1181
|
```
|
|
1116
1182
|
|
|
1117
1183
|
Display file sizes and modification times:
|
|
1118
1184
|
|
|
1119
1185
|
```bash
|
|
1120
|
-
|
|
1186
|
+
psk query --details size --details modified
|
|
1121
1187
|
```
|
|
1122
1188
|
|
|
1123
1189
|
Display selected fields using explicit assignment:
|
|
1124
1190
|
|
|
1125
1191
|
```bash
|
|
1126
|
-
|
|
1192
|
+
psk --details=size --details=accessed query
|
|
1127
1193
|
```
|
|
1128
1194
|
|
|
1129
1195
|
The special value `all` can also be used explicitly:
|
|
1130
1196
|
|
|
1131
1197
|
```bash
|
|
1132
|
-
|
|
1198
|
+
psk query --details=all
|
|
1133
1199
|
```
|
|
1134
1200
|
|
|
1135
1201
|
**Additional notes:**
|
|
@@ -1138,7 +1204,7 @@ pseek query --details=all
|
|
|
1138
1204
|
- Modification and access times may be unavailable for some archive entries, depending on the archive format and the metadata stored in it.
|
|
1139
1205
|
- Access times may be inaccurate or outdated depending on filesystem settings, such as `relatime`, `noatime`, or `nodiratime`.
|
|
1140
1206
|
- Symbolic link targets do not have a filesystem traversal depth in the same way as their original paths, so their depth may be unavailable.
|
|
1141
|
-
- Match counts may be `0` when match positions are not calculated, such as
|
|
1207
|
+
- Match counts may be `0` when match positions are not calculated, such as fuzzy search.
|
|
1142
1208
|
- Unavailable or inapplicable values are displayed as `—`.
|
|
1143
1209
|
|
|
1144
1210
|
## Requirements
|
|
@@ -212,7 +212,7 @@ def normalize_details(ctx, param, value):
|
|
|
212
212
|
is_flag=False,
|
|
213
213
|
flag_value='all',
|
|
214
214
|
default=(),
|
|
215
|
-
metavar='
|
|
215
|
+
metavar='FIELD',
|
|
216
216
|
help='Show metadata next to result paths. '
|
|
217
217
|
'If used without a value, all metadata fields are displayed. '
|
|
218
218
|
'Available fields: size, modified, accessed, depth, matches. '
|
|
@@ -281,7 +281,7 @@ def search(**kwargs):
|
|
|
281
281
|
start = time.perf_counter()
|
|
282
282
|
results, metrics = seek(config)
|
|
283
283
|
elapsed = time.perf_counter() - start
|
|
284
|
-
|
|
284
|
+
|
|
285
285
|
echo(results, config)
|
|
286
286
|
if config.stats:
|
|
287
287
|
echo_stats(config, results, metrics, elapsed)
|
|
@@ -380,7 +380,7 @@ def extract_text_from_archive(file_path: SysPath, config, depth: int = -1,
|
|
|
380
380
|
head = file_data.read(8192)
|
|
381
381
|
if is_binary(head) and file_name.suffix not in ARCHIVE_EXTS:
|
|
382
382
|
continue
|
|
383
|
-
|
|
383
|
+
|
|
384
384
|
data = head + file_data.read()
|
|
385
385
|
if file_name.suffix in ARCHIVE_EXTS:
|
|
386
386
|
if any(new_depth < d[1] for d in config.arc_depth):
|
|
@@ -400,7 +400,7 @@ def extract_text_from_archive(file_path: SysPath, config, depth: int = -1,
|
|
|
400
400
|
for member in tf.getmembers():
|
|
401
401
|
if member.isdir():
|
|
402
402
|
continue
|
|
403
|
-
|
|
403
|
+
|
|
404
404
|
f = tf.extractfile(member)
|
|
405
405
|
if f is None:
|
|
406
406
|
continue
|
|
@@ -432,7 +432,7 @@ def extract_text_from_archive(file_path: SysPath, config, depth: int = -1,
|
|
|
432
432
|
|
|
433
433
|
if archive_should_skip(file_name, config):
|
|
434
434
|
continue
|
|
435
|
-
|
|
435
|
+
|
|
436
436
|
head = f.read(8192)
|
|
437
437
|
if is_binary(head) and file_name.suffix not in ARCHIVE_EXTS:
|
|
438
438
|
continue
|