From cd4b763523037888e3c6c20b64fdcb901536a751 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Thu, 26 Jan 2012 23:20:59 +0100 Subject: [PATCH] Add some link --- lg.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lg.py b/lg.py index c393853..c4dd040 100755 --- a/lg.py +++ b/lg.py @@ -29,13 +29,16 @@ def add_links(text): ret_text = [] for line in text: + # Some heuristic to create link if line.strip().startswith("BGP.as_path:") or \ line.strip().startswith("Neighbor AS:") : ret_text.append(re.sub(r'(\d+)',r'\1',line)) else: - line = re.sub(r'([a-zA-Z0-9\-]*\.([a-zA-Z]{2,3}){1,2})(\s|$)', r'\1',line) + line = re.sub(r'([a-zA-Z0-9\-]*\.([a-zA-Z]{2,3}){1,2})(\s|$)', r'\1\2',line) line = re.sub(r'AS(\d+)', r'AS\1',line) line = re.sub(r'(\d+\.\d+\.\d+\.\d+)', r'\1',line) + hosts = "/".join(request.path.split("/")[2:]) + line = re.sub(r'\[(\w+)\s+((|\d\d\d\d-\d\d-\d\d\s)(|\d\d:)\d\d:\d\d|\w\w\w\d\d)\]', r'[\1 \2]' % hosts, line) ret_text.append(line) return "\n".join(ret_text)