Mercurial > cgi-bin > hgweb.cgi > curlyq
diff curlyq @ 10:397c178c5b98
Make it array-based.
author | David Barts <n5jrn@me.com> |
---|---|
date | Fri, 27 Dec 2019 11:26:00 -0800 |
parents | 05363e803272 |
children | a771878f6cf4 |
line wrap: on
line diff
--- a/curlyq Fri Dec 27 09:51:26 2019 -0800 +++ b/curlyq Fri Dec 27 11:26:00 2019 -0800 @@ -6,7 +6,7 @@ import codecs from curlers import TextCurler, HtmlCurler, uncurl -from workspace import Workspace +from runes import Workspace from writer import CODECS_TO_NAME # V a r i a b l e s @@ -22,46 +22,46 @@ def normal(): global input_fp, output_fp, args - with Workspace() as ws: - curler = TextCurler(ws) - while True: - line = input_fp.readline() - ws.write(line) - if line == "" or line == "\n": - if args.force: uncurl(ws) - curler.feed() - output_fp.write(ws.getvalue()) - ws.clear() - if line == "": - break + ws = Workspace() + curler = TextCurler(ws) + while True: + line = input_fp.readline() + ws.append(line) + if line == "" or line == "\n": + if args.force: uncurl(ws) + curler.feed() + output_fp.write(str(ws)) + ws.clear() + if line == "": + break def flowed(): global input_fp, output_fp, args - with Workspace() as ws: - curler = TextCurler(ws) - while True: - line = input_fp.readline() - if line == "": - break - ws.write(line) - if args.force: uncurl(ws) - curler.feed() - output_fp.write(ws.getvalue()) - ws.clear() + ws = Workspace() + curler = TextCurler(ws) + while True: + line = input_fp.readline() + if line == "": + break + ws.append(line) + if args.force: uncurl(ws) + curler.feed() + output_fp.write(str(ws)) + ws.clear() def html(): global input_fp, output_fp - with Workspace(input_fp.read()) as ws: - curler = HtmlCurler(ws) - if args.force: uncurl(ws) - curler.feed() - output_fp.write(ws.getvalue()) + ws = Workspace(input_fp.read()) + curler = HtmlCurler(ws) + if args.force: uncurl(ws) + curler.feed() + output_fp.write(str(ws)) def do_uncurl(): global input_fp, output_fp - with Workspace(input_fp.read()) as ws: - uncurl(ws) - output_fp.write(ws.getvalue()) + ws = Workspace(input_fp.read()) + uncurl(ws) + output_fp.write(str(ws)) # M a i n P r o g r a m