Skip to content

Commit

Permalink
Adding config editor for pip package
Browse files Browse the repository at this point in the history
  • Loading branch information
KunalAggarwal committed Jul 25, 2017
1 parent 4116d07 commit b3d52d0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions datasploit_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python

import os, subprocess, tempfile

def edit():
config_path = os.path.dirname(__file__)
config_file = "%s/config.py" % config_path
fh = open(config_file)
config = fh.read()
fh.close()
f, fname = tempfile.mkstemp()
fh = open(fname, "w")
fh.write(config)
fh.close()

cmd = os.environ.get('EDITOR', 'vi') + ' ' + fname
subprocess.call(cmd, shell = True)

with open(fname, "r") as f:
config = f.read().strip()
fh = open(config_file, "w")
fh.write(config)
fh.close()

os.unlink(fname)

if __name__ == "__main__":
edit()

0 comments on commit b3d52d0

Please sign in to comment.