Created
April 15, 2015 09:27
-
-
Save RaffaeleSgarro/55da0bae548c16bac6e2 to your computer and use it in GitHub Desktop.
Add user to whitelist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # Usage add_to_whitelist.py $FILENAME $USERNAME | |
| import sys | |
| def eval_line(line): | |
| if line.startswith('#'): | |
| return line | |
| if '=' in line: | |
| key, val = line.split('=') | |
| if key == 'app.store.access.list': | |
| return line + ',' + sys.argv[2] | |
| return line | |
| def get_updated_file_content(filename): | |
| with open(filename, 'r') as props: | |
| return [eval_line(line.rstrip()) for line in props] | |
| filename = sys.argv[1] | |
| new_content = get_updated_file_content(filename) | |
| dst = open(filename, 'w') | |
| for line in new_content: | |
| dst.write(line + '\n') | |
| dst.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment