MCPcopy Index your code
hub / github.com/python/cpython / uu_decode

Function uu_decode

Lib/encodings/uu_codec.py:37–68  ·  view source on GitHub ↗
(input, errors='strict')

Source from the content-addressed store, hash-verified

35 return (outfile.getvalue(), len(input))
36
37def uu_decode(input, errors='strict'):
38 assert errors == 'strict'
39 infile = BytesIO(input)
40 outfile = BytesIO()
41 readline = infile.readline
42 write = outfile.write
43
44 # Find start of encoded data
45 while 1:
46 s = readline()
47 if not s:
48 raise ValueError('Missing "begin" line in input data')
49 if s[:5] == b'begin':
50 break
51
52 # Decode
53 while True:
54 s = readline()
55 if not s or s == b'end\n':
56 break
57 try:
58 data = binascii.a2b_uu(s)
59 except binascii.Error:
60 # Workaround for broken uuencoders by /Fredrik Lundh
61 nbytes = (((s[0]-32) & 63) * 4 + 5) // 3
62 data = binascii.a2b_uu(s[:nbytes])
63 #sys.stderr.write("Warning: %s\n" % str(v))
64 write(data)
65 if not s:
66 raise ValueError('Truncated input data')
67
68 return (outfile.getvalue(), len(input))
69
70class Codec(codecs.Codec):
71 def encode(self, input, errors='strict'):

Callers 2

decodeMethod · 0.85
decodeMethod · 0.85

Calls 3

getvalueMethod · 0.95
BytesIOClass · 0.90
writeFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…