From 869a278aa8bdaf981222a4e72a4cfc3fbb740f95 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 8 Dec 2015 18:26:08 +0100 Subject: m 2 Reaktor: use sed-plugin --- makefu/2configs/Reaktor/sed-plugin.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'makefu/2configs/Reaktor') diff --git a/makefu/2configs/Reaktor/sed-plugin.py b/makefu/2configs/Reaktor/sed-plugin.py index 6d6e1f8b8..677a1a44f 100644 --- a/makefu/2configs/Reaktor/sed-plugin.py +++ b/makefu/2configs/Reaktor/sed-plugin.py @@ -21,8 +21,8 @@ m = is_regex(line) if m: f,t,flagstr = m.groups() - f = f.replace('\/','/') - t = t.replace('\/','/') + fn = f.replace('\/','/') + tn = t.replace('\/','/') flags = 0 count = 1 if flagstr: @@ -30,10 +30,20 @@ if m: flags = re.IGNORECASE if 'g' in flagstr: count = 0 + else: + flagstr = '' last = d.get(environ['_from'],None) if last: - print(f,t,last) - print(re.sub(f,t,last,count=count,flags=flags)) + print(fn,tn,last) + #print(re.sub(fn,tn,last,count=count,flags=flags)) + from subprocess import Popen,PIPE + p = Popen(['sed','s/{}/{}/{}'.format(f,t,flagstr)],stdin=PIPE,stdout=PIPE ) + so,_ = p.communicate(last+"\n") + if p.returncode: + print("something went wrong when trying to process your regex") + print(so) + + else: print("no last message") else: -- cgit v1.2.3