Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto add builtin provider to Generic based on passed locale #674

Closed
lk-geimfari opened this issue Apr 19, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@lk-geimfari
Copy link
Owner

commented Apr 19, 2019

Feature request

An idea is very simple:

generic = Generic('ru', auto_add_builtin=True)
generic.russia_provider.inn()

Instead of this:

from mimesis import Generic
from mimesis.builtins import RussiaSpecProvider

generic = Generic('ru')
generic.add_provider(RussiaSpecProvider)
generic.russia_provider.inn()

Optionally we can make builtin's name customizable:

generic = Generic('ru', auto_add_builtin=True, builtin_custom_name='russia')
generic.russia.inn()
@lk-geimfari

This comment has been minimized.

Copy link
Owner Author

commented Apr 19, 2019

@ceccoemi @sobolevn What do you, guys, think?

@lk-geimfari lk-geimfari self-assigned this Apr 19, 2019

@lk-geimfari lk-geimfari added this to the Version 3.2.0 milestone Apr 19, 2019

@lk-geimfari lk-geimfari assigned ceccoemi and unassigned ceccoemi Apr 19, 2019

@sobolevn

This comment has been minimized.

Copy link
Collaborator

commented Apr 19, 2019

I do not see any problems with these three lines of code.
What problem are you trying to solve?

@lk-geimfari

This comment has been minimized.

Copy link
Owner Author

commented Apr 19, 2019

@sobolevn I'm trying to make it easier to add country-specific data to Generic. For example, in common cases when you need to generate Personal info for locale ru, you will exactly need some data from RussiaSpecProvider, such as inn, patronymic and etc.

It's just an easier way to add builtin provider to Generic. We can do get all params we need from **kwargs.

@ceccoemi

This comment has been minimized.

Copy link
Collaborator

commented Apr 20, 2019

@lk-geimfari I think that is a good idea.

What do you think about adding the builtin provider by default? The generic provider generates all the data from a locale so I think that is reasonable to add the builtin too:

g = Generic('ru')
g.russia_provider.inn()

It's ok to add the parameter builtin_custom_name if you think that it will not add unnecessary complexity.

I could work on this next week. Let me know!

@ceccoemi ceccoemi referenced this issue Apr 28, 2019

Merged

Generic dev #677

3 of 3 tasks complete

@ceccoemi ceccoemi closed this in #677 May 7, 2019

lk-geimfari added a commit that referenced this issue May 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.