-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdive.py
55 lines (47 loc) · 1.4 KB
/
dive.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
import sys
def searcher(paths, word):
"""
Function to search for a file in the entire file system, by any part of the file name
...
Parameters
----------
paths : list
A list containing all the file paths of the file system
word : str
File name or part of the file name to search for
"""
print(word)
for p in paths:
if(p.find(word) != -1):
print("Path of your file is: " + p)
return
print("Could not find a file that contains your file name")
def file_searcher(root, word):
"""
Function to create a list of the file path of the file system
...
Parameters
----------
root : str
Path of the root directory to start searching from
word : str
File name or part of the file name to search for
"""
filePaths = []
print("Searching for files...")
for root, dirs, files in os.walk(root):
for f in files:
filePaths.append(os.path.join(root, f))
searcher(filePaths, word)
filename = sys.argv[1]
if(sys.argv[1] == '--help'):
f = open('help_files/help_searcher.txt', 'r')
print(f.read())
elif(sys.argv[1] == "--version" or sys.argv[1] == "-v"):
print("searcher (sea shell) 1.0.0")
elif(sys.argv[1] == "treasure-map"):
f = open('man_files/man_searcher.txt', 'r')
print(f.read())
else:
file_searcher('/', sys.argv[1])