diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-09-15 17:54:02 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-09-15 17:54:02 -0400 |
commit | ccedbb9f6e666c8777b7e5ba8eff4cc5aeeca4b2 (patch) | |
tree | 1e94f136112800ea013bc75815c4512d19dab930 | |
parent | 817f91ca28eaeba4e5a2e202ae2495a2cd04843a (diff) | |
download | python-termcast-server-ccedbb9f6e666c8777b7e5ba8eff4cc5aeeca4b2.tar.gz python-termcast-server-ccedbb9f6e666c8777b7e5ba8eff4cc5aeeca4b2.zip |
no need to compile these regexes every time
-rw-r--r-- | termcast.py | 5 |
1 files 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) |