-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.py
More file actions
48 lines (40 loc) · 1.08 KB
/
Copy pathparser.py
File metadata and controls
48 lines (40 loc) · 1.08 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
import shutil
import shlex
s=[]
filter={'files':[],'exes':[],'url':[]}
delimiters=['|','&&',';','&']
with open('input.txt')as f:
s+=f.readlines()
for i in s:
d=[]
cmd=shlex.split(i)[0]
if(cmd not in filter['exes'] and cmd.isalpha()):
filter['exes'].append(cmd)
z=''
x=shlex.split(i)
for i,j in enumerate(x):
if('://' in j):
filter['url'].append(j)
continue
if('.'in j):
if('/'in j):
file=j[::-1][:j[::-1].index('/')][::-1]
else:
file=j
if(not file[file.index('.')+1:].isalpha()):continue
if(file not in filter['files']):
filter['files'].append(file)
if(j in delimiters):
d.append(i)
try:
for ind in d:
if x[ind+1] not in filter['exes']:
filter['exes'].append(x[ind+1])
except:
pass
for i in filter:
print(i+":",filter[i])
print("\nCommands not installed:\n")
for i in filter['exes']:
if(shutil.which(i)==None):
print(i)