-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
helpers.py
45 lines (37 loc) · 1.06 KB
/
helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
"""
Random user endpoint.
Using Mimesis example for this: https://bit.ly/37KUAlo
"""
import emoji
from mimesis import Generic
from mimesis.enums import Gender
from mimesis.schema import Field, Schema
_ = Field("en")
random_users = Schema(
lambda: {
"id": _("uuid"),
"name": _("name", gender=Gender.MALE),
"surname": _("surname", gender=Gender.MALE),
"email": _("email"),
"age": _("age"),
"username": _("username", template="UU_d"),
"occupation": _("occupation"),
"address": {
"street": _("street_name"),
"city": _("city"),
"zipcode": _("zip_code"),
},
},
)
g = Generic("en") # Going to stick with American English.
def passwd(length: int = 8, hash: bool = False) -> str:
"""
Helper function to generate a random password.
"""
return g.person.password(length=length, hashed=hash)
def emojis() -> str:
"""
Helper function to create random a emoji.
"""
return emoji.emojize(g.internet.emoji(), use_aliases=True)