nanopyx.core.io.unique_names
1# a list of ludicrous dog names to be used as unique identifiers 2# lets see how much time it takes until someone finds this 3 4import random 5 6names = [ 7 "Poodlef", 8 "Schnoodlepuff", 9 "Muttley", 10 "Furball", 11 "Poodlefroot", 12 "Hotdog", 13 "Barkalicious", 14 "Pupperoni", 15 "Doggydoo", 16 "Puppycinno", 17 "Poodlepops", 18 "Barkers", 19 "Muttleydoo", 20 "Poodlepup", 21 "Pupcake", 22 "Barkleberry", 23 "Fluffernutter", 24 "Puppykins", 25 "Poodleberry", 26 "Pupperpuff", 27 "Poodlepop", 28 "Barktastic", 29 "Fluffy_McFluffernutter", 30 "Sir_Barksalot", 31 "Lady_Woofington", 32 "Barkley_von_Wagner", 33 "Count_Fluffernutter", 34 "Duke_of_Woofington", 35 "Baroness_Snugglesnout", 36 "Sir_Wigglesworth", 37 "Lady_Pawsington", 38 "Biscuit_McFluffernutter", 39 "Princess_Fluffybutt", 40] 41 42 43def intToRoman(num): 44 """ 45 Convert an integer to a roman numeral. 46 47 Parameters: 48 num (int): The integer to be converted. 49 50 Returns: 51 str: The roman numeral representation of the input integer. 52 """ 53 m = ["", "M", "MM", "MMM"] 54 c = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM "] 55 x = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"] 56 i = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"] 57 58 # Converting to roman 59 thousands = m[num // 1000] 60 hundreds = c[(num % 1000) // 100] 61 tens = x[(num % 100) // 10] 62 ones = i[num % 10] 63 64 ans = thousands + hundreds + tens + ones 65 66 return ans 67 68 69_already_used = [] 70 71 72def get_unique_name() -> str: 73 """ 74 Get a unique name from the list of names. 75 76 >>> name = get_unique_name() 77 """ 78 # get a unique name 79 global _already_used 80 name = random.choice(names) + "_" + str(intToRoman(random.randint(1, 10))) 81 while name in _already_used: 82 name = random.choice(names) + "_" + str(intToRoman(random.randint(1, 10))) 83 _already_used.append(name) 84 return name
names =
['Poodlef', 'Schnoodlepuff', 'Muttley', 'Furball', 'Poodlefroot', 'Hotdog', 'Barkalicious', 'Pupperoni', 'Doggydoo', 'Puppycinno', 'Poodlepops', 'Barkers', 'Muttleydoo', 'Poodlepup', 'Pupcake', 'Barkleberry', 'Fluffernutter', 'Puppykins', 'Poodleberry', 'Pupperpuff', 'Poodlepop', 'Barktastic', 'Fluffy_McFluffernutter', 'Sir_Barksalot', 'Lady_Woofington', 'Barkley_von_Wagner', 'Count_Fluffernutter', 'Duke_of_Woofington', 'Baroness_Snugglesnout', 'Sir_Wigglesworth', 'Lady_Pawsington', 'Biscuit_McFluffernutter', 'Princess_Fluffybutt']
def
intToRoman(num):
44def intToRoman(num): 45 """ 46 Convert an integer to a roman numeral. 47 48 Parameters: 49 num (int): The integer to be converted. 50 51 Returns: 52 str: The roman numeral representation of the input integer. 53 """ 54 m = ["", "M", "MM", "MMM"] 55 c = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM "] 56 x = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"] 57 i = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"] 58 59 # Converting to roman 60 thousands = m[num // 1000] 61 hundreds = c[(num % 1000) // 100] 62 tens = x[(num % 100) // 10] 63 ones = i[num % 10] 64 65 ans = thousands + hundreds + tens + ones 66 67 return ans
Convert an integer to a roman numeral.
Parameters: num (int): The integer to be converted.
Returns: str: The roman numeral representation of the input integer.
def
get_unique_name() -> str:
73def get_unique_name() -> str: 74 """ 75 Get a unique name from the list of names. 76 77 >>> name = get_unique_name() 78 """ 79 # get a unique name 80 global _already_used 81 name = random.choice(names) + "_" + str(intToRoman(random.randint(1, 10))) 82 while name in _already_used: 83 name = random.choice(names) + "_" + str(intToRoman(random.randint(1, 10))) 84 _already_used.append(name) 85 return name
Get a unique name from the list of names.
>>> name = get_unique_name()