Skip to content

Commit

Permalink
Fix for Lorem maker and new Faker locale changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyjb committed Aug 4, 2016
1 parent 984de8d commit c6ed7c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion mongoframes/factory/makers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ def _finish(self, value):
return provider(**self._kwargs)

@staticmethod
def get_fake(locale):
def get_fake(locale=None):
"""Return a shared faker factory used to generate fake data"""
if locale is None:
locale = Faker.default_locale

if not hasattr(Maker, '_fake_' + locale):
Faker._fake = faker.Factory.create(locale)
return Faker._fake
Expand Down
8 changes: 4 additions & 4 deletions mongoframes/factory/makers/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import string

from mongoframes.factory.makers import Maker
from mongoframes.factory.makers import Faker, Maker

__all__ = [
'Code',
Expand Down Expand Up @@ -103,16 +103,16 @@ def _assemble(self):
quantity = int(self._quantity)

if self._text_type == 'body':
return '\n'.join(self.get_fake().paragraphs(nb=quantity))
return '\n'.join(Faker.get_fake().paragraphs(nb=quantity))

if self._text_type == 'paragraph':
return self.get_fake().paragraph(
return Faker.get_fake().paragraph(
nb_sentences=quantity,
variable_nb_sentences=False
)

if self._text_type == 'sentence':
return self.get_fake().sentence(
return Faker.get_fake().sentence(
nb_words=quantity,
variable_nb_words=False
)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='1.1.1',
version='1.1.2',

description='A fast unobtrusive MongoDB ODM for Python',
long_description=long_description,
Expand Down

0 comments on commit c6ed7c0

Please sign in to comment.