-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generate_random_string function to API config
- Loading branch information
Showing
1 changed file
with
21 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,30 @@ | ||
"""Stores API configuartion data.""" | ||
from dataclasses import dataclass | ||
import random, string | ||
|
||
|
||
|
||
def generate_random_string(length=16) -> str: | ||
"""Generate random string of letters and numbers of specified length. | ||
Example: | ||
generate_random_string() -> "aud04ki947rrje3k9" | ||
Args: | ||
length (int, optional): Number of characters to generate. Defaults to 16. | ||
Returns: | ||
str: Random string. | ||
""" | ||
possible_characters = string.ascii_letters + string.digits + "!@#$%^&*" | ||
random_string = '' | ||
for number in range(length): | ||
random_string += random.choice(possible_characters) | ||
return random_string | ||
|
||
@dataclass | ||
class Configuraton: | ||
pass | ||
|
||
|
||
config = Configuraton( | ||
|
||
) |