Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main(args=None):
# main parser
parser = argparse.ArgumentParser(
prog=__package__,
description=__package__ + ' command-line tool.')
parser.add_argument(
'-V', '--version',
action='version',
version=__package__ + ' ' + pybase64.get_version())
parser.add_argument(
'--license',
action=LicenseAction,
license=pybase64.get_license_text())
# create sub-parsers
subparsers = parser.add_subparsers(help='tool help')
# benchmark parser
benchmark_parser = subparsers.add_parser('benchmark', help='-h for usage')
benchmark_parser.add_argument(
'-d', '--duration',
metavar='D',
dest='duration',
type=float,
default=1.0,
help='expected duration for a single encode or decode test')
benchmark_parser.add_argument(
def benchmark(args):
print(__package__ + ' ' + pybase64.get_version())
data = readall(args.input)
for altchars in [None, b'-_']:
for validate in [False, True]:
print('bench: altchars={0:s}, validate={1:s}'.format(
repr(altchars), repr(validate)))
bench_one(args.duration,
data,
pybase64.b64encode,
pybase64.b64decode,
pybase64.encodebytes,
altchars,
validate)
bench_one(args.duration,
data,
base64.b64encode,
b64decodeValidate,