Skip to content

Instantly share code, notes, and snippets.

@RaffaeleSgarro
Created April 15, 2015 09:27
Show Gist options
  • Select an option

  • Save RaffaeleSgarro/55da0bae548c16bac6e2 to your computer and use it in GitHub Desktop.

Select an option

Save RaffaeleSgarro/55da0bae548c16bac6e2 to your computer and use it in GitHub Desktop.
Add user to whitelist
#!/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