Created
March 12, 2018 09:54
-
-
Save SebastianBoe/8d36b5b1af0491e5abc8fd598ded976c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/a/6257321/1134134 | |
import os, fnmatch | |
def findReplace(directory, find, replace, filePattern): | |
for path, dirs, files in os.walk(os.path.abspath(directory)): | |
for filename in fnmatch.filter(files, filePattern): | |
filepath = os.path.join(path, filename) | |
s = "" | |
with open(filepath) as f: | |
for line in f: | |
if ("source \"" in line) and ("*" in line): | |
possibly_modified_line = line.replace('source', 'gsource') | |
else: | |
possibly_modified_line = line | |
s += possibly_modified_line | |
with open(filepath, "w") as f: | |
f.write(s) | |
findReplace(".", "not_in_use", "not_in_use", "*Kconfig*") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment