MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _decode_uu

Function _decode_uu

tools/python-3.11.9-amd64/Lib/email/message.py:104–132  ·  view source on GitHub ↗

Decode uuencoded data.

(encoded)

Source from the content-addressed store, hash-verified

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

Callers 1

get_payloadMethod · 0.85

Calls 7

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

Tested by

no test coverage detected