Skip to content

Instantly share code, notes, and snippets.

@Krylez-zz
Created January 3, 2014 00:53
Show Gist options
  • Save Krylez-zz/8230485 to your computer and use it in GitHub Desktop.
Save Krylez-zz/8230485 to your computer and use it in GitHub Desktop.
Here's a quick starting point for your Android app manifest according to Facebook's established best practices.
import re
import urllib2
from BeautifulSoup import BeautifulSoup
PERMISSIONS_URL = 'http://developer.android.com/reference/android/Manifest.permission.html'
NON_THIRD_PARTY = 'Not for use by third-party applications.'
MANIFEST_START = ("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n"
" package=\"com.facebook.katana\">\n")
MANFEST_END = "</manifest>"
MANIFEST_PERMISSION = " <uses-permission android:name=\"%s\" />"
page = BeautifulSoup(urllib2.urlopen(PERMISSIONS_URL).read())
permissions = page.findAll(True, {'class': re.compile(r'\bjd-details\b[^-]')})
print MANIFEST_START
for permission in permissions :
description = permission.findAll(True, {'class': 'jd-tagdata jd-tagdescr'})[0].getText()
if NON_THIRD_PARTY not in description :
data = permission.find(True, {'class': 'jd-tagdata'})
if data is not None:
print MANIFEST_PERMISSION % re.findall('\"(.*)\"', data.getText())[0]
print MANFEST_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment