Use int(s, 36) rather than roll a custom base36 converter
This commit is contained in:
parent
269af277d7
commit
31b4fcbf13
18
mclevel.py
18
mclevel.py
@ -1623,23 +1623,7 @@ class MCInfdevOldLevel(MCLevel):
|
|||||||
|
|
||||||
base36alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"
|
base36alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||||
def decbase36(self, s):
|
def decbase36(self, s):
|
||||||
n = 0;
|
return int(s, 36)
|
||||||
neg = False;
|
|
||||||
s = s.lower();
|
|
||||||
|
|
||||||
if s[0] == '-':
|
|
||||||
neg = True;
|
|
||||||
s=s[1:];
|
|
||||||
|
|
||||||
while(len(s)):
|
|
||||||
if not s[0] in self.base36alphabet:
|
|
||||||
break;
|
|
||||||
n*=36
|
|
||||||
n+=self.base36alphabet.index(s[0])
|
|
||||||
s=s[1:];
|
|
||||||
|
|
||||||
if neg: return -n
|
|
||||||
return n;
|
|
||||||
|
|
||||||
def base36(self, n):
|
def base36(self, n):
|
||||||
n = int(n);
|
n = int(n);
|
||||||
|
Reference in New Issue
Block a user