/usr/lib/python3/dist-packages/defcon/tools/identifiers.py is in python3-defcon 0.3.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import random
characters = list("0123456789")
characters += list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
characters += list("abcdefghijklmnopqrstuvwxyz")
identifierLength = 10
identifierRange = range(identifierLength)
def makeRandomIdentifier(existing, recursionDepth=0):
if recursionDepth >= 50:
raise NotImplementedError("Failed 50 times in a row to create a unique id. Sorry.")
identifier = []
for i in identifierRange:
c = random.choice(characters)
identifier.append(c)
identifier = "".join(identifier)
if identifier in existing:
return makeRandomIdentifier(existing, recursionDepth+1)
else:
return identifier
|