siftx 0.1.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.
- siftx-0.1.0/LICENSE +0 -0
- siftx-0.1.0/PKG-INFO +41 -0
- siftx-0.1.0/README.md +30 -0
- siftx-0.1.0/pyproject.toml +15 -0
- siftx-0.1.0/setup.cfg +4 -0
- siftx-0.1.0/siftx/__init__.py +0 -0
- siftx-0.1.0/siftx/cli.py +53 -0
- siftx-0.1.0/siftx/files.py +17 -0
- siftx-0.1.0/siftx/highlight.py +7 -0
- siftx-0.1.0/siftx/output.py +15 -0
- siftx-0.1.0/siftx/search.py +55 -0
- siftx-0.1.0/siftx.egg-info/PKG-INFO +41 -0
- siftx-0.1.0/siftx.egg-info/SOURCES.txt +15 -0
- siftx-0.1.0/siftx.egg-info/dependency_links.txt +1 -0
- siftx-0.1.0/siftx.egg-info/entry_points.txt +2 -0
- siftx-0.1.0/siftx.egg-info/top_level.txt +1 -0
- siftx-0.1.0/tests/test_search.py +0 -0
siftx-0.1.0/LICENSE
ADDED
|
File without changes
|
siftx-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: siftx
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple grep-like CLI tools for searching and filtering text
|
|
5
|
+
Author: Musa Adam
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
#siftx
|
|
13
|
+
|
|
14
|
+
siftx is a lightweight grep like command-line tools for searching and filtering text files.
|
|
15
|
+
|
|
16
|
+
It is designed to be simple, fast, and easy to extend.
|
|
17
|
+
|
|
18
|
+
##installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install siftx
|
|
22
|
+
|
|
23
|
+
#usage
|
|
24
|
+
siftx [search:text] [path] [options]
|
|
25
|
+
|
|
26
|
+
#options
|
|
27
|
+
|
|
28
|
+
-n Show line numbers
|
|
29
|
+
-i Ignore_case (Case insensitive search)
|
|
30
|
+
-v Invert search
|
|
31
|
+
-c Count matching lines
|
|
32
|
+
|
|
33
|
+
#Examples
|
|
34
|
+
siftx search:error text.txt
|
|
35
|
+
siftx -n search:error text.txt
|
|
36
|
+
siftx -i search:error text.txt
|
|
37
|
+
siftx -v search:error text.txt
|
|
38
|
+
siftx -c search:error text.txt
|
|
39
|
+
|
|
40
|
+
#Status
|
|
41
|
+
This is the first public release (v0.1.0). More features will be added in the future version
|
siftx-0.1.0/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#siftx
|
|
2
|
+
|
|
3
|
+
siftx is a lightweight grep like command-line tools for searching and filtering text files.
|
|
4
|
+
|
|
5
|
+
It is designed to be simple, fast, and easy to extend.
|
|
6
|
+
|
|
7
|
+
##installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install siftx
|
|
11
|
+
|
|
12
|
+
#usage
|
|
13
|
+
siftx [search:text] [path] [options]
|
|
14
|
+
|
|
15
|
+
#options
|
|
16
|
+
|
|
17
|
+
-n Show line numbers
|
|
18
|
+
-i Ignore_case (Case insensitive search)
|
|
19
|
+
-v Invert search
|
|
20
|
+
-c Count matching lines
|
|
21
|
+
|
|
22
|
+
#Examples
|
|
23
|
+
siftx search:error text.txt
|
|
24
|
+
siftx -n search:error text.txt
|
|
25
|
+
siftx -i search:error text.txt
|
|
26
|
+
siftx -v search:error text.txt
|
|
27
|
+
siftx -c search:error text.txt
|
|
28
|
+
|
|
29
|
+
#Status
|
|
30
|
+
This is the first public release (v0.1.0). More features will be added in the future version
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "siftx"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A simple grep-like CLI tools for searching and filtering text"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT"}
|
|
11
|
+
authors = [{ name = "Musa Adam" }]
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
|
|
14
|
+
[project.scripts]
|
|
15
|
+
siftx = "siftx.cli:main"
|
siftx-0.1.0/setup.cfg
ADDED
|
File without changes
|
siftx-0.1.0/siftx/cli.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from argparse import ArgumentParser
|
|
3
|
+
import output
|
|
4
|
+
import search
|
|
5
|
+
import colorama
|
|
6
|
+
from colorama import Back, Fore, Style
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main():
|
|
10
|
+
parser = ArgumentParser(description="Siftx is a command line interface")
|
|
11
|
+
parser.usage = f"{Fore.RED} siftx [search:text] [path] [options] {Style.RESET_ALL}"
|
|
12
|
+
|
|
13
|
+
group = parser.add_mutually_exclusive_group()
|
|
14
|
+
|
|
15
|
+
parser.add_argument("project_name",
|
|
16
|
+
help=f"siftx help you to make a search through document")
|
|
17
|
+
|
|
18
|
+
parser.add_argument("search", help="search command helps in search through a text")
|
|
19
|
+
|
|
20
|
+
parser.add_argument("file", help="file to search through")
|
|
21
|
+
|
|
22
|
+
parser.add_argument("-n", "--number_line",
|
|
23
|
+
help="for print number line of where text exits", action="store_true")
|
|
24
|
+
|
|
25
|
+
group.add_argument("-v", "--invert",
|
|
26
|
+
help="indirect printing", action="store_true")
|
|
27
|
+
|
|
28
|
+
parser.add_argument("-i", "--ignore_case",
|
|
29
|
+
help="printing without checking weather it's case_sensitive or not",
|
|
30
|
+
action="store_true")
|
|
31
|
+
|
|
32
|
+
group.add_argument("-c", "--counter",
|
|
33
|
+
help="count the number of time word occure in the text",
|
|
34
|
+
action="store_true")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
result = parser.parse_args()
|
|
38
|
+
commands = {"search": result.search, "usage": parser.usage, "file":result.file,
|
|
39
|
+
"line_number": result.number_line, "invert": result.invert,
|
|
40
|
+
"ignorecase" : result.ignore_case, "counter" : result.counter}
|
|
41
|
+
|
|
42
|
+
print(commands)
|
|
43
|
+
|
|
44
|
+
if result.project_name != "siftx":
|
|
45
|
+
output.optional()
|
|
46
|
+
else:
|
|
47
|
+
search.search_command(commands)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if __name__ == "__main__":
|
|
53
|
+
main()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from colorama import Back, Fore, Style
|
|
2
|
+
|
|
3
|
+
def optional():
|
|
4
|
+
print(Fore.RED, """
|
|
5
|
+
siftx [search:text] [path] [options]
|
|
6
|
+
|
|
7
|
+
Options:
|
|
8
|
+
-r recursice
|
|
9
|
+
-i ignore case
|
|
10
|
+
-n line numbers
|
|
11
|
+
-c context lines
|
|
12
|
+
--ast python-aware parsing
|
|
13
|
+
--django django intelligence
|
|
14
|
+
--json machine-readable output
|
|
15
|
+
""")
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from files import open_file
|
|
3
|
+
from colorama import Back, Fore, Style
|
|
4
|
+
from highlight import highlight
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def search_command(command):
|
|
8
|
+
if command["search"].startswith("search:"):
|
|
9
|
+
search_cmd, word = command["search"].split(":")
|
|
10
|
+
if len(word) != 0:
|
|
11
|
+
search_file(word, command["file"], command["line_number"],
|
|
12
|
+
command["invert"], command["ignorecase"], command["counter"])
|
|
13
|
+
else:
|
|
14
|
+
print(Fore.RED, command["usage"])
|
|
15
|
+
else:
|
|
16
|
+
print(Fore.RED, command["usage"])
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def count_word(word:list, pattern:str):
|
|
21
|
+
for eachword in word:
|
|
22
|
+
if eachword.startswith(pattern[0]) and eachword.endswith(pattern[len(pattern) - 1]):
|
|
23
|
+
return word.count(eachword)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def search_file(pattern:str, file, number_line, invert, ignore_case, counter):
|
|
28
|
+
if open_file(file):
|
|
29
|
+
with open(file, "r", errors="ignore") as output:
|
|
30
|
+
|
|
31
|
+
first_case = pattern[0].lower() + pattern[1:]
|
|
32
|
+
second_case = pattern[0].upper() + pattern[1:]
|
|
33
|
+
counts = 0
|
|
34
|
+
|
|
35
|
+
for line, word in enumerate(output, 1):
|
|
36
|
+
if pattern in word.strip().split(" ") and number_line:
|
|
37
|
+
# change = find_word(word.strip().split(" "), pattern)
|
|
38
|
+
# word.strip().split(" ")[change].upper()
|
|
39
|
+
print(line, word, end="", sep=": ")
|
|
40
|
+
elif pattern in word.strip().split(" ") and not invert and not counter:
|
|
41
|
+
highlight(word, pattern)
|
|
42
|
+
else:
|
|
43
|
+
if invert and not pattern in word.strip().split(" "):
|
|
44
|
+
print(word, end="")
|
|
45
|
+
elif ignore_case:
|
|
46
|
+
if first_case in word.strip().split(" ") or second_case in word.strip().split(" "):
|
|
47
|
+
print("-i:", word, end="")
|
|
48
|
+
elif counter and pattern in word.strip().split(" "):
|
|
49
|
+
counts += count_word(word.strip().split(" "), pattern)
|
|
50
|
+
print(counts)
|
|
51
|
+
continue
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
else:
|
|
55
|
+
print("File doest not exit")
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: siftx
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple grep-like CLI tools for searching and filtering text
|
|
5
|
+
Author: Musa Adam
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
#siftx
|
|
13
|
+
|
|
14
|
+
siftx is a lightweight grep like command-line tools for searching and filtering text files.
|
|
15
|
+
|
|
16
|
+
It is designed to be simple, fast, and easy to extend.
|
|
17
|
+
|
|
18
|
+
##installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install siftx
|
|
22
|
+
|
|
23
|
+
#usage
|
|
24
|
+
siftx [search:text] [path] [options]
|
|
25
|
+
|
|
26
|
+
#options
|
|
27
|
+
|
|
28
|
+
-n Show line numbers
|
|
29
|
+
-i Ignore_case (Case insensitive search)
|
|
30
|
+
-v Invert search
|
|
31
|
+
-c Count matching lines
|
|
32
|
+
|
|
33
|
+
#Examples
|
|
34
|
+
siftx search:error text.txt
|
|
35
|
+
siftx -n search:error text.txt
|
|
36
|
+
siftx -i search:error text.txt
|
|
37
|
+
siftx -v search:error text.txt
|
|
38
|
+
siftx -c search:error text.txt
|
|
39
|
+
|
|
40
|
+
#Status
|
|
41
|
+
This is the first public release (v0.1.0). More features will be added in the future version
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
siftx/__init__.py
|
|
5
|
+
siftx/cli.py
|
|
6
|
+
siftx/files.py
|
|
7
|
+
siftx/highlight.py
|
|
8
|
+
siftx/output.py
|
|
9
|
+
siftx/search.py
|
|
10
|
+
siftx.egg-info/PKG-INFO
|
|
11
|
+
siftx.egg-info/SOURCES.txt
|
|
12
|
+
siftx.egg-info/dependency_links.txt
|
|
13
|
+
siftx.egg-info/entry_points.txt
|
|
14
|
+
siftx.egg-info/top_level.txt
|
|
15
|
+
tests/test_search.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
siftx
|
|
File without changes
|