From ccedbb9f6e666c8777b7e5ba8eff4cc5aeeca4b2 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 15 Sep 2014 17:54:02 -0400 Subject: no need to compile these regexes every time --- termcast.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/termcast.py b/termcast.py index 51fb592..1c511d2 100644 --- a/termcast.py +++ b/termcast.py @@ -4,6 +4,9 @@ import re import vt100 +auth_re = re.compile(b'^hello ([^ ]+) ([^ ]+)$') +extra_data_re = re.compile(b'^\033\[H\000([^\377]*)\377\033\[H\033\[2J(.*)$') + class Handler(object): def __init__(self, rows, cols): self.created_at = time.time() @@ -85,7 +88,6 @@ class Connection(object): buf = buf[pos+1:] - auth_re = re.compile(b'^hello ([^ ]+) ([^ ]+)$') m = auth_re.match(auth) if m is None: print("no authentication found (%s)" % auth) @@ -96,7 +98,6 @@ class Connection(object): self.client.send(b"hello, " + self.name + b"\n") extra_data = {} - extra_data_re = re.compile(b'^\033\[H\000([^\377]*)\377\033\[H\033\[2J(.*)$') m = extra_data_re.match(buf) if m is not None: extra_data_json = m.group(1) -- cgit v1.2.3-54-g00ecf