First working implementation of the _checkchar method
This commit is contained in:
@@ -182,7 +182,17 @@ class Minter(Persistent):
|
||||
# 7. init checkchar to the value of xdig[sum % alphacount]
|
||||
# 8. return the concat of id and checkchar is lastchar equal to '+' or checkchar
|
||||
# 9. return None
|
||||
pass
|
||||
if id is None:
|
||||
return None
|
||||
lastchar = id[-1]
|
||||
sum = 0
|
||||
for idx, char in enumerate(id[:-1], 1):
|
||||
sum += idx * (self.legalstring.index(char) if self.legalstring.index(char) else 0)
|
||||
checkchar = self.xdig[sum % self.alphacount]
|
||||
if lastchar == "+" or lastchar == checkchar:
|
||||
return id[:-1] + checkchar
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user