-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpPackageFinder.py
More file actions
59 lines (43 loc) · 1.6 KB
/
Copy pathphpPackageFinder.py
File metadata and controls
59 lines (43 loc) · 1.6 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: UTF-8 -*-
import sys
from searcherClass import Searcher
def showMenu():
print 'Usage phpPackageFinder arg1 arg2 arg3 arg4'
print ' arg1 = path to directory to search'
print ' arg2 = search string'
print ' arg3 = file extension'
print ' arg4 = hit count only, meaning only show number of hits of the search string in the file (True or False)'
print ' '
print 'Example: phpPackageFinder /home/somename/Documents/ testQuery txt True'
print ' '
print 'For the query string, use a single quote for a multiple word phrase.'
def performSearch(searchObj):
print 'Search started...'
Search.find()
results = Search.getResults()
print 'Found ', len(results), ' files:'
print 'Search ended.'
for file, count in results.items():
#after search @Package, then conduct another search using the filename
#to get the version number of the Package
with open(file, 'r') as searchfile:
for line in searchfile:
if search in line:
print line
if version in line:
print line
#path = 'c:\\temp\\'
path = '/someName/Users/'
search = 'security'
fileExt = 'txt'
hitOnly = True
noVars = True
if __name__ == '__main__':
if len(sys.argv) != 5 and noVars == False:
showMenu()
elif len(sys.argv) == 5:
Search = Searcher(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
performSearch(Search)
else:
Search = Searcher(path, search, fileExt, hitOnly)
performSearch(Search)