diff options
author | Edward Hill <ecgh@chromium.org> | 2022-10-28 16:50:07 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-28 21:05:21 +0000 |
commit | 83be28f6f56c7daa543c03633b28a742e2c462a3 (patch) | |
tree | a8215d48381cf4a41bd2280019eca809da9db8e0 | |
parent | 8113d238fb985d73e7607510c89fcc3bfbe98052 (diff) | |
download | chrome-ec-83be28f6f56c7daa543c03633b28a742e2c462a3.tar.gz |
util/chargen: Update to python3
Update to match the copy in ToT EC repo.
BUG=b:227228605
TEST=script works with python3
Signed-off-by: Edward Hill <ecgh@chromium.org>
Change-Id: Idd4ff156f980d1edaaf4f98d468e3cffbe7ae771
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3989665
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r-- | util/chargen | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/util/chargen b/util/chargen index c949f709e0..fd9e73cbda 100644 --- a/util/chargen +++ b/util/chargen @@ -1,10 +1,11 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # Copyright 2019 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import sys + def chargen(modulo, max_chars): """Generate a stream of characters on the console. @@ -18,7 +19,7 @@ def chargen(modulo, max_chars): zero, if zero - print indefinitely """ - base = '0' + base = "0" c = base counter = 0 while True: @@ -26,25 +27,25 @@ def chargen(modulo, max_chars): counter = counter + 1 if (max_chars != 0) and (counter == max_chars): - sys.stdout.write('\n') + sys.stdout.write("\n") return if modulo and ((counter % modulo) == 0): c = base continue - if c == 'z': + if c == "z": c = base - elif c == 'Z': - c = 'a' - elif c == '9': - c = 'A' + elif c == "Z": + c = "a" + elif c == "9": + c = "A" else: - c = '%c' % (ord(c) + 1) + c = "%c" % (ord(c) + 1) def main(args): - '''Process command line arguments and invoke chargen if args are valid''' + """Process command line arguments and invoke chargen if args are valid""" modulo = 0 max_chars = 0 @@ -55,15 +56,15 @@ def main(args): if len(args) > 1: max_chars = int(args[1]) except ValueError: - sys.stderr.write('usage %s:' - "['seq_length' ['max_chars']]\n") + sys.stderr.write("usage %s:" "['seq_length' ['max_chars']]\n") sys.exit(1) try: chargen(modulo, max_chars) except KeyboardInterrupt: - print + print() + -if __name__ == '__main__': +if __name__ == "__main__": main(sys.argv[1:]) sys.exit(0) |