Advertisement
Guest User

Untitled

a guest
May 25th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # Usage add_to_whitelist.py $FILENAME $USERNAME
  3. import sys
  4.  
  5. def eval_line(line):
  6. if line.startswith('#'):
  7. return line
  8. if '=' in line:
  9. key, val = line.split('=')
  10. if key == 'app.store.access.list':
  11. return line + ',' + sys.argv[2]
  12. return line
  13.  
  14. def get_updated_file_content(filename):
  15. with open(filename, 'r') as props:
  16. return [eval_line(line.rstrip()) for line in props]
  17.  
  18. filename = sys.argv[1]
  19.  
  20. new_content = get_updated_file_content(filename)
  21.  
  22. dst = open(filename, 'w')
  23.  
  24. for line in new_content:
  25. dst.write(line + '\n')
  26.  
  27. dst.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement