From 3ef79a1d929368bc490661aba86e55f345325849 Mon Sep 17 00:00:00 2001 From: Cash TingHin Lo Date: Wed, 7 Sep 2016 17:14:51 +0200 Subject: [PATCH] Make getSmallName() goes higher than 701 --- muncher/varfactory.py | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/muncher/varfactory.py b/muncher/varfactory.py index 7e2810b..ed058a5 100644 --- a/muncher/varfactory.py +++ b/muncher/varfactory.py @@ -55,35 +55,14 @@ def getVersion(type): @staticmethod def getSmallName(index): - """gets a letter index based on the numeric index + """gets a letter index based on the numeric index Arguments: index -- the number you are looking for - Returns: string - """ - # total number of combinations for this index size - combinations = 0 - letters = 0 - while (combinations + (((letters - 1) * 26) - 1) < index): - letters += 1 - combinations = int(math.pow(len(VarFactory.letters), letters)) - - if (index > 701): - raise Exception("until my math skillz get better we can only support 702 possibilities!") - - a = int(index) + 1 - - if a < 27: - return chr(a + 96) - - b = 0 - while a > 26: - b += 1 - a = a - 26 + if index < 26: + return chr(index + 97) - b = chr(b + 96) - a = chr(a + 96) - return b + a + return VarFactory.getSmallName(index / 26 - 1) + VarFactory.getSmallName(index % 26)