File tree Expand file tree Collapse file tree
src/processing/mode/android Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 (' };' )
You can’t perform that action at this time.
0 commit comments