diff options
author | makefu <github@syntax-fehler.de> | 2018-04-04 15:23:44 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2018-04-04 15:23:44 +0200 |
commit | 3ed84b0b8c063a294e7cb40a786fa7a15ee0e5a4 (patch) | |
tree | 569658ceb8fc90f640d7ce48357eb84a0383b494 /krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py | |
parent | 1b740bf9ef32972f7242226699a75b39feeb18b2 (diff) | |
parent | 1a5b58c828409ce9bf1639f3f26ebeb142e0148a (diff) |
Merge remote-tracking branch 'lass/staging/18.03' into staging
Diffstat (limited to 'krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py')
-rw-r--r-- | krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py b/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py index da8e2f726..51ac7a071 100644 --- a/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py +++ b/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py @@ -18,20 +18,27 @@ def is_regex(line): myre = re.compile(r'^s/(?:\\/|[^/])+/(?:\\/|[^/])*/[ig]?$') return myre.match(line) + line = argv[1] if is_regex(line): last = d.get(usr, None) if last: from subprocess import Popen, PIPE - p = Popen(['sed', line], stdin=PIPE, stdout=PIPE) + p = Popen(['sed', line], stdin=PIPE, stdout=PIPE, stderr=PIPE) so, se = p.communicate(bytes("{}\n".format(last), "UTF-8")) if p.returncode: - print("something went wrong when trying to process your regex: {}".format(se.decode())) + print("something went wrong when trying to process your regex: {}".format(line.strip())) ret = so.decode() - print("\x1b[1m{}\x1b[0m meant: {}".format(usr, ret.strip())) - if ret: - d[usr] = ret + if len(ret) > 512: + print('message to long, skipped') + elif len(ret.split('\n')) > 5: + print('to many lines, skipped') + else: + if last.strip() != ret.strip(): + print("\x1b[1m{}\x1b[0m meant: {}".format(usr, ret.strip())) + if ret: + d[usr] = ret else: print("no last message") |