From 0f65d0e8c80cb0ed652d479196d60ed68580e3cf Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 10 May 2013 00:21:18 +0200 Subject: input and output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- passcheck.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/passcheck.py b/passcheck.py index da8cccb..61e8e74 100755 --- a/passcheck.py +++ b/passcheck.py @@ -18,3 +18,32 @@ # along with this program. If not, see . # +import sys + + +while True: + line = [] + try: + while True: + c = sys.stdin.buffer.read(1)[0] + if c == 10: + break + line.append(c) + except: + break + passphrase = [] + escape = False + for c in line: + if escape: + if (c == ord('~')) or (ord('a') <= c <= ord('z')) or (ord('A') <= c <= ord('Z')): + escape = False + elif c == ord('\033'): + escape = True + else: + passphrase.append(c) + rating = 0 + sys.stdout.buffer.write(('%i \033[34m' % rating).encode('utf-8')) + sys.stdout.buffer.write(bytes(line)) + sys.stdout.buffer.write('\033[00m\n'.encode('utf-8')) + sys.stdout.buffer.flush() + -- cgit v1.2.3-70-g09d2