-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdependencies.py
More file actions
executable file
·39 lines (34 loc) · 932 Bytes
/
dependencies.py
File metadata and controls
executable file
·39 lines (34 loc) · 932 Bytes
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
import sys
import subprocess
res=""
for e in sys.argv[1:]:
if res=="":
res=e
else:
aux=""
x = min(len(e),len(res))
for i in range(0,x):
if e[i]==res[i]:
aux=aux+e[i]
else:
break
res=aux
#print "Shared root: \""+res+"\""
auxlist={}
for e in sys.argv[1:]:
a=e.replace(res,"")
if "/" in a: auxlist[a]="folder"
else: auxlist[a]="element"
#print auxlist.keys()
elems=""
for e in auxlist.keys():
name=""
if auxlist[e]=="folder": name=e.split("/")[0]
else: name=e
findCMD = 'find . -name "*'+name+'*"'
out = subprocess.Popen(findCMD,shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
(stdout, stderr) = out.communicate()
filelist = stdout.decode().split()
for i in filelist:
if ".yang" in i and i[2:] not in elems: elems=elems+" "+i[2:]
print elems