mirror of https://github.com/python/cpython
upgdaded the test program
This commit is contained in:
parent
4ac0050304
commit
3b8e1604e8
|
@ -109,11 +109,25 @@ def decodestring(s):
|
||||||
# Small test program, reads stdin, writes stdout.
|
# Small test program, reads stdin, writes stdout.
|
||||||
# no arg: encode, any arg: decode.
|
# no arg: encode, any arg: decode.
|
||||||
def test():
|
def test():
|
||||||
import sys
|
import sys, getopt
|
||||||
if sys.argv[1:]:
|
try:
|
||||||
decode(sys.stdin, sys.stdout)
|
opts, args = getopt.getopt(sys.argv[1:], 'deut')
|
||||||
|
except getopt.error, msg:
|
||||||
|
print msg
|
||||||
|
print """usage: basd64 [-d] [-e] [-u] [-t] [file|-]
|
||||||
|
-d, -u: decode
|
||||||
|
-e: encode (default)
|
||||||
|
-t: decode string 'Aladdin:open sesame'"""
|
||||||
|
func = encode
|
||||||
|
for o, a in opts:
|
||||||
|
if o == '-e': func = encode
|
||||||
|
if o == '-d': func = decode
|
||||||
|
if o == '-u': func = decode
|
||||||
|
if o == '-t': test1(); return
|
||||||
|
if args and args[0] != '-':
|
||||||
|
func(open(args[0]), sys.stdout)
|
||||||
else:
|
else:
|
||||||
encode(sys.stdin, sys.stdout)
|
func(sys.stdin, sys.stdout)
|
||||||
|
|
||||||
def test1():
|
def test1():
|
||||||
s0 = "Aladdin:open sesame"
|
s0 = "Aladdin:open sesame"
|
||||||
|
|
Loading…
Reference in New Issue