rewrote some variable names and code style to make more sense to me

master
BodgeMaster 2020-02-23 23:19:40 +01:00
parent 523bcf1830
commit daff15e873
1 changed files with 11 additions and 7 deletions

View File

@ -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()