summaryrefslogtreecommitdiff
path: root/util/chargen
diff options
context:
space:
mode:
Diffstat (limited to 'util/chargen')
-rw-r--r--util/chargen27
1 files changed, 14 insertions, 13 deletions
diff --git a/util/chargen b/util/chargen
index 9ba14d3d6a..fd9e73cbda 100644
--- a/util/chargen
+++ b/util/chargen
@@ -1,10 +1,11 @@
#!/usr/bin/env python3
-# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# 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,8 +56,7 @@ 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:
@@ -64,6 +64,7 @@ def main(args):
except KeyboardInterrupt:
print()
-if __name__ == '__main__':
+
+if __name__ == "__main__":
main(sys.argv[1:])
sys.exit(0)