comparison curlyq @ 4:7a83e82e65a6

Remove some deadwood.
author David Barts <n5jrn@me.com>
date Thu, 26 Dec 2019 20:04:04 -0800
parents 091c03f1b2e8
children d5198c7ec54d
comparison
equal deleted inserted replaced
3:091c03f1b2e8 4:7a83e82e65a6
3 3
4 import os, sys 4 import os, sys
5 import argparse 5 import argparse
6 import codecs 6 import codecs
7 7
8 from curlers import TextCurler, HtmlCurler 8 from curlers import TextCurler, HtmlCurler, uncurl
9 from workspace import Workspace, Bounds, Mapping, SegmentedView 9 from workspace import Workspace
10 from writer import CODECS_TO_NAME 10 from writer import CODECS_TO_NAME
11 11
12 # V a r i a b l e s 12 # V a r i a b l e s
13 13
14 # Name invoked by 14 # Name invoked by
19 output_fp = None 19 output_fp = None
20 20
21 # F u n c t i o n s 21 # F u n c t i o n s
22 22
23 def normal(): 23 def normal():
24 global input_fp, output_fp 24 global input_fp, output_fp, args
25 with Workspace() as ws: 25 with Workspace() as ws:
26 curler = TextCurler(ws) 26 curler = TextCurler(ws)
27 while True: 27 while True:
28 line = input_fp.readline() 28 line = input_fp.readline()
29 ws.write(line) 29 ws.write(line)
30 if line == "" or line == "\n": 30 if line == "" or line == "\n":
31 if args.force: uncurl(ws)
31 curler.feed() 32 curler.feed()
32 output_fp.write(ws.getvalue()) 33 output_fp.write(ws.getvalue())
33 ws.clear() 34 ws.clear()
34 if line == "": 35 if line == "":
35 break 36 break
41 while True: 42 while True:
42 line = input_fp.readline() 43 line = input_fp.readline()
43 if line == "": 44 if line == "":
44 break 45 break
45 ws.write(line) 46 ws.write(line)
47 if args.force: uncurl(ws)
46 curler.feed() 48 curler.feed()
47 output_fp.write(ws.getvalue()) 49 output_fp.write(ws.getvalue())
48 ws.clear() 50 ws.clear()
49 51
50 def html(): 52 def html():
51 global input_fp, output_fp 53 global input_fp, output_fp
52 with Workspace(input_fp.read()) as ws: 54 with Workspace(input_fp.read()) as ws:
53 curler = HtmlCurler(ws) 55 curler = HtmlCurler(ws)
56 if args.force: uncurl(ws)
54 curler.feed() 57 curler.feed()
55 output_fp.write(ws.getvalue()) 58 output_fp.write(ws.getvalue())
56 59
57 # M a i n P r o g r a m 60 # M a i n P r o g r a m
58 61