31 lines
756 B
Python
31 lines
756 B
Python
class color:
|
|
PURPLE = '\033[95m'
|
|
CYAN = '\033[96m'
|
|
DARKCYAN = '\033[36m'
|
|
BLUE = '\033[94m'
|
|
GREEN = '\033[92m'
|
|
YELLOW = '\033[93m'
|
|
RED = '\033[91m'
|
|
BOLD = '\033[1m'
|
|
UNDERLINE = '\033[4m'
|
|
END = '\033[0m'
|
|
|
|
def main():
|
|
files = input("Insert filenames separated by whitespaces: ").strip().split()
|
|
|
|
keyword = input("Insert keyword: ")
|
|
|
|
for file in files:
|
|
try:
|
|
fio = open(file, "r")
|
|
except FileNotFoundError:
|
|
print("File", file, "not found")
|
|
continue
|
|
|
|
for line in fio:
|
|
if keyword in line.lower():
|
|
print(file + ":", line.removesuffix("\n").replace(keyword, color.GREEN + color.BOLD + keyword + color.END))
|
|
|
|
fio.close()
|
|
|
|
main() |