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

Function uu_encode

Lib/encodings/uu_codec.py:16–35  ·  view source on GitHub ↗
(input, errors='strict', filename='<data>', mode=0o666)

Source from the content-addressed store, hash-verified

14### Codec APIs
15
16def uu_encode(input, errors='strict', filename='<data>', mode=0o666):
17 assert errors == 'strict'
18 infile = BytesIO(input)
19 outfile = BytesIO()
20 read = infile.read
21 write = outfile.write
22
23 # Remove newline chars from filename
24 filename = filename.replace('\n','\\n')
25 filename = filename.replace('\r','\\r')
26
27 # Encode
28 write(('begin %o %s\n' % (mode & 0o777, filename)).encode('ascii'))
29 chunk = read(45)
30 while chunk:
31 write(binascii.b2a_uu(chunk))
32 chunk = read(45)
33 write(b' \nend\n')
34
35 return (outfile.getvalue(), len(input))
36
37def uu_decode(input, errors='strict'):
38 assert errors == 'strict'

Callers 2

encodeMethod · 0.85
encodeMethod · 0.85

Calls 6

getvalueMethod · 0.95
BytesIOClass · 0.90
writeFunction · 0.50
readFunction · 0.50
replaceMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…