Skip to content

Commit 7e2639b

Browse files
committed
updated list of permissions
1 parent befa46f commit 7e2639b

File tree

2 files changed

+161
-120
lines changed

2 files changed

+161
-120
lines changed

scripts/parse.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
''' How to use
2+
1. Go to https://developer.android.com/reference/android/Manifest.permission.html and select desired API level.
3+
2. Save page as Webpage complete
4+
3. Run parse.py filename
5+
4. Use output to set the updated permissions listing in Permissions.java
6+
'''
7+
8+
import sys, re
9+
10+
from BeautifulSoup import BeautifulSoup
11+
12+
filename = sys.argv[1]
13+
data = open(filename,'r').read()
14+
15+
16+
soup = BeautifulSoup(data)
17+
table = soup.find('table', { 'id': 'constants', 'class' : 'responsive constants' })
18+
19+
entries = table.findAll('tr')
20+
print(' static final String[] listing = {')
21+
for entry in entries:
22+
if not entry or not entry.attrs: continue
23+
if 'absent' in entry.attrs[0][1]: continue
24+
info = entry.find('td', {'width':'100%'})
25+
if info:
26+
name = info.find('code').find('a').contents[0]
27+
pieces = []
28+
for piece in info.find('p').contents:
29+
piece_str = re.sub('\s+', ' ', str(piece)).strip()
30+
if '<code>' in piece_str:
31+
piece_str = piece.find('a').contents[0].strip();
32+
pieces += [piece_str]
33+
if name and pieces:
34+
desc = ' '.join(pieces).strip().replace('"', '\\"')
35+
print ' "' + name + '", "' + desc + '",'
36+
print(' };')

0 commit comments

Comments
 (0)