Hello bats,
on Mon, 1. Mar 2004 at 01:58:04 +0100 I wrote:
> Even a simple
> %Py("print 5")
> fails.
After I made a QT up I came to the idea, that executing the %Py()
statements gets done, but simply print() for output fails.
I then realized that I could use the Pyx() macro perhaps, which
simply evaluates a Python expression.
And this in fact works!
Because I rewrote the Python code into plain TB macro languagem with
extensions from MyMacros for looping, we can no compare..
----->8-----[ QT: !protecttext ]-------------------------------
%SUBJ=%OFULLSUBJ%-
%_TEXT=%TEXT%-
%-
%_s1=''%-
%-
%SETPATTREGEXP='(?x)(.*?\n) # delete whole lines
(
Delivered-To:[EMAIL PROTECTED]
|(?:(?:X-POPFile-Link|X-Text-Classification|X-GMX-Antispam|X-GMX-Antivirus):
[^\n]*)
)(.*)'%-
%until("s1", "", "%-
%%RegExpBlindMatch(%%_TEXT)%%-
%%_s1=%%SUBPATT(1)%%_s2=%%SUBPATT(3)%%-
%%IF:'%%_s1'<>'':#%%_TEXT='%%_s1%%_s2'#%%-
")%-
%-
%SETPATTREGEXP='(.*?\n(?:Message-ID|References|In-Reply-To): (?!\())[^\n]*(.*)'%-
%until("s1", "", "%-
%%RegExpBlindMatch(%%_TEXT)%%-
%%_s1=%%SUBPATT(1)%%_s2=%%SUBPATT(2)%%-
%%IF:'%%_s1'<>'':#%%_TEXT='%%_s1%%-((protected))%%_s2'#%%-
")%-
%-
%SetPattRegExp='(?is)(.*?)((?:(?:myname|thistoo)\s*)?[^\s]*domain[^\s;]*)(.*)'%-
%until("s1", "", "%-
%%RegExpBlindMatch(%%_TEXT)%%-
%%_s1=%%SUBPATT(1)%%_s2=%%SUBPATT(3)%%-
%%IF:'%%_s1'<>'':#%%_TEXT='%%_s1%%-[protected]%%_s2'#%%-
")%-
%-
%_TEXT
----->8--------------------------------------------------------
Now for the Python:
----->8-----[ QT: !Protext ]-----------------------------------
%PY("
from re import sub
text = tb.macro('%%TEXT')
text = sub('(?i)(Delivered-To: xxxxx delivery to [EMAIL PROTECTED]'\
'|((X-POPFile-Link|X-Text-Classification|X-GMX-Antispam|X-GMX-Antivirus): ))'\
'[^\n]*\n', '', text)
text = sub('(?i)(To|Message-ID|References|In-Reply-To): [^\n]*\n',
r'\1: <protected>\n', text)
text = sub('(?i)((myname|thistoo)\s*)?[^\s]*domain[^\s;]*', '[protected]', text)
")%-
%PYX("
text
")
----->8--------------------------------------------------------
This is ALOT sweeter.. :)
And so powerful, that Python.
btw: Spamcop will replace "[protected]" and thelike from aboves
replacements to "[prot_cted]".. double protection? ;)
would it only become "[email_domain.com]" normally?
> Fortunately the MyMacros plugin works and I can use it's %StrReplace
> function..
but that cannot use regexp patterns/matching.. :/
--
shinE!
http://www.thequod.de ICQ#152282665
GnuPG/PGP key: http://thequod.de/danielhahler.asc
________________________________________________
Current version is 2.04.7 | 'Using TBUDL' information:
http://www.silverstones.com/thebat/TBUDLInfo.html