From 56d4b3fc13be9c2aa6841710f6bb993ad24ea8b0 Mon Sep 17 00:00:00 2001 From: Mitja HORVAT Date: Sun, 14 Nov 2021 09:10:12 +0100 Subject: [PATCH] python: Remove the `x` pattern. Rename `X` to `x'. --- python/passgeny/passgeny.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/python/passgeny/passgeny.py b/python/passgeny/passgeny.py index 1ae0299..42a5e8c 100644 --- a/python/passgeny/passgeny.py +++ b/python/passgeny/passgeny.py @@ -81,10 +81,8 @@ class Passgeny: return PASSGENY_SPECIAL[bh.modulo(len(PASSGENY_SPECIAL))] def gen_decimal(match): - return "{}".format(bh.modulo(int(match[1]))) - - def gen_hex(match): - return "{:x}".format(bh.modulo(int(match[1]))) + dlen = 1 if match[1] == "" else int(match[1]) + return "{}".format(bh.modulo(dlen)) def gen_hexstr(match): x = "" @@ -103,8 +101,7 @@ class Passgeny: [ '([0-9]*)p', gen_phogen ], [ '([0-9]*)s', gen_special ], [ '([0-9]+)d', gen_decimal ], - [ '([0-9]+)x', gen_hex ], - [ '([0-9]+)X', gen_hexstr ], + [ '([0-9]+)x', gen_hexstr ], [ '\^', gen_capitalize ], ]