Lines Matching +full:write +full:- +full:output
3 """Conversions to/from quoted-printable transport encoding as per RFC 1521."""
25 quoted. Note that line-ending tabs and spaces are always encoded, as per
44 def encode(input, output, quotetabs, header=False): argument
45 """Read 'input', apply quoted-printable encoding, and write to 'output'.
47 'input' and 'output' are binary file objects. The 'quotetabs' flag
49 line-ending tabs and spaces are always encoded, as per RFC 1521.
56 output.write(odata)
59 def write(s, output=output, lineEnd=b'\n'): argument
62 if s and s[-1:] in b' \t':
63 output.write(s[:-1] + quote(s[-1:]) + lineEnd)
65 output.write(quote(s) + lineEnd)
67 output.write(s + lineEnd)
77 if line[-1:] == b'\n':
78 line = line[:-1]
80 # Calculate the un-length-limited encoded line
89 # First, write out the previous line
91 write(prevline)
92 # Now see if we need any soft line breaks because of RFC-imposed
93 # length limitations. Then do the thisline->prevline dance.
98 write(thisline[:MAXLINESIZE-1], lineEnd=b'=\n')
99 thisline = thisline[MAXLINESIZE-1:]
100 # Write out the current line
102 # Write out the last line, without a trailing newline
104 write(prevline, lineEnd=stripped)
117 def decode(input, output, header=False): argument
118 """Read 'input', apply quoted-printable decoding, and write to 'output'.
119 'input' and 'output' are binary file objects.
125 output.write(odata)
133 if n > 0 and line[n-1:n] == b'\n':
134 partial = 0; n = n-1
136 while n > 0 and line[n-1:n] in b" \t\r":
137 n = n-1
152 else: # Bad escape sequence -- leave it in
155 output.write(new + b'\n')
158 output.write(new)
185 i = ord('a')-10
187 i = ord(b'A')-10
189 assert False, "non-hex digit "+repr(c)
190 bits = bits*16 + (ord(c) - i)
203 print("usage: quopri [-t | -d] [file] ...")
204 print("-t: quote tabs")
205 print("-d: decode; default encode")
210 if o == '-t': tabs = True
211 if o == '-d': deco = True
214 print("-t and -d are mutually exclusive")
216 if not args: args = ['-']
219 if file == '-':
225 sys.stderr.write("%s: can't open (%s)\n" % (file, msg))
234 if file != '-':