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

Function _decode_uu

Lib/email/message.py:110–138  ·  view source on GitHub ↗

Decode uuencoded data.

(encoded)

Source from the content-addressed store, hash-verified

108
109
110def _decode_uu(encoded):
111 """Decode uuencoded data."""
112 decoded_lines = []
113 encoded_lines_iter = iter(encoded.splitlines())
114 for line in encoded_lines_iter:
115 if line.startswith(b"begin "):
116 mode, _, path = line.removeprefix(b"begin ").partition(b" ")
117 try:
118 int(mode, base=8)
119 except ValueError:
120 continue
121 else:
122 break
123 else:
124 raise ValueError("`begin` line not found")
125 for line in encoded_lines_iter:
126 if not line:
127 raise ValueError("Truncated input")
128 elif line.strip(b' \t\r\n\f') == b'end':
129 break
130 try:
131 decoded_line = binascii.a2b_uu(line)
132 except binascii.Error:
133 # Workaround for broken uuencoders by /Fredrik Lundh
134 nbytes = (((line[0]-32) & 63) * 4 + 5) // 3
135 decoded_line = binascii.a2b_uu(line[:nbytes])
136 decoded_lines.append(decoded_line)
137
138 return b''.join(decoded_lines)
139
140
141class Message:

Callers 1

get_payloadMethod · 0.85

Calls 7

splitlinesMethod · 0.45
startswithMethod · 0.45
partitionMethod · 0.45
removeprefixMethod · 0.45
stripMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…