From 45d17cf6cf992ce770ec7b1cd1b9617f2ed930e3 Mon Sep 17 00:00:00 2001 From: Jakob Date: Sun, 23 Feb 2020 23:06:34 +0100 Subject: [PATCH] variable grabbler script might actually function now --- variable_grabbler.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/variable_grabbler.py b/variable_grabbler.py index bbf765b..d6b2616 100644 --- a/variable_grabbler.py +++ b/variable_grabbler.py @@ -5,11 +5,23 @@ Variable Grabbler - version 1.0 -------------------------------""" # definitions +import os, json, fnmatch +dir = os.path.dirname(os.path.abspath(__file__)) +fext = "*.php" print "Opening config file..." -config = open("variable_grabbler.conf","r") +config = open(os.path.join(dir, "variable_grabbler.cfg"),"r") +parsed = json.load(config) -print next_variable(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) config.close()