NexusInstruments commited on
Commit
1edda54
·
verified ·
1 Parent(s): 5f5b92b

Create file_utils.py

Browse files
Files changed (1) hide show
  1. utils/file_utils.py +10 -0
utils/file_utils.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+ def normalize_log_line(line: str) -> str:
4
+ """Strip timestamp/hostname noise from syslog-style line"""
5
+ noise = re.compile(r"^\w{3}\s+\d+\s+\d{2}:\d{2}:\d{2}\s+[\w\-\.\:]+\s+")
6
+ return noise.sub("", line).strip()
7
+
8
+ def keyword_search(content: str, query: str) -> list:
9
+ """Case-insensitive keyword search across lines"""
10
+ return [line for line in content.splitlines() if query.lower() in line.lower()]