Skip to content

Instantly share code, notes, and snippets.

@pudquick
Created November 27, 2012 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pudquick/4156759 to your computer and use it in GitHub Desktop.
Save pudquick/4156759 to your computer and use it in GitHub Desktop.
import sys, os.path
with open(sys.argv[1]) as f, open(sys.argv[2]) as g:
settings = [x for x in f.read().split('\n')]
ids = g.read().split()
mode = 0
for i, line in enumerate(settings):
if line.strip():
if (mode == 0) and line.startswith('[') and (line.strip('[]') in ids): mode = 1
if (mode == 1): settings[i] = ';' + settings[i]
else: mode = 0
fname, fext = os.path.splitext(sys.argv[1])
with open(fname + '_out' + fext, 'w') as f: f.write('\n'.join(settings))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment