Skip to content

Commit

Permalink
even better id generation
Browse files Browse the repository at this point in the history
  • Loading branch information
LasseMempel committed Apr 15, 2024
1 parent eafc5db commit fcd0e1d
Show file tree
Hide file tree
Showing 2 changed files with 2,006 additions and 2,003 deletions.
9 changes: 6 additions & 3 deletions py/generateID.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
import random
import csv

def idGenerator(size=6, chars= "ABCDEF123456789"):
def idGenerator(size=6, chars= "ABCDFG123456789"):
return "".join(random.choice(chars) for _ in range(size))

def createNewId(checkList):
x = idGenerator()
while x in checkList:
print("combination already in use...")
hasLetters = any(c.isalpha() for c in x)
hasNumbers = any(c.isdigit() for c in x)
while x in checkList or not hasLetters or not hasNumbers:
x = idGenerator()
hasLetters = any(c.isalpha() for c in x)
hasNumbers = any(c.isdigit() for c in x)
return x


Expand Down
Loading

0 comments on commit fcd0e1d

Please sign in to comment.