diff --git a/variable_grabbler.py b/variable_grabbler.py index d6b2616..32594c3 100644 --- a/variable_grabbler.py +++ b/variable_grabbler.py @@ -1,7 +1,7 @@ #!/usr/bin/python2 print """ -Variable Grabbler - version 1.0 +Variable Grabbler - version 1.1 -------------------------------""" # definitions @@ -11,17 +11,21 @@ dir = os.path.dirname(os.path.abspath(__file__)) fext = "*.php" print "Opening config file..." -config = open(os.path.join(dir, "variable_grabbler.cfg"),"r") +config = open("variable_grabbler.cfg","r") parsed = json.load(config) for x in parsed: for path, dirs, files in os.walk(dir): for fname in fnmatch.filter(files, fext): fpath = os.path.join(path, fname) - with open(fpath) as f: - s = f.read() - s = s.replace("%" + x + "%", parsed[x]) - with open(fpath, "w") as f: - f.write(s) + file_in = open(fpath, "r") + file_content = file_in.read() + file_in.close() + + file_content = file_content.replace("%" + x + "%", parsed[x]) + + file_out = open(fpath, "w") + file_out.write(file_content) + file_out.close() config.close()