pseek 3.7.0__tar.gz → 3.8.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/.github/workflows/publish.yml +154 -0
- {pseek-3.7.0 → pseek-3.8.0}/PKG-INFO +168 -11
- {pseek-3.7.0 → pseek-3.8.0}/README.md +167 -10
- {pseek-3.7.0 → pseek-3.8.0}/pseek/cli.py +59 -251
- pseek-3.8.0/pseek/core/archive.py +454 -0
- {pseek-3.7.0/pseek → pseek-3.8.0/pseek/core}/parser.py +1 -2
- pseek-3.8.0/pseek/core/search/parallel.py +203 -0
- pseek-3.8.0/pseek/core/search/search.py +367 -0
- pseek-3.8.0/pseek/core/search/timeout.py +107 -0
- pseek-3.8.0/pseek/core/walk.py +251 -0
- pseek-3.8.0/pseek/output.py +272 -0
- pseek-3.8.0/pseek/sorting.py +197 -0
- {pseek-3.7.0 → pseek-3.8.0}/pseek/structs.py +94 -10
- {pseek-3.7.0 → pseek-3.8.0}/pseek/utils.py +27 -1
- {pseek-3.7.0 → pseek-3.8.0}/pyproject.toml +1 -1
- pseek-3.7.0/.github/workflows/publish.yml +0 -58
- pseek-3.7.0/pseek/archive.py +0 -304
- pseek-3.7.0/pseek/searcher.py +0 -646
- {pseek-3.7.0 → pseek-3.8.0}/.gitattributes +0 -0
- {pseek-3.7.0 → pseek-3.8.0}/.gitignore +0 -0
- {pseek-3.7.0 → pseek-3.8.0}/Cargo.lock +0 -0
- {pseek-3.7.0 → pseek-3.8.0}/Cargo.toml +0 -0
- {pseek-3.7.0 → pseek-3.8.0}/LICENSE +0 -0
- {pseek-3.7.0 → pseek-3.8.0}/pseek/__init__.py +0 -0
- {pseek-3.7.0 → pseek-3.8.0}/pseek/compound_extensions +0 -0
- {pseek-3.7.0 → pseek-3.8.0}/scripts/check_version.py +0 -0
- {pseek-3.7.0 → pseek-3.8.0}/src/lib.rs +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
# Prevent two publishing workflows from running concurrently.
|
|
9
|
+
concurrency:
|
|
10
|
+
group: pseek-pypi-publish
|
|
11
|
+
cancel-in-progress: false
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
|
|
18
|
+
# Check whether the package version should be published.
|
|
19
|
+
check-version:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
|
|
22
|
+
outputs:
|
|
23
|
+
publish: ${{ steps.check.outputs.publish }}
|
|
24
|
+
|
|
25
|
+
steps:
|
|
26
|
+
|
|
27
|
+
- name: Checkout repository
|
|
28
|
+
uses: actions/checkout@v4
|
|
29
|
+
|
|
30
|
+
- name: Setup Python
|
|
31
|
+
uses: actions/setup-python@v5
|
|
32
|
+
with:
|
|
33
|
+
python-version: "3.12"
|
|
34
|
+
|
|
35
|
+
- name: Install dependencies
|
|
36
|
+
run: |
|
|
37
|
+
python -m pip install --upgrade pip packaging
|
|
38
|
+
|
|
39
|
+
- name: Check package version
|
|
40
|
+
id: check
|
|
41
|
+
run: python scripts/check_version.py
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# Build wheels for multiple operating systems and architectures.
|
|
45
|
+
build-wheels:
|
|
46
|
+
needs: check-version
|
|
47
|
+
if: needs.check-version.outputs.publish == 'true'
|
|
48
|
+
|
|
49
|
+
strategy:
|
|
50
|
+
fail-fast: false
|
|
51
|
+
|
|
52
|
+
matrix:
|
|
53
|
+
include:
|
|
54
|
+
|
|
55
|
+
# Linux x86_64
|
|
56
|
+
- os: ubuntu-latest
|
|
57
|
+
target: x86_64
|
|
58
|
+
platform: linux-x86_64
|
|
59
|
+
manylinux: "2_28"
|
|
60
|
+
|
|
61
|
+
# Linux ARM64
|
|
62
|
+
- os: ubuntu-latest
|
|
63
|
+
target: aarch64
|
|
64
|
+
platform: linux-aarch64
|
|
65
|
+
manylinux: "2_28"
|
|
66
|
+
|
|
67
|
+
# Windows x86_64
|
|
68
|
+
- os: windows-latest
|
|
69
|
+
target: x64
|
|
70
|
+
platform: windows-x86_64
|
|
71
|
+
manylinux: auto
|
|
72
|
+
|
|
73
|
+
# macOS Intel
|
|
74
|
+
- os: macos-15-intel
|
|
75
|
+
target: x86_64
|
|
76
|
+
platform: macos-x86_64
|
|
77
|
+
manylinux: auto
|
|
78
|
+
|
|
79
|
+
# macOS Apple Silicon
|
|
80
|
+
- os: macos-latest
|
|
81
|
+
target: aarch64
|
|
82
|
+
platform: macos-aarch64
|
|
83
|
+
manylinux: auto
|
|
84
|
+
|
|
85
|
+
runs-on: ${{ matrix.os }}
|
|
86
|
+
|
|
87
|
+
steps:
|
|
88
|
+
|
|
89
|
+
- name: Checkout repository
|
|
90
|
+
uses: actions/checkout@v4
|
|
91
|
+
|
|
92
|
+
- name: Setup Python
|
|
93
|
+
uses: actions/setup-python@v5
|
|
94
|
+
with:
|
|
95
|
+
python-version: "3.12"
|
|
96
|
+
|
|
97
|
+
- name: Build wheel
|
|
98
|
+
uses: PyO3/maturin-action@v1
|
|
99
|
+
with:
|
|
100
|
+
target: ${{ matrix.target }}
|
|
101
|
+
manylinux: ${{ matrix.manylinux }}
|
|
102
|
+
args: --release --out dist --compatibility pypi
|
|
103
|
+
sccache: true
|
|
104
|
+
|
|
105
|
+
# Each runner uploads its wheels as a separate artifact.
|
|
106
|
+
- name: Upload wheels
|
|
107
|
+
uses: actions/upload-artifact@v4
|
|
108
|
+
with:
|
|
109
|
+
name: wheels-${{ matrix.platform }}
|
|
110
|
+
path: dist/*.whl
|
|
111
|
+
if-no-files-found: error
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# Collect all wheels, build the source distribution and publish.
|
|
115
|
+
publish:
|
|
116
|
+
needs:
|
|
117
|
+
- check-version
|
|
118
|
+
- build-wheels
|
|
119
|
+
|
|
120
|
+
if: needs.check-version.outputs.publish == 'true'
|
|
121
|
+
|
|
122
|
+
runs-on: ubuntu-latest
|
|
123
|
+
|
|
124
|
+
steps:
|
|
125
|
+
|
|
126
|
+
- name: Checkout repository
|
|
127
|
+
uses: actions/checkout@v4
|
|
128
|
+
|
|
129
|
+
- name: Setup Python
|
|
130
|
+
uses: actions/setup-python@v5
|
|
131
|
+
with:
|
|
132
|
+
python-version: "3.12"
|
|
133
|
+
|
|
134
|
+
- name: Install dependencies
|
|
135
|
+
run: |
|
|
136
|
+
python -m pip install --upgrade pip build
|
|
137
|
+
|
|
138
|
+
# Download wheels produced by all platform jobs.
|
|
139
|
+
- name: Download all wheels
|
|
140
|
+
uses: actions/download-artifact@v4
|
|
141
|
+
with:
|
|
142
|
+
pattern: wheels-*
|
|
143
|
+
path: dist
|
|
144
|
+
merge-multiple: true
|
|
145
|
+
|
|
146
|
+
# Build the source distribution separately.
|
|
147
|
+
- name: Build source distribution
|
|
148
|
+
run: python -m build --sdist --outdir dist
|
|
149
|
+
|
|
150
|
+
- name: Publish to PyPI
|
|
151
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
152
|
+
with:
|
|
153
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
154
|
+
skip-existing: true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pseek
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.8.0
|
|
4
4
|
Classifier: Development Status :: 5 - Production/Stable
|
|
5
5
|
Classifier: Environment :: Console
|
|
6
6
|
Classifier: Intended Audience :: Developers
|
|
@@ -96,6 +96,8 @@ Fast and powerful command-line search tool for finding files, directories, and t
|
|
|
96
96
|
* [Result Statistics](#result-statistics)
|
|
97
97
|
* [Search Statistics](#search-statistics)
|
|
98
98
|
* [Search time](#search-time)
|
|
99
|
+
* [Sorting Results](#sorting-results)
|
|
100
|
+
* [Details](#details)
|
|
99
101
|
* [Requirements](#requirements)
|
|
100
102
|
|
|
101
103
|
## Features
|
|
@@ -121,8 +123,6 @@ Fast and powerful command-line search tool for finding files, directories, and t
|
|
|
121
123
|
|
|
122
124
|
## Installation
|
|
123
125
|
|
|
124
|
-
> **Note:** Pseek includes a native Rust extension. Currently, pre-built wheels are provided for Linux only. If you are installing Pseek on another platform, [Rust and Cargo](https://rust-lang.org/) must be installed so the extension can be built locally.
|
|
125
|
-
|
|
126
126
|
### Install from PyPI (Recommended)
|
|
127
127
|
|
|
128
128
|
```bash
|
|
@@ -244,6 +244,9 @@ psk --exclude build
|
|
|
244
244
|
| `--paths-only` | Only show matching file paths for content search |
|
|
245
245
|
| `--stats` | Show search statistics including result counts and search time |
|
|
246
246
|
| `--threads` | This flag sets the approximate number of threads to use. A value of 0 (which is the default) causes pseek to choose the thread count using heuristics |
|
|
247
|
+
| `--sort` | This option enables sorting of results in ascending order. The possible values for this option are: none, path, size, modified, depth, accessed, matches, natpath. Multiple values can be used simultaneously: --sort depth --sort modified. The results are sorted first by depth, and in the event that the depths are identical, then by modified. Use --sort-rev flag for descending order. For more details about this option and how different values function, see [sorting results section](#sorting-results) |
|
|
248
|
+
| `--sort-rev` | Sets the sort order for the `--sort` option to descending. This option is just a flag. You still need to use `--sort` to specify the sort type |
|
|
249
|
+
| `--details` | Show metadata next to result paths. If used without a value, all metadata fields are displayed. Available fields: size, modified, accessed, depth, matches. This option can be repeated to select multiple fields |
|
|
247
250
|
|
|
248
251
|
## Specifying the Root Directory
|
|
249
252
|
|
|
@@ -273,6 +276,8 @@ psk backup --directory
|
|
|
273
276
|
psk TODO --content
|
|
274
277
|
```
|
|
275
278
|
|
|
279
|
+
> **Note:** When searching through file contents, binary files are automatically ignored, and this behavior cannot be changed. If null bytes are present within the first 8 KiB of a file, it is identified as a binary file (The entire file is not examined, in order to increase speed).
|
|
280
|
+
|
|
276
281
|
### Search Everywhere
|
|
277
282
|
|
|
278
283
|
```bash
|
|
@@ -757,12 +762,12 @@ Controls how deep the search goes inside directories.
|
|
|
757
762
|
A depth of `0` means that only base path's immediate contents are searched; subdirectories are not entered.
|
|
758
763
|
|
|
759
764
|
```text
|
|
760
|
-
project/
|
|
761
|
-
├── file.txt
|
|
762
|
-
├── folder1/
|
|
763
|
-
│ ├── file.txt
|
|
764
|
-
│ └── folder2/
|
|
765
|
-
│ └── file.txt
|
|
765
|
+
project/ <- base directory
|
|
766
|
+
├── file.txt <- depth 0
|
|
767
|
+
├── folder1/ <- depth 0
|
|
768
|
+
│ ├── file.txt <- depth 1
|
|
769
|
+
│ └── folder2/ <- depth 1
|
|
770
|
+
│ └── file.txt <- depth 2
|
|
766
771
|
```
|
|
767
772
|
|
|
768
773
|
`--depth` can be specified multiple times to search non-contiguous depth ranges:
|
|
@@ -965,7 +970,7 @@ If the search exceeds the limit, it will be terminated. Results found before the
|
|
|
965
970
|
Display a summary of the search, including result counts, scanned paths, archive information, and search time.
|
|
966
971
|
|
|
967
972
|
```bash
|
|
968
|
-
pseek config --stats
|
|
973
|
+
pseek config --archive --stats
|
|
969
974
|
```
|
|
970
975
|
|
|
971
976
|
Example output:
|
|
@@ -974,7 +979,7 @@ Example output:
|
|
|
974
979
|
Statistics
|
|
975
980
|
────────────────
|
|
976
981
|
Results
|
|
977
|
-
Files: 12
|
|
982
|
+
Files matched: 12
|
|
978
983
|
Directories matched: 3
|
|
979
984
|
Files with matched content: 8
|
|
980
985
|
Lines matched: 24
|
|
@@ -1012,6 +1017,158 @@ Time spent performing the search.
|
|
|
1012
1017
|
|
|
1013
1018
|
When `--timeout` is used, the statistics represent the work completed before the timeout.
|
|
1014
1019
|
|
|
1020
|
+
### Sorting Results
|
|
1021
|
+
|
|
1022
|
+
The `--sort` option sorts search results in ascending order. It supports multiple values, allowing you to combine different sorting criteria.
|
|
1023
|
+
|
|
1024
|
+
Use the option multiple times to specify the desired order of criteria:
|
|
1025
|
+
|
|
1026
|
+
```bash
|
|
1027
|
+
pseek --sort depth --sort modified
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
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.
|
|
1031
|
+
|
|
1032
|
+
By default, sorting is disabled (`none`). Without explicit sorting, results are returned in their natural discovery order. Since search processing is parallel, this order is not guaranteed and may vary between runs (Unless you use `--threads 1`).
|
|
1033
|
+
|
|
1034
|
+
Use `--sort-rev` to reverse the sorting order (descending):
|
|
1035
|
+
|
|
1036
|
+
```bash
|
|
1037
|
+
pseek --sort size --sort modified --sort-rev
|
|
1038
|
+
```
|
|
1039
|
+
|
|
1040
|
+
Missing values (`None`) are always placed at the end, regardless of the sorting direction.
|
|
1041
|
+
|
|
1042
|
+
Sorting does not disable parallel search. Results are collected first and sorted afterward. Sorting adds some processing overhead, generally proportional to **O(n log n)**, where `n` is the number of results.
|
|
1043
|
+
|
|
1044
|
+
#### Available Sorting Criteria
|
|
1045
|
+
|
|
1046
|
+
| Option | Description |
|
|
1047
|
+
|---|---|
|
|
1048
|
+
| `none` | Disables sorting. This is the default behavior. |
|
|
1049
|
+
| `path` | Sorts by the full path using lexicographical ordering. Relative paths are used by default; absolute paths are used when `--absolute-path` is enabled. Numeric portions are treated as ordinary characters, so `file10.txt` comes before `file2.txt`. |
|
|
1050
|
+
| `size` | Sorts files by their size in bytes. Directories are not sorted by size and retain their existing order unless another applicable sorting criterion is specified. |
|
|
1051
|
+
| `modified` | Sorts by the last modification time. For directories, this refers to the directory itself, not its contents. Archive entries may have unavailable timestamps and are placed at the end. |
|
|
1052
|
+
| `depth` | Sorts by path depth. Symbolic link targets have no depth value and are placed at the end. Archive depth follows archive nesting rather than filesystem directory depth. Nested archive levels are considered when sorting entries within archives. |
|
|
1053
|
+
| `accessed` | Sorts by the last access time. Directory access time generally reflects when the directory's contents were last listed or read, not when one of its files was accessed. Some files and archive entries may not provide this information. |
|
|
1054
|
+
| `matches` | Sorts content search results by the total number of matches. This criterion only affects content results, not file or directory results. When match positions are unavailable, results cannot be distinguished by this criterion and retain their existing relative order. |
|
|
1055
|
+
| `natpath` | Sorts by the full path using natural ordering instead of lexicographical ordering. It recognizes integer sequences, so `file2.txt` comes before `file10.txt`. See the details below. |
|
|
1056
|
+
|
|
1057
|
+
#### Natural Path Sorting (`natpath`)
|
|
1058
|
+
|
|
1059
|
+
Unlike regular `path` sorting, `natpath` recognizes numbers within path components and compares them numerically rather than lexicographically.
|
|
1060
|
+
|
|
1061
|
+
For example:
|
|
1062
|
+
|
|
1063
|
+
```text
|
|
1064
|
+
file1.txt
|
|
1065
|
+
file2.txt
|
|
1066
|
+
file3.txt
|
|
1067
|
+
file10.txt
|
|
1068
|
+
file20.txt
|
|
1069
|
+
```
|
|
1070
|
+
|
|
1071
|
+
Natural path sorting also provides the following features:
|
|
1072
|
+
|
|
1073
|
+
- **Leading zeros:** Numerically equivalent values are grouped together, with shorter representations appearing first. For example: `file1`, `file01`, `file001`.
|
|
1074
|
+
- **Case-insensitive:** Uppercase and lowercase letters are treated as equivalent during comparison.
|
|
1075
|
+
- **Unicode normalization:** Canonically equivalent Unicode characters are normalized before comparison.
|
|
1076
|
+
- **Unicode decimal digits:** Decimal digits from different writing systems are recognized and compared numerically. For example, the Persian digit `۵` is treated as the number `5`.
|
|
1077
|
+
|
|
1078
|
+
#### Examples
|
|
1079
|
+
|
|
1080
|
+
Sort by path, then by modification time:
|
|
1081
|
+
|
|
1082
|
+
```bash
|
|
1083
|
+
pseek --sort path --sort modified
|
|
1084
|
+
```
|
|
1085
|
+
|
|
1086
|
+
Sort by size in descending order:
|
|
1087
|
+
|
|
1088
|
+
```bash
|
|
1089
|
+
pseek --sort size --sort-rev
|
|
1090
|
+
```
|
|
1091
|
+
|
|
1092
|
+
Sort by depth, then by path, then by access time:
|
|
1093
|
+
|
|
1094
|
+
```bash
|
|
1095
|
+
pseek --sort depth --sort path --sort accessed
|
|
1096
|
+
```
|
|
1097
|
+
|
|
1098
|
+
Use natural path sorting:
|
|
1099
|
+
|
|
1100
|
+
```bash
|
|
1101
|
+
pseek --sort natpath
|
|
1102
|
+
```
|
|
1103
|
+
|
|
1104
|
+
Use natural path sorting followed by descending modification time:
|
|
1105
|
+
|
|
1106
|
+
```bash
|
|
1107
|
+
pseek --sort natpath --sort modified --sort-rev
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
> **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`.
|
|
1111
|
+
|
|
1112
|
+
### Details
|
|
1113
|
+
|
|
1114
|
+
Display additional metadata next to result paths. This option accepts an optional field name and can be repeated to select multiple fields.
|
|
1115
|
+
|
|
1116
|
+
- **Without this option:** No additional metadata is displayed.
|
|
1117
|
+
- **`--details` without a value:** Displays all available metadata fields.
|
|
1118
|
+
- **`--details FIELD`:** Displays only the specified field.
|
|
1119
|
+
- **Multiple values:** Repeat the option to display multiple selected fields.
|
|
1120
|
+
|
|
1121
|
+
Available fields:
|
|
1122
|
+
|
|
1123
|
+
| Field | Description |
|
|
1124
|
+
|---|---|
|
|
1125
|
+
| `size` | File size. Directory sizes are omitted because calculating their total size requires scanning their contents. Uses binary (IEC) units such as KiB, MiB, and GiB (1 KiB = 1,024 bytes). |
|
|
1126
|
+
| `modified` | Last modification time of the file or directory itself, displayed in the system's local time zone. |
|
|
1127
|
+
| `accessed` | Last recorded access time. For directories, this generally refers to when their contents were last listed or read. |
|
|
1128
|
+
| `depth` | Path depth. For archive entries, displayed as `(archive_depth, entry_depth)`, representing the containing archive's filesystem depth and the entry's depth within the archive hierarchy, respectively. |
|
|
1129
|
+
| `matches` | Number of recorded content matches. Only applicable to content search results. |
|
|
1130
|
+
|
|
1131
|
+
**Examples:**
|
|
1132
|
+
|
|
1133
|
+
Display all metadata fields:
|
|
1134
|
+
|
|
1135
|
+
```bash
|
|
1136
|
+
pseek query --details
|
|
1137
|
+
```
|
|
1138
|
+
|
|
1139
|
+
Display only file sizes:
|
|
1140
|
+
|
|
1141
|
+
```bash
|
|
1142
|
+
pseek query --details size
|
|
1143
|
+
```
|
|
1144
|
+
|
|
1145
|
+
Display file sizes and modification times:
|
|
1146
|
+
|
|
1147
|
+
```bash
|
|
1148
|
+
pseek query --details size --details modified
|
|
1149
|
+
```
|
|
1150
|
+
|
|
1151
|
+
Display selected fields using explicit assignment:
|
|
1152
|
+
|
|
1153
|
+
```bash
|
|
1154
|
+
pseek --details=size --details=accessed query
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
The special value `all` can also be used explicitly:
|
|
1158
|
+
|
|
1159
|
+
```bash
|
|
1160
|
+
pseek query --details=all
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
**Additional notes:**
|
|
1164
|
+
|
|
1165
|
+
- Directories do not display a size because their total contents are not calculated.
|
|
1166
|
+
- Modification and access times may be unavailable for some archive entries, depending on the archive format and the metadata stored in it.
|
|
1167
|
+
- Access times may be inaccurate or outdated depending on filesystem settings, such as `relatime`, `noatime`, or `nodiratime`.
|
|
1168
|
+
- 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 with `--path-only` or fuzzy search.
|
|
1170
|
+
- Unavailable or inapplicable values are displayed as `—`.
|
|
1171
|
+
|
|
1015
1172
|
## Requirements
|
|
1016
1173
|
|
|
1017
1174
|
* Python `3.10+`
|
|
@@ -68,6 +68,8 @@ Fast and powerful command-line search tool for finding files, directories, and t
|
|
|
68
68
|
* [Result Statistics](#result-statistics)
|
|
69
69
|
* [Search Statistics](#search-statistics)
|
|
70
70
|
* [Search time](#search-time)
|
|
71
|
+
* [Sorting Results](#sorting-results)
|
|
72
|
+
* [Details](#details)
|
|
71
73
|
* [Requirements](#requirements)
|
|
72
74
|
|
|
73
75
|
## Features
|
|
@@ -93,8 +95,6 @@ Fast and powerful command-line search tool for finding files, directories, and t
|
|
|
93
95
|
|
|
94
96
|
## Installation
|
|
95
97
|
|
|
96
|
-
> **Note:** Pseek includes a native Rust extension. Currently, pre-built wheels are provided for Linux only. If you are installing Pseek on another platform, [Rust and Cargo](https://rust-lang.org/) must be installed so the extension can be built locally.
|
|
97
|
-
|
|
98
98
|
### Install from PyPI (Recommended)
|
|
99
99
|
|
|
100
100
|
```bash
|
|
@@ -216,6 +216,9 @@ psk --exclude build
|
|
|
216
216
|
| `--paths-only` | Only show matching file paths for content search |
|
|
217
217
|
| `--stats` | Show search statistics including result counts and search time |
|
|
218
218
|
| `--threads` | This flag sets the approximate number of threads to use. A value of 0 (which is the default) causes pseek to choose the thread count using heuristics |
|
|
219
|
+
| `--sort` | This option enables sorting of results in ascending order. The possible values for this option are: none, path, size, modified, depth, accessed, matches, natpath. Multiple values can be used simultaneously: --sort depth --sort modified. The results are sorted first by depth, and in the event that the depths are identical, then by modified. Use --sort-rev flag for descending order. For more details about this option and how different values function, see [sorting results section](#sorting-results) |
|
|
220
|
+
| `--sort-rev` | Sets the sort order for the `--sort` option to descending. This option is just a flag. You still need to use `--sort` to specify the sort type |
|
|
221
|
+
| `--details` | Show metadata next to result paths. If used without a value, all metadata fields are displayed. Available fields: size, modified, accessed, depth, matches. This option can be repeated to select multiple fields |
|
|
219
222
|
|
|
220
223
|
## Specifying the Root Directory
|
|
221
224
|
|
|
@@ -245,6 +248,8 @@ psk backup --directory
|
|
|
245
248
|
psk TODO --content
|
|
246
249
|
```
|
|
247
250
|
|
|
251
|
+
> **Note:** When searching through file contents, binary files are automatically ignored, and this behavior cannot be changed. If null bytes are present within the first 8 KiB of a file, it is identified as a binary file (The entire file is not examined, in order to increase speed).
|
|
252
|
+
|
|
248
253
|
### Search Everywhere
|
|
249
254
|
|
|
250
255
|
```bash
|
|
@@ -729,12 +734,12 @@ Controls how deep the search goes inside directories.
|
|
|
729
734
|
A depth of `0` means that only base path's immediate contents are searched; subdirectories are not entered.
|
|
730
735
|
|
|
731
736
|
```text
|
|
732
|
-
project/
|
|
733
|
-
├── file.txt
|
|
734
|
-
├── folder1/
|
|
735
|
-
│ ├── file.txt
|
|
736
|
-
│ └── folder2/
|
|
737
|
-
│ └── file.txt
|
|
737
|
+
project/ <- base directory
|
|
738
|
+
├── file.txt <- depth 0
|
|
739
|
+
├── folder1/ <- depth 0
|
|
740
|
+
│ ├── file.txt <- depth 1
|
|
741
|
+
│ └── folder2/ <- depth 1
|
|
742
|
+
│ └── file.txt <- depth 2
|
|
738
743
|
```
|
|
739
744
|
|
|
740
745
|
`--depth` can be specified multiple times to search non-contiguous depth ranges:
|
|
@@ -937,7 +942,7 @@ If the search exceeds the limit, it will be terminated. Results found before the
|
|
|
937
942
|
Display a summary of the search, including result counts, scanned paths, archive information, and search time.
|
|
938
943
|
|
|
939
944
|
```bash
|
|
940
|
-
pseek config --stats
|
|
945
|
+
pseek config --archive --stats
|
|
941
946
|
```
|
|
942
947
|
|
|
943
948
|
Example output:
|
|
@@ -946,7 +951,7 @@ Example output:
|
|
|
946
951
|
Statistics
|
|
947
952
|
────────────────
|
|
948
953
|
Results
|
|
949
|
-
Files: 12
|
|
954
|
+
Files matched: 12
|
|
950
955
|
Directories matched: 3
|
|
951
956
|
Files with matched content: 8
|
|
952
957
|
Lines matched: 24
|
|
@@ -984,6 +989,158 @@ Time spent performing the search.
|
|
|
984
989
|
|
|
985
990
|
When `--timeout` is used, the statistics represent the work completed before the timeout.
|
|
986
991
|
|
|
992
|
+
### Sorting Results
|
|
993
|
+
|
|
994
|
+
The `--sort` option sorts search results in ascending order. It supports multiple values, allowing you to combine different sorting criteria.
|
|
995
|
+
|
|
996
|
+
Use the option multiple times to specify the desired order of criteria:
|
|
997
|
+
|
|
998
|
+
```bash
|
|
999
|
+
pseek --sort depth --sort modified
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
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.
|
|
1003
|
+
|
|
1004
|
+
By default, sorting is disabled (`none`). Without explicit sorting, results are returned in their natural discovery order. Since search processing is parallel, this order is not guaranteed and may vary between runs (Unless you use `--threads 1`).
|
|
1005
|
+
|
|
1006
|
+
Use `--sort-rev` to reverse the sorting order (descending):
|
|
1007
|
+
|
|
1008
|
+
```bash
|
|
1009
|
+
pseek --sort size --sort modified --sort-rev
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
Missing values (`None`) are always placed at the end, regardless of the sorting direction.
|
|
1013
|
+
|
|
1014
|
+
Sorting does not disable parallel search. Results are collected first and sorted afterward. Sorting adds some processing overhead, generally proportional to **O(n log n)**, where `n` is the number of results.
|
|
1015
|
+
|
|
1016
|
+
#### Available Sorting Criteria
|
|
1017
|
+
|
|
1018
|
+
| Option | Description |
|
|
1019
|
+
|---|---|
|
|
1020
|
+
| `none` | Disables sorting. This is the default behavior. |
|
|
1021
|
+
| `path` | Sorts by the full path using lexicographical ordering. Relative paths are used by default; absolute paths are used when `--absolute-path` is enabled. Numeric portions are treated as ordinary characters, so `file10.txt` comes before `file2.txt`. |
|
|
1022
|
+
| `size` | Sorts files by their size in bytes. Directories are not sorted by size and retain their existing order unless another applicable sorting criterion is specified. |
|
|
1023
|
+
| `modified` | Sorts by the last modification time. For directories, this refers to the directory itself, not its contents. Archive entries may have unavailable timestamps and are placed at the end. |
|
|
1024
|
+
| `depth` | Sorts by path depth. Symbolic link targets have no depth value and are placed at the end. Archive depth follows archive nesting rather than filesystem directory depth. Nested archive levels are considered when sorting entries within archives. |
|
|
1025
|
+
| `accessed` | Sorts by the last access time. Directory access time generally reflects when the directory's contents were last listed or read, not when one of its files was accessed. Some files and archive entries may not provide this information. |
|
|
1026
|
+
| `matches` | Sorts content search results by the total number of matches. This criterion only affects content results, not file or directory results. When match positions are unavailable, results cannot be distinguished by this criterion and retain their existing relative order. |
|
|
1027
|
+
| `natpath` | Sorts by the full path using natural ordering instead of lexicographical ordering. It recognizes integer sequences, so `file2.txt` comes before `file10.txt`. See the details below. |
|
|
1028
|
+
|
|
1029
|
+
#### Natural Path Sorting (`natpath`)
|
|
1030
|
+
|
|
1031
|
+
Unlike regular `path` sorting, `natpath` recognizes numbers within path components and compares them numerically rather than lexicographically.
|
|
1032
|
+
|
|
1033
|
+
For example:
|
|
1034
|
+
|
|
1035
|
+
```text
|
|
1036
|
+
file1.txt
|
|
1037
|
+
file2.txt
|
|
1038
|
+
file3.txt
|
|
1039
|
+
file10.txt
|
|
1040
|
+
file20.txt
|
|
1041
|
+
```
|
|
1042
|
+
|
|
1043
|
+
Natural path sorting also provides the following features:
|
|
1044
|
+
|
|
1045
|
+
- **Leading zeros:** Numerically equivalent values are grouped together, with shorter representations appearing first. For example: `file1`, `file01`, `file001`.
|
|
1046
|
+
- **Case-insensitive:** Uppercase and lowercase letters are treated as equivalent during comparison.
|
|
1047
|
+
- **Unicode normalization:** Canonically equivalent Unicode characters are normalized before comparison.
|
|
1048
|
+
- **Unicode decimal digits:** Decimal digits from different writing systems are recognized and compared numerically. For example, the Persian digit `۵` is treated as the number `5`.
|
|
1049
|
+
|
|
1050
|
+
#### Examples
|
|
1051
|
+
|
|
1052
|
+
Sort by path, then by modification time:
|
|
1053
|
+
|
|
1054
|
+
```bash
|
|
1055
|
+
pseek --sort path --sort modified
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
Sort by size in descending order:
|
|
1059
|
+
|
|
1060
|
+
```bash
|
|
1061
|
+
pseek --sort size --sort-rev
|
|
1062
|
+
```
|
|
1063
|
+
|
|
1064
|
+
Sort by depth, then by path, then by access time:
|
|
1065
|
+
|
|
1066
|
+
```bash
|
|
1067
|
+
pseek --sort depth --sort path --sort accessed
|
|
1068
|
+
```
|
|
1069
|
+
|
|
1070
|
+
Use natural path sorting:
|
|
1071
|
+
|
|
1072
|
+
```bash
|
|
1073
|
+
pseek --sort natpath
|
|
1074
|
+
```
|
|
1075
|
+
|
|
1076
|
+
Use natural path sorting followed by descending modification time:
|
|
1077
|
+
|
|
1078
|
+
```bash
|
|
1079
|
+
pseek --sort natpath --sort modified --sort-rev
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1082
|
+
> **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`.
|
|
1083
|
+
|
|
1084
|
+
### Details
|
|
1085
|
+
|
|
1086
|
+
Display additional metadata next to result paths. This option accepts an optional field name and can be repeated to select multiple fields.
|
|
1087
|
+
|
|
1088
|
+
- **Without this option:** No additional metadata is displayed.
|
|
1089
|
+
- **`--details` without a value:** Displays all available metadata fields.
|
|
1090
|
+
- **`--details FIELD`:** Displays only the specified field.
|
|
1091
|
+
- **Multiple values:** Repeat the option to display multiple selected fields.
|
|
1092
|
+
|
|
1093
|
+
Available fields:
|
|
1094
|
+
|
|
1095
|
+
| Field | Description |
|
|
1096
|
+
|---|---|
|
|
1097
|
+
| `size` | File size. Directory sizes are omitted because calculating their total size requires scanning their contents. Uses binary (IEC) units such as KiB, MiB, and GiB (1 KiB = 1,024 bytes). |
|
|
1098
|
+
| `modified` | Last modification time of the file or directory itself, displayed in the system's local time zone. |
|
|
1099
|
+
| `accessed` | Last recorded access time. For directories, this generally refers to when their contents were last listed or read. |
|
|
1100
|
+
| `depth` | Path depth. For archive entries, displayed as `(archive_depth, entry_depth)`, representing the containing archive's filesystem depth and the entry's depth within the archive hierarchy, respectively. |
|
|
1101
|
+
| `matches` | Number of recorded content matches. Only applicable to content search results. |
|
|
1102
|
+
|
|
1103
|
+
**Examples:**
|
|
1104
|
+
|
|
1105
|
+
Display all metadata fields:
|
|
1106
|
+
|
|
1107
|
+
```bash
|
|
1108
|
+
pseek query --details
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
Display only file sizes:
|
|
1112
|
+
|
|
1113
|
+
```bash
|
|
1114
|
+
pseek query --details size
|
|
1115
|
+
```
|
|
1116
|
+
|
|
1117
|
+
Display file sizes and modification times:
|
|
1118
|
+
|
|
1119
|
+
```bash
|
|
1120
|
+
pseek query --details size --details modified
|
|
1121
|
+
```
|
|
1122
|
+
|
|
1123
|
+
Display selected fields using explicit assignment:
|
|
1124
|
+
|
|
1125
|
+
```bash
|
|
1126
|
+
pseek --details=size --details=accessed query
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1129
|
+
The special value `all` can also be used explicitly:
|
|
1130
|
+
|
|
1131
|
+
```bash
|
|
1132
|
+
pseek query --details=all
|
|
1133
|
+
```
|
|
1134
|
+
|
|
1135
|
+
**Additional notes:**
|
|
1136
|
+
|
|
1137
|
+
- Directories do not display a size because their total contents are not calculated.
|
|
1138
|
+
- Modification and access times may be unavailable for some archive entries, depending on the archive format and the metadata stored in it.
|
|
1139
|
+
- Access times may be inaccurate or outdated depending on filesystem settings, such as `relatime`, `noatime`, or `nodiratime`.
|
|
1140
|
+
- 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 with `--path-only` or fuzzy search.
|
|
1142
|
+
- Unavailable or inapplicable values are displayed as `—`.
|
|
1143
|
+
|
|
987
1144
|
## Requirements
|
|
988
1145
|
|
|
989
1146
|
* Python `3.10+`
|