From 53ea4b605327b5ed83edb694dcfcb78e4f38eda8 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sun, 23 Feb 2020 23:42:13 +0100 Subject: [PATCH] made variable grabbler more verbose --- variable_grabbler.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/variable_grabbler.py b/variable_grabbler.py index ec33c18..df1e402 100644 --- a/variable_grabbler.py +++ b/variable_grabbler.py @@ -1,7 +1,7 @@ #!/usr/bin/python2 print """ -Variable Grabbler - version 1.1 +Variable Grabbler - version 1.4 -------------------------------""" # definitions @@ -13,19 +13,21 @@ fext = "*.php" print "Opening config file..." config = open("variable_grabbler.cfg","r") parsed = json.load(config) +config.close() 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) - file_in = open(fpath, "r") + file_path = os.path.join(path, fname) + + print "Working on file: "+file_path + + file_in = open(file_path, "r") file_content = file_in.read() file_in.close() file_content = file_content.decode('utf-8').replace("%" + x + "%", parsed[x]).encode('utf-8') - file_out = open(fpath, "w") + file_out = open(file_path, "w") file_out.write(file_content) file_out.close() - -config.close()