search-comment-file 1.0.1__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.
File without changes
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: search-comment-file
3
+ Version: 1.0.1
4
+ Summary: Search source code files using comments
5
+ Author: Yallavula Navadeep
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Dynamic: license-file
10
+
11
+ # Search Comment
12
+
13
+ Search source code files using comments.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install search-comment
@@ -0,0 +1,8 @@
1
+ # Search Comment
2
+
3
+ Search source code files using comments.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install search-comment
@@ -0,0 +1,17 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "search-comment-file"
7
+ version = "1.0.1"
8
+ description = "Search source code files using comments"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+
12
+ authors = [
13
+ { name = "Yallavula Navadeep" }
14
+ ]
15
+
16
+ [project.scripts]
17
+ search-comment = "search_comment.main:search_comments"
@@ -0,0 +1 @@
1
+ __version__ = "1.0.0"
@@ -0,0 +1,128 @@
1
+ import os
2
+ import sys
3
+ import subprocess
4
+ import platform
5
+
6
+
7
+ FILE_TYPES = {
8
+ "java": ".java",
9
+ "python": ".py",
10
+ "c": ".c",
11
+ "cpp": ".cpp",
12
+ "html": ".html",
13
+ "css": ".css",
14
+ }
15
+
16
+
17
+ def open_file(filepath):
18
+
19
+ system = platform.system()
20
+
21
+ if system == "Windows":
22
+ os.startfile(filepath)
23
+
24
+ elif system == "Darwin":
25
+ subprocess.run(["open", filepath])
26
+
27
+ elif system == "Linux":
28
+ subprocess.run(["xdg-open", filepath])
29
+
30
+ else:
31
+ print("Unsupported operating system")
32
+
33
+
34
+ def search_comments():
35
+
36
+ if len(sys.argv) < 2:
37
+ print('Usage: search-comment "keyword"')
38
+ return
39
+
40
+ keyword = sys.argv[1].lower()
41
+
42
+ start_dir = os.path.expanduser("~")
43
+
44
+ filetype = input(
45
+ "Enter file type (java/python/c/cpp/html/css or press Enter for all): "
46
+ ).strip().lower()
47
+
48
+ extension = FILE_TYPES.get(filetype)
49
+
50
+ print(f"\nScanning files from: {start_dir}")
51
+ print("Please wait...\n")
52
+
53
+ matches = []
54
+
55
+ skip_dirs = {
56
+ ".git",
57
+ ".venv",
58
+ "__pycache__",
59
+ "node_modules"
60
+ }
61
+
62
+ for root, dirs, files in os.walk(start_dir):
63
+
64
+ dirs[:] = [d for d in dirs if d not in skip_dirs]
65
+
66
+ for file in files:
67
+
68
+ if extension and not file.endswith(extension):
69
+ continue
70
+
71
+ filepath = os.path.join(root, file)
72
+
73
+ try:
74
+
75
+ with open(filepath, "r", errors="ignore") as f:
76
+
77
+ for lineno, line in enumerate(f, 1):
78
+
79
+ line_strip = line.strip()
80
+
81
+ if (
82
+ line_strip.startswith("//")
83
+ or line_strip.startswith("#")
84
+ or line_strip.startswith("/*")
85
+ or line_strip.startswith("*")
86
+ ):
87
+
88
+ if keyword in line_strip.lower():
89
+
90
+ matches.append(
91
+ (filepath, lineno, line_strip)
92
+ )
93
+ break
94
+
95
+ except Exception:
96
+ pass
97
+
98
+ if not matches:
99
+ print("No files found.")
100
+ return
101
+
102
+ print("Found in files:\n")
103
+
104
+ for i, (filepath, lineno, comment) in enumerate(matches, start=1):
105
+
106
+ print(f"{i}. {filepath}")
107
+ print(f" Line {lineno}: {comment}\n")
108
+
109
+ choice = input(
110
+ "Enter the number of the file you want to open (or press Enter to skip): "
111
+ )
112
+
113
+ if not choice:
114
+ return
115
+
116
+ try:
117
+
118
+ index = int(choice) - 1
119
+ filepath = matches[index][0]
120
+
121
+ open_file(filepath)
122
+
123
+ except Exception as e:
124
+ print("Error:", e)
125
+
126
+
127
+ if __name__ == "__main__":
128
+ search_comments()
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: search-comment-file
3
+ Version: 1.0.1
4
+ Summary: Search source code files using comments
5
+ Author: Yallavula Navadeep
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Dynamic: license-file
10
+
11
+ # Search Comment
12
+
13
+ Search source code files using comments.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install search-comment
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ search_comment/__init__.py
5
+ search_comment/main.py
6
+ search_comment_file.egg-info/PKG-INFO
7
+ search_comment_file.egg-info/SOURCES.txt
8
+ search_comment_file.egg-info/dependency_links.txt
9
+ search_comment_file.egg-info/entry_points.txt
10
+ search_comment_file.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ search-comment = search_comment.main:search_comments
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+