Skip to content

fix blacklist comment bug and add whitelist #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
'*.swp',
]

WHITELIST_PATTERNS = []

python_files = []


Expand Down Expand Up @@ -80,8 +82,16 @@ def compile_dir(dfn):
subprocess.call([PYTHON, '-OO', '-m', 'compileall', '-f', dfn])


def is_whitelist(name):
return match_filename(WHITELIST_PATTERNS, name)

def is_blacklist(name):
for pattern in BLACKLIST_PATTERNS:
if is_whitelist(name):
return False
return match_filename(BLACKLIST_PATTERNS, name)

def match_filename(pattern_list, name):
for pattern in pattern_list:
if pattern.startswith('^'):
pattern = pattern[1:]
else:
Expand Down Expand Up @@ -373,6 +383,9 @@ def make_package(args):
ap.add_argument('--blacklist', dest='blacklist',
default=join(curdir, 'blacklist.txt'),
help='Use a blacklist file to match unwanted file in the final APK')
ap.add_argument('--whitelist', dest='whitelist',
default=join(curdir, 'whitelist.txt'),
help='Use a whitelist file to prevent blacklisting of file in the final APK')
ap.add_argument('--sdk', dest='sdk_version', default='8', help='Android SDK version to use. Default to 8')
ap.add_argument('--minsdk', dest='min_sdk_version', default='8', help='Minimum Android SDK version to use. Default to 8')
ap.add_argument('--window', dest='window', action='store_true',
Expand Down Expand Up @@ -405,8 +418,14 @@ def make_package(args):

if args.blacklist:
with open(args.blacklist) as fd:
patterns = [x.strip() for x in fd.read().splitlines() if x.strip() or
patterns = [x.strip() for x in fd.read().splitlines() if x.strip() and not
x.startswith('#')]
BLACKLIST_PATTERNS += patterns

if args.whitelist:
with open(args.whitelist) as fd:
patterns = [x.strip() for x in fd.read().splitlines() if x.strip() and not
x.startswith('#')]
WHITELIST_PATTERNS += patterns

make_package(args)