Skip to content

Commit

Permalink
Fixed #619
Browse files Browse the repository at this point in the history
  • Loading branch information
lk-geimfari committed Mar 17, 2019
1 parent 937b49e commit 8d2b7ca
Show file tree
Hide file tree
Showing 22 changed files with 110 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Version 3.2.0
**Added**:

- Added built-in provider DenmarkSpecProvider

- Added meta classes for providers for internal usage (see `#619 <https://github.com/lk-geimfari/mimesis/issues/619>`_.)

**Fixed**:

Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ def __init__(self, *args, **kwargs) -> None:
self._datafile = 'address.json'
self.pull(self._datafile)

class Meta:
"""Class for metadata."""

name = 'address'

@staticmethod
def _dd_to_dms(num: float, _type: str) -> str:
"""Convert decimal number to DMS format.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def __init__(self, *args, **kwargs):
self._datafile = 'business.json'
self.pull(self._datafile)

class Meta:
"""Class for metadata."""

name = 'business'

def company(self) -> str:
"""Get a random company name.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/clothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
class Clothing(BaseProvider):
"""Class for generate data related to clothing."""

class Meta:
"""Class for metadata."""

name = 'clothing'

def international_size(self) -> str:
"""Get a random size in international format.
Expand Down
8 changes: 7 additions & 1 deletion mimesis/providers/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def __init__(self, *args, **kwargs):
"""
super().__init__(*args, **kwargs)

class Meta:
"""Class for metadata."""

name = 'code'

def locale_code(self) -> str:
"""Get a random locale code (MS-LCID).
Expand All @@ -46,7 +51,8 @@ def issn(self, mask: str = '####-####') -> str:
"""
return self.random.custom_code(mask=mask)

def isbn(self, fmt: Optional[ISBNFormat] = None, locale: str = 'en') -> str:
def isbn(self, fmt: Optional[ISBNFormat] = None,
locale: str = 'en') -> str:
"""Generate ISBN for current locale.
To change ISBN format, pass parameter ``fmt`` with needed value of
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/cryptographic.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.__words = Text('en')._data.get('words', {})

class Meta:
"""Class for metadata."""

name = 'cryptographic'

def uuid(self, version: int = None) -> str:
"""Generate random UUID.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/date.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def __init__(self, *args, **kwargs):
self._datafile = 'datetime.json'
self.pull(self._datafile)

class Meta:
"""Class for metadata."""

name = 'datetime'

@staticmethod
def bulk_create_datetimes(date_start: DateTime,
date_end: DateTime, **kwargs) -> List[DateTime]:
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
class Development(BaseProvider):
"""Class for getting fake data for Developers."""

class Meta:
"""Class for metadata."""

name = 'development'

def software_license(self) -> str:
"""Get a random software license.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__text = Text('en', seed=self.seed)

class Meta:
"""Class for metadata."""

name = 'file'

def __sub(self, string: str = '') -> str:
"""Replace spaces in string.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/food.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def __init__(self, *args, **kwargs):
self._datafile = 'food.json'
self.pull(self._datafile)

class Meta:
"""Class for metadata."""

name = 'food'

def _choice_from(self, key: str) -> str:
"""Choice random element."""
data = self._data[key]
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def __init__(self, *args, **kwargs) -> None:
self.structure = Structure(seed=self.seed)
self.choice = Choice(seed=self.seed)

class Meta:
"""Class for metadata."""

name = 'generic'

def __getattr__(self, attrname: str) -> Any:
"""Get attribute without underscore.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
class Hardware(BaseProvider):
"""Class for generate data related to hardware."""

class Meta:
"""Class for metadata."""

name = 'hardware'

def resolution(self) -> str:
"""Get a random screen resolution.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/internet.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__file = File(seed=self.seed)

class Meta:
"""Class for metadata."""

name = 'internet'

def content_type(self, mime_type: Optional[MimeType] = None) -> str:
"""Get a random HTTP content type.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
class Numbers(BaseProvider):
"""Class for generating numbers."""

class Meta:
"""Class for metadata."""

name = 'numbers'

def floats(self, n: int = 2) -> List[float]:
"""Generate a list of random float numbers.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def __init__(self, platform: str = sys.platform, *args, **kwargs) -> None:
else PurePosixPath()
self._pathlib_home /= PLATFORMS[platform]['home']

class Meta:
"""Class for metadata."""

name = 'path'

def root(self) -> str:
"""Generate a root dir path.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.__person = Person('en', seed=self.seed)

class Meta:
"""Class for metadata."""

name = 'payment'

def cid(self) -> int:
"""Generate a random CID.
Expand Down
8 changes: 7 additions & 1 deletion mimesis/providers/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def __init__(self, *args, **kwargs) -> None:
'age': 0,
}

class Meta:
"""Class for metadata."""

name = 'person'

def age(self, minimum: int = 16, maximum: int = 66) -> int:
"""Get a random integer value.
Expand Down Expand Up @@ -258,7 +263,8 @@ def email(self, domains: Union[tuple, list] = None) -> str:
domain=domain,
)

def social_media_profile(self, site: Optional[SocialNetwork] = None) -> str:
def social_media_profile(self,
site: Optional[SocialNetwork] = None) -> str:
"""Generate profile for random social network.
:return: Profile in some network.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/science.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def __init__(self, *args, **kwargs):
self._datafile = 'science.json'
self.pull(self._datafile)

class Meta:
"""Class for metadata."""

name = 'science'

def math_formula(self) -> str:
"""Get a random mathematical formula.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def __init__(self, *args, **kwargs) -> None:
self.__inet = Internet(seed=self.seed)
self.__text = Text('en', seed=self.seed)

class Meta:
"""Class for metadata."""

name = 'structure'

def css(self) -> str:
"""Generate a random snippet of CSS.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def __init__(self, *args, **kwargs):
self._datafile = 'text.json'
self.pull(self._datafile)

class Meta:
"""Class for metadata."""

name = 'text'

def alphabet(self, lower_case: bool = False) -> list:
"""Get an alphabet for current locale.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def __init__(self, *args, **kwargs) -> None:
"""
super().__init__(*args, **kwargs)

class Meta:
"""Class for metadata."""

name = 'transport'

def truck(self, model_mask: str = '#### @@') -> str:
"""Generate a truck model.
Expand Down
5 changes: 5 additions & 0 deletions mimesis/providers/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
class UnitSystem(BaseProvider):
"""Class for generating data related to units."""

class Meta:
"""Class for metadata."""

name = 'unit_system'

def unit(self, name: Optional[UnitName] = None, symbol=False):
"""Get unit name.
Expand Down

0 comments on commit 8d2b7ca

Please sign in to comment.