pseek 2.1.2__tar.gz → 2.1.4__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-2.1.2 → pseek-2.1.4}/PKG-INFO +16 -14
- pseek-2.1.4/README.md +80 -0
- {pseek-2.1.2 → pseek-2.1.4}/pseek/cli.py +11 -3
- {pseek-2.1.2 → pseek-2.1.4}/pseek/searcher.py +30 -12
- {pseek-2.1.2 → pseek-2.1.4}/pseek.egg-info/PKG-INFO +16 -14
- {pseek-2.1.2 → pseek-2.1.4}/setup.py +1 -1
- pseek-2.1.2/README.md +0 -78
- {pseek-2.1.2 → pseek-2.1.4}/LICENSE +0 -0
- {pseek-2.1.2 → pseek-2.1.4}/pseek/__init__.py +0 -0
- {pseek-2.1.2 → pseek-2.1.4}/pseek.egg-info/SOURCES.txt +0 -0
- {pseek-2.1.2 → pseek-2.1.4}/pseek.egg-info/dependency_links.txt +0 -0
- {pseek-2.1.2 → pseek-2.1.4}/pseek.egg-info/entry_points.txt +0 -0
- {pseek-2.1.2 → pseek-2.1.4}/pseek.egg-info/requires.txt +0 -0
- {pseek-2.1.2 → pseek-2.1.4}/pseek.egg-info/top_level.txt +0 -0
- {pseek-2.1.2 → pseek-2.1.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: pseek
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.4
|
|
4
4
|
Summary: Pseek is a Python library to search files, folders, and text
|
|
5
5
|
Home-page: https://github.com/ArianN8610/pysearch
|
|
6
6
|
Author: Arian
|
|
@@ -87,16 +87,18 @@ pseek "error\d+" --regex
|
|
|
87
87
|
|
|
88
88
|
## Command Options
|
|
89
89
|
|
|
90
|
-
| Option
|
|
91
|
-
|
|
92
|
-
| `--path`
|
|
93
|
-
| `--file`
|
|
94
|
-
| `--directory`
|
|
95
|
-
| `--content`
|
|
96
|
-
| `--ext`, `--exclude-ext`
|
|
97
|
-
| `--case-sensitive`
|
|
98
|
-
| `--regex`
|
|
99
|
-
| `--include`, `--exclude`
|
|
100
|
-
| `--
|
|
101
|
-
| `--
|
|
102
|
-
| `--
|
|
90
|
+
| Option | Description |
|
|
91
|
+
|--------------------------------|------------------------------------------------------------------|
|
|
92
|
+
| `--path` | Base directory to search in (default: current directory `.`) |
|
|
93
|
+
| `--file` | Search only in file names |
|
|
94
|
+
| `--directory` | Search only in directory names |
|
|
95
|
+
| `--content` | Search inside file contents |
|
|
96
|
+
| `--ext`, `--exclude-ext` | Filter by file extension (e.g., `.txt`, `.log`) |
|
|
97
|
+
| `--case-sensitive` | Make the search case-sensitive |
|
|
98
|
+
| `--regex` | Use regular expression for searching |
|
|
99
|
+
| `--include`, `--exclude` | Limit search results to specific set of directories or files |
|
|
100
|
+
| `--re-include`, `--re-exclude` | Limit search results to specific directories or files with regex |
|
|
101
|
+
| `--word` | Match the whole word only |
|
|
102
|
+
| `--max-size`, `--min-size` | Specify maximum and minimum sizes for files and directories |
|
|
103
|
+
| `--full-path` | Display full path of files and directories |
|
|
104
|
+
| `--no-content` | Only display files path for content search |
|
pseek-2.1.4/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Pseek
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
A powerful command-line tool for searching files, directories, and content inside files efficiently. The tool supports searching by name, content, extensions, and more with advanced filtering options.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
* **Search in file & folder names**
|
|
10
|
+
* **Search inside file contents**
|
|
11
|
+
* **Highlight matches** in terminal output
|
|
12
|
+
* **Optimized for speed** with ThreadPoolExecutor
|
|
13
|
+
* **Cross-platform** (Linux, macOS, Windows)
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
### **1️⃣ Install via `pip` (Recommended)**
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
pip install pseek
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### **2️⃣ Install from source**
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
git clone https://github.com/ArianN8610/pysearch.git
|
|
27
|
+
cd pseek
|
|
28
|
+
pip install click==8.1.8
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Run the command with a search query:
|
|
34
|
+
```sh
|
|
35
|
+
pseek <query> [options]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Examples
|
|
39
|
+
|
|
40
|
+
### Search for a keyword in file & folder names
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
pseek "my_keyword" --path /path/to/search --file --directory
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Search inside file contents
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
pseek "error" --path /var/logs --content
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Search only in specific file types
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
pseek "TODO" --path ./projects --ext py --ext txt
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Search by regex
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
pseek "error\d+" --regex
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Command Options
|
|
65
|
+
|
|
66
|
+
| Option | Description |
|
|
67
|
+
|--------------------------------|------------------------------------------------------------------|
|
|
68
|
+
| `--path` | Base directory to search in (default: current directory `.`) |
|
|
69
|
+
| `--file` | Search only in file names |
|
|
70
|
+
| `--directory` | Search only in directory names |
|
|
71
|
+
| `--content` | Search inside file contents |
|
|
72
|
+
| `--ext`, `--exclude-ext` | Filter by file extension (e.g., `.txt`, `.log`) |
|
|
73
|
+
| `--case-sensitive` | Make the search case-sensitive |
|
|
74
|
+
| `--regex` | Use regular expression for searching |
|
|
75
|
+
| `--include`, `--exclude` | Limit search results to specific set of directories or files |
|
|
76
|
+
| `--re-include`, `--re-exclude` | Limit search results to specific directories or files with regex |
|
|
77
|
+
| `--word` | Match the whole word only |
|
|
78
|
+
| `--max-size`, `--min-size` | Specify maximum and minimum sizes for files and directories |
|
|
79
|
+
| `--full-path` | Display full path of files and directories |
|
|
80
|
+
| `--no-content` | Only display files path for content search |
|
|
@@ -24,13 +24,18 @@ from .searcher import Search
|
|
|
24
24
|
multiple=True, help='Directories or files to include in search.')
|
|
25
25
|
@click.option('-e', '--exclude', type=click.Path(exists=True, file_okay=True, dir_okay=True),
|
|
26
26
|
multiple=True, help='Directories or files to exclude from search.')
|
|
27
|
+
@click.option('--re-include', type=click.STRING,
|
|
28
|
+
help='Directories or files to include in search with regex.')
|
|
29
|
+
@click.option('--re-exclude', type=click.STRING,
|
|
30
|
+
help='Directories or files to exclude from search with regex.')
|
|
27
31
|
# Size filters
|
|
28
32
|
@click.option('--max-size', type=click.FLOAT, help='Maximum file/directory size (in MB).')
|
|
29
33
|
@click.option('--min-size', type=click.FLOAT, help='Minimum file/directory size (in MB).')
|
|
30
34
|
# Output option
|
|
31
35
|
@click.option('--full-path', is_flag=True, help='Display full paths for results.')
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
@click.option('--no-content', is_flag=True, help='Only display files path for content search.')
|
|
37
|
+
def search(query, path, file, directory, content, case_sensitive, ext, exclude_ext, regex, include, exclude,
|
|
38
|
+
re_include, re_exclude, word, max_size, min_size, full_path, no_content):
|
|
34
39
|
"""Search for files, directories, and file content based on the query."""
|
|
35
40
|
# If no search type is specified, search in all types.
|
|
36
41
|
if not any((file, directory, content)):
|
|
@@ -46,10 +51,13 @@ def search(query, path, file, directory, content, case_sensitive, ext, exclude_e
|
|
|
46
51
|
regex=regex,
|
|
47
52
|
include=include,
|
|
48
53
|
exclude=exclude,
|
|
54
|
+
re_include=re_include,
|
|
55
|
+
re_exclude=re_exclude,
|
|
49
56
|
whole_word=word,
|
|
50
57
|
max_size=max_size,
|
|
51
58
|
min_size=min_size,
|
|
52
|
-
full_path=full_path
|
|
59
|
+
full_path=full_path,
|
|
60
|
+
no_content=no_content
|
|
53
61
|
)
|
|
54
62
|
|
|
55
63
|
total_results = 0
|
|
@@ -19,9 +19,18 @@ EXCLUDED_EXTENSIONS = {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
|
|
22
|
+
def compile_regex(txt, flags=0):
|
|
23
|
+
if txt is not None:
|
|
24
|
+
try:
|
|
25
|
+
return re.compile(txt, flags)
|
|
26
|
+
except re.error as e:
|
|
27
|
+
click.echo(click.style(f"Regex compile error: {e}", fg='red'))
|
|
28
|
+
sys.exit(1)
|
|
29
|
+
|
|
30
|
+
|
|
22
31
|
class Search:
|
|
23
|
-
def __init__(self, base_path, query, case_sensitive, ext, exclude_ext, regex, include, exclude,
|
|
24
|
-
max_size, min_size, full_path):
|
|
32
|
+
def __init__(self, base_path, query, case_sensitive, ext, exclude_ext, regex, include, exclude, re_include,
|
|
33
|
+
re_exclude, whole_word, max_size, min_size, full_path, no_content):
|
|
25
34
|
"""Initialize search parameters"""
|
|
26
35
|
self.base_path = Path(base_path)
|
|
27
36
|
self.query = query
|
|
@@ -31,10 +40,13 @@ class Search:
|
|
|
31
40
|
self.regex = regex
|
|
32
41
|
self.include = {Path(p).resolve() for p in include}
|
|
33
42
|
self.exclude = {Path(p).resolve() for p in exclude}
|
|
43
|
+
self.re_include = re_include
|
|
44
|
+
self.re_exclude = re_exclude
|
|
34
45
|
self.whole_word = whole_word
|
|
35
46
|
self.max_size = max_size
|
|
36
47
|
self.min_size = min_size
|
|
37
48
|
self.full_path = full_path
|
|
49
|
+
self.no_content = no_content
|
|
38
50
|
self.result = None
|
|
39
51
|
|
|
40
52
|
def should_skip(self, p_resolved: Path, search_type: str) -> bool:
|
|
@@ -61,6 +73,12 @@ class Search:
|
|
|
61
73
|
or (search_type == 'directory' and not p_resolved.is_dir()):
|
|
62
74
|
return True
|
|
63
75
|
|
|
76
|
+
# Filter by regex include and exclude
|
|
77
|
+
if compiled_inc:=compile_regex(self.re_include):
|
|
78
|
+
return not compiled_inc.search(str(p_resolved))
|
|
79
|
+
if compiled_exc:=compile_regex(self.re_exclude):
|
|
80
|
+
return compiled_exc.search(str(p_resolved)) is not None
|
|
81
|
+
|
|
64
82
|
return False
|
|
65
83
|
|
|
66
84
|
def search(self, search_type: str):
|
|
@@ -76,13 +94,7 @@ class Search:
|
|
|
76
94
|
query = rf'\b{query}\b'
|
|
77
95
|
|
|
78
96
|
flags = 0 if self.case_sensitive else re.IGNORECASE # Adjust case sensitivity
|
|
79
|
-
|
|
80
|
-
# Precompile the regex pattern for performance
|
|
81
|
-
try:
|
|
82
|
-
pattern = re.compile(query, flags)
|
|
83
|
-
except re.error as e:
|
|
84
|
-
click.echo(click.style(f"Regex compile error: {e}", fg='red'))
|
|
85
|
-
sys.exit(1)
|
|
97
|
+
pattern = compile_regex(query, flags) # Precompile the regex pattern for performance
|
|
86
98
|
|
|
87
99
|
if search_type in ('file', 'directory'):
|
|
88
100
|
matches = []
|
|
@@ -102,7 +114,7 @@ class Search:
|
|
|
102
114
|
matches.append(f'{p_parent}\\{highlighted_name}')
|
|
103
115
|
else: # content search
|
|
104
116
|
# Use dictionary: key: file path (colored), value: list of line matches
|
|
105
|
-
matches = {}
|
|
117
|
+
matches = {} if not self.no_content else set()
|
|
106
118
|
# Compile binary version of the pattern
|
|
107
119
|
pattern_bytes = re.compile(pattern.pattern.encode('utf-8'))
|
|
108
120
|
|
|
@@ -119,6 +131,14 @@ class Search:
|
|
|
119
131
|
with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as mm:
|
|
120
132
|
# Search for the pattern in the entire file as bytes
|
|
121
133
|
if pattern_bytes.search(mm):
|
|
134
|
+
# Choose the file path format based on the full_path setting
|
|
135
|
+
file_label = str(file_path.resolve()) if self.full_path else str(file_path)
|
|
136
|
+
|
|
137
|
+
# Avoid searching through the entire file content if the fast-content flag is True
|
|
138
|
+
if self.no_content:
|
|
139
|
+
matches.add(click.style(file_label, fg='cyan'))
|
|
140
|
+
return
|
|
141
|
+
|
|
122
142
|
lines = []
|
|
123
143
|
mm.seek(0) # Move the cursor to the beginning of the file
|
|
124
144
|
|
|
@@ -149,8 +169,6 @@ class Search:
|
|
|
149
169
|
|
|
150
170
|
# If any matching lines were found
|
|
151
171
|
if lines:
|
|
152
|
-
# Choose the file path format based on the full_path setting
|
|
153
|
-
file_label = str(file_path.resolve()) if self.full_path else str(file_path)
|
|
154
172
|
# Add the file and its matching lines to the results
|
|
155
173
|
matches[click.style(file_label, fg='cyan')] = lines
|
|
156
174
|
except Exception:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: pseek
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.4
|
|
4
4
|
Summary: Pseek is a Python library to search files, folders, and text
|
|
5
5
|
Home-page: https://github.com/ArianN8610/pysearch
|
|
6
6
|
Author: Arian
|
|
@@ -87,16 +87,18 @@ pseek "error\d+" --regex
|
|
|
87
87
|
|
|
88
88
|
## Command Options
|
|
89
89
|
|
|
90
|
-
| Option
|
|
91
|
-
|
|
92
|
-
| `--path`
|
|
93
|
-
| `--file`
|
|
94
|
-
| `--directory`
|
|
95
|
-
| `--content`
|
|
96
|
-
| `--ext`, `--exclude-ext`
|
|
97
|
-
| `--case-sensitive`
|
|
98
|
-
| `--regex`
|
|
99
|
-
| `--include`, `--exclude`
|
|
100
|
-
| `--
|
|
101
|
-
| `--
|
|
102
|
-
| `--
|
|
90
|
+
| Option | Description |
|
|
91
|
+
|--------------------------------|------------------------------------------------------------------|
|
|
92
|
+
| `--path` | Base directory to search in (default: current directory `.`) |
|
|
93
|
+
| `--file` | Search only in file names |
|
|
94
|
+
| `--directory` | Search only in directory names |
|
|
95
|
+
| `--content` | Search inside file contents |
|
|
96
|
+
| `--ext`, `--exclude-ext` | Filter by file extension (e.g., `.txt`, `.log`) |
|
|
97
|
+
| `--case-sensitive` | Make the search case-sensitive |
|
|
98
|
+
| `--regex` | Use regular expression for searching |
|
|
99
|
+
| `--include`, `--exclude` | Limit search results to specific set of directories or files |
|
|
100
|
+
| `--re-include`, `--re-exclude` | Limit search results to specific directories or files with regex |
|
|
101
|
+
| `--word` | Match the whole word only |
|
|
102
|
+
| `--max-size`, `--min-size` | Specify maximum and minimum sizes for files and directories |
|
|
103
|
+
| `--full-path` | Display full path of files and directories |
|
|
104
|
+
| `--no-content` | Only display files path for content search |
|
pseek-2.1.2/README.md
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# Pseek
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
A powerful command-line tool for searching files, directories, and content inside files efficiently. The tool supports searching by name, content, extensions, and more with advanced filtering options.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
* **Search in file & folder names**
|
|
10
|
-
* **Search inside file contents**
|
|
11
|
-
* **Highlight matches** in terminal output
|
|
12
|
-
* **Optimized for speed** with ThreadPoolExecutor
|
|
13
|
-
* **Cross-platform** (Linux, macOS, Windows)
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
### **1️⃣ Install via `pip` (Recommended)**
|
|
18
|
-
|
|
19
|
-
```sh
|
|
20
|
-
pip install pseek
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### **2️⃣ Install from source**
|
|
24
|
-
|
|
25
|
-
```sh
|
|
26
|
-
git clone https://github.com/ArianN8610/pysearch.git
|
|
27
|
-
cd pseek
|
|
28
|
-
pip install click==8.1.8
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Usage
|
|
32
|
-
|
|
33
|
-
Run the command with a search query:
|
|
34
|
-
```sh
|
|
35
|
-
pseek <query> [options]
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Examples
|
|
39
|
-
|
|
40
|
-
### Search for a keyword in file & folder names
|
|
41
|
-
|
|
42
|
-
```sh
|
|
43
|
-
pseek "my_keyword" --path /path/to/search --file --directory
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Search inside file contents
|
|
47
|
-
|
|
48
|
-
```sh
|
|
49
|
-
pseek "error" --path /var/logs --content
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Search only in specific file types
|
|
53
|
-
|
|
54
|
-
```sh
|
|
55
|
-
pseek "TODO" --path ./projects --ext py --ext txt
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Search by regex
|
|
59
|
-
|
|
60
|
-
```sh
|
|
61
|
-
pseek "error\d+" --regex
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Command Options
|
|
65
|
-
|
|
66
|
-
| Option | Description |
|
|
67
|
-
|----------------------------|--------------------------------------------------------------|
|
|
68
|
-
| `--path` | Base directory to search in (default: current directory `.`) |
|
|
69
|
-
| `--file` | Search only in file names |
|
|
70
|
-
| `--directory` | Search only in directory names |
|
|
71
|
-
| `--content` | Search inside file contents |
|
|
72
|
-
| `--ext`, `--exclude-ext` | Filter by file extension (e.g., `.txt`, `.log`) |
|
|
73
|
-
| `--case-sensitive` | Make the search case-sensitive |
|
|
74
|
-
| `--regex` | Use regular expression for searching |
|
|
75
|
-
| `--include`, `--exclude` | Limit search results to specific set of directories or files |
|
|
76
|
-
| `--word` | Match the whole word only |
|
|
77
|
-
| `--max-size`, `--min-size` | Specify maximum and minimum sizes for files and directories |
|
|
78
|
-
| `--full-path` | Display full path of files and directories |
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|