From: Philipp Falk Date: Tue, 17 Mar 2015 16:55:34 +0000 (+0100) Subject: added maskmail.py X-Git-Url: https://vcs.mathematik.uni-freiburg.de/gitweb//gitweb/index.cgi?a=commitdiff_plain;h=5cf69fd3b10380a15d5e4e547c13f5414931b723;p=philipp%2Fscripts added maskmail.py --- 5cf69fd3b10380a15d5e4e547c13f5414931b723 diff --git a/maskmail.py b/maskmail.py new file mode 100755 index 0000000..d60ac0e --- /dev/null +++ b/maskmail.py @@ -0,0 +1,26 @@ +#!/usr/bin/python +#-*-coding: utf8-*- + +import io +import sys + +def gen_ent(mail): + for char in mail: + ent = "".join(['&#', `ord(char)`, ';']) + yield ent + +def main(inp): + for mail in inp: + print mail,":", "".join(gen_ent(mail)) + +if __name__ == "__main__": + if len(sys.argv) == 1: + inp = [] + for mail in str.split(sys.__stdin__.read()): + inp.append(mail) + if len(inp) == 0: + print "Error: Please use either stdin or $1 for string input!" + else: + main(inp) + else: + main(sys.argv[1:])