-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.py
More file actions
32 lines (27 loc) · 1.13 KB
/
Copy pathsearch.py
File metadata and controls
32 lines (27 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import json
def search_devnexus(root_dir):
matches = []
for dirpath, dirnames, filenames in os.walk(root_dir):
# Exclude common ignore dirs
dirnames[:] = [d for d in dirnames if d not in ('node_modules', '.git', 'dist')]
for filename in filenames:
if filename in ['package-lock.json', 'rename.py', 'search.py']:
continue
filepath = os.path.join(dirpath, filename)
try:
with open(filepath, 'r', encoding='utf-8') as f:
for i, line in enumerate(f):
if 'DevNexus' in line or 'devnexus' in line.lower():
matches.append({
'file': filepath,
'line_num': i + 1,
'line': line.strip()
})
except Exception:
pass
return matches
if __name__ == '__main__':
root_dir = "C:/Users/Manas/OneDrive/Desktop/DevNexus"
results = search_devnexus(root_dir)
print(json.dumps(results, indent=2))