Skip to content

Commit

Permalink
refactor: use modern faker calls
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Feb 16, 2024
1 parent 30921f8 commit 9af9a30
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions canaille/core/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@

def faker_generator(locales=None):
locales = locales or list(set(available_language_codes()) & set(AVAILABLE_LOCALES))
return [faker.Faker(locale) for locale in locales]
return faker.Faker(locales)


def fake_users(nb=1):
fakes = faker_generator()
users = list()
for _ in range(nb):
try:
fake = random.choice(fakes)
fake = faker_generator()
name = fake.unique.name()
user = models.User(
formatted_name=name,
Expand Down Expand Up @@ -45,10 +44,10 @@ def fake_users(nb=1):


def fake_groups(nb=1, nb_users_max=1):
fake = faker_generator(["en_US"])[0]
users = models.User.query()
groups = list()
for _ in range(nb):
fake = faker_generator(["en_US"])
try:
group = models.Group(
display_name=fake.unique.word(),
Expand Down

0 comments on commit 9af9a30

Please sign in to comment.