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

Function test

tools/python-3.11.9-amd64/Lib/uu.py:177–213  ·  view source on GitHub ↗

uuencode/uudecode main program

()

Source from the content-addressed store, hash-verified

175 f.close()
176
177def test():
178 """uuencode/uudecode main program"""
179
180 import optparse
181 parser = optparse.OptionParser(usage='usage: %prog [-d] [-t] [input [output]]')
182 parser.add_option('-d', '--decode', dest='decode', help='Decode (instead of encode)?', default=False, action='store_true')
183 parser.add_option('-t', '--text', dest='text', help='data is text, encoded format unix-compatible text?', default=False, action='store_true')
184
185 (options, args) = parser.parse_args()
186 if len(args) > 2:
187 parser.error('incorrect number of arguments')
188 sys.exit(1)
189
190 # Use the binary streams underlying stdin/stdout
191 input = sys.stdin.buffer
192 output = sys.stdout.buffer
193 if len(args) > 0:
194 input = args[0]
195 if len(args) > 1:
196 output = args[1]
197
198 if options.decode:
199 if options.text:
200 if isinstance(output, str):
201 output = open(output, 'wb')
202 else:
203 print(sys.argv[0], ': cannot do -t to stdout')
204 sys.exit(1)
205 decode(input, output)
206 else:
207 if options.text:
208 if isinstance(input, str):
209 input = open(input, 'rb')
210 else:
211 print(sys.argv[0], ': cannot do -t from stdin')
212 sys.exit(1)
213 encode(input, output)
214
215if __name__ == '__main__':
216 test()

Callers 1

uu.pyFile · 0.70

Calls 8

parse_argsMethod · 0.95
errorMethod · 0.95
openFunction · 0.70
decodeFunction · 0.70
encodeFunction · 0.70
printFunction · 0.50
add_optionMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected