From 623352cdd7f83271dc235dd5073bdfdaafc573fa Mon Sep 17 00:00:00 2001 From: Daniel Washburn Date: Sun, 21 Feb 2021 11:52:45 -0500 Subject: Add ability to specify the number of words in each pet name --- pet_names | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'pet_names') diff --git a/pet_names b/pet_names index 6dbb5c6..e91fe1d 100755 --- a/pet_names +++ b/pet_names @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: CDDL-1.0 -# Copyright (c) 2020 Daniel Washburn +# Copyright (c) 2020, 2021 Daniel Washburn from hex2words import hex2words from secrets import token_hex @@ -8,12 +8,16 @@ import sys def main(argv): try: - num = int(argv[1]) + names = int(argv[1]) except: - num = 1 + names = 1 + try: + nbytes = int(argv[2]) + except: + nbytes = 2 - for i in range(num): - tok = token_hex(2) + for i in range(names): + tok = token_hex(nbytes) print("_".join(hex2words.hex2words(tok).lower().split())) if __name__ == "__main__": -- cgit v1.2.2