-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproviderperms.py
More file actions
57 lines (47 loc) · 1.09 KB
/
providerperms.py
File metadata and controls
57 lines (47 loc) · 1.09 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
#!/usr/bin/python
import sys, re, os
providermap = {}
permissions = []
def readProviderMap(filename):
global providermap
f = open(filename)
for line in f:
lineS = line.split(",")
providermap[lineS[0]] = lineS[1].rstrip()
f.close()
def readStringList(filename):
global permissions
f = open(filename)
and_pattern = re.compile('.+ and .+',re.IGNORECASE)
for line in f:
lineS = line.split(" ")
uri = lineS[0].rstrip("/")
if not checkMap(uri):
parts = uri.split("/")
partialuri = ""
for part in parts:
if (part != "content:"):
partialuri = partialuri + "/" + part
checkMap(partialuri)
else:
partialuri = part
def checkMap(uri):
global providermap
and_pattern = re.compile('.+ and .+',re.IGNORECASE)
if uri in providermap:
perm = providermap[uri]
if and_pattern.match(perm):
perms = perm.split(" and ")
for i in perms:
print i
else:
print perm
sys.stderr.write(uri+" ["+perm+"]\n")
return True
else:
return False
def main():
readProviderMap("providermap.csv");
readStringList(sys.argv[1])
if __name__ == "__main__":
main()