METADATA 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. Metadata-Version: 2.1
  2. Name: Faker
  3. Version: 0.9.1
  4. Summary: Faker is a Python package that generates fake data for you.
  5. Home-page: https://github.com/joke2k/faker
  6. Author: joke2k
  7. Author-email: joke2k@gmail.com
  8. License: MIT License
  9. Keywords: faker fixtures data test mock generator
  10. Platform: any
  11. Classifier: Development Status :: 5 - Production/Stable
  12. Classifier: Environment :: Console
  13. Classifier: Intended Audience :: Developers
  14. Classifier: Programming Language :: Python
  15. Classifier: Programming Language :: Python :: 2
  16. Classifier: Programming Language :: Python :: 2.7
  17. Classifier: Programming Language :: Python :: 3
  18. Classifier: Programming Language :: Python :: 3.4
  19. Classifier: Programming Language :: Python :: 3.5
  20. Classifier: Programming Language :: Python :: 3.6
  21. Classifier: Programming Language :: Python :: 3.7
  22. Classifier: Programming Language :: Python :: Implementation :: CPython
  23. Classifier: Programming Language :: Python :: Implementation :: PyPy
  24. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  25. Classifier: Topic :: Software Development :: Testing
  26. Classifier: Topic :: Utilities
  27. Classifier: License :: OSI Approved :: MIT License
  28. Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
  29. Requires-Dist: python-dateutil (>=2.4)
  30. Requires-Dist: six (>=1.10)
  31. Requires-Dist: text-unidecode (==1.2)
  32. Requires-Dist: ipaddress; python_version=="2.7"
  33. *Faker* is a Python package that generates fake data for you. Whether
  34. you need to bootstrap your database, create good-looking XML documents,
  35. fill-in your persistence to stress test it, or anonymize data taken from
  36. a production service, Faker is for you.
  37. Faker is heavily inspired by `PHP Faker`_, `Perl Faker`_, and by `Ruby Faker`_.
  38. ----
  39. ::
  40. _|_|_|_| _|
  41. _| _|_|_| _| _| _|_| _| _|_|
  42. _|_|_| _| _| _|_| _|_|_|_| _|_|
  43. _| _| _| _| _| _| _|
  44. _| _|_|_| _| _| _|_|_| _|
  45. |pypi| |unix_build| |windows_build| |coverage| |license|
  46. ----
  47. For more details, see the `extended docs`_.
  48. Basic Usage
  49. -----------
  50. Install with pip:
  51. .. code:: bash
  52. pip install Faker
  53. *Note: this package was previously called* ``fake-factory``.
  54. Use ``faker.Faker()`` to create and initialize a faker
  55. generator, which can generate data by accessing properties named after
  56. the type of data you want.
  57. .. code:: python
  58. from faker import Faker
  59. fake = Faker()
  60. fake.name()
  61. # 'Lucy Cechtelar'
  62. fake.address()
  63. # "426 Jordy Lodge
  64. # Cartwrightshire, SC 88120-6700"
  65. fake.text()
  66. # Sint velit eveniet. Rerum atque repellat voluptatem quia rerum. Numquam excepturi
  67. # beatae sint laudantium consequatur. Magni occaecati itaque sint et sit tempore. Nesciunt
  68. # amet quidem. Iusto deleniti cum autem ad quia aperiam.
  69. # A consectetur quos aliquam. In iste aliquid et aut similique suscipit. Consequatur qui
  70. # quaerat iste minus hic expedita. Consequuntur error magni et laboriosam. Aut aspernatur
  71. # voluptatem sit aliquam. Dolores voluptatum est.
  72. # Aut molestias et maxime. Fugit autem facilis quos vero. Eius quibusdam possimus est.
  73. # Ea quaerat et quisquam. Deleniti sunt quam. Adipisci consequatur id in occaecati.
  74. # Et sint et. Ut ducimus quod nemo ab voluptatum.
  75. Each call to method ``fake.name()`` yields a different (random) result.
  76. This is because faker forwards ``faker.Generator.method_name()`` calls
  77. to ``faker.Generator.format(method_name)``.
  78. .. code:: python
  79. for _ in range(10):
  80. print(fake.name())
  81. # Adaline Reichel
  82. # Dr. Santa Prosacco DVM
  83. # Noemy Vandervort V
  84. # Lexi O'Conner
  85. # Gracie Weber
  86. # Roscoe Johns
  87. # Emmett Lebsack
  88. # Keegan Thiel
  89. # Wellington Koelpin II
  90. # Ms. Karley Kiehn V
  91. Providers
  92. ---------
  93. Each of the generator properties (like ``name``, ``address``, and
  94. ``lorem``) are called "fake". A faker generator has many of them,
  95. packaged in "providers".
  96. Check the `extended docs`_ for a list of `bundled providers`_ and a list of
  97. `community providers`_.
  98. Localization
  99. ------------
  100. ``faker.Factory`` can take a locale as an argument, to return localized
  101. data. If no localized provider is found, the factory falls back to the
  102. default en\_US locale.
  103. .. code:: python
  104. from faker import Faker
  105. fake = Faker('it_IT')
  106. for _ in range(10):
  107. print(fake.name())
  108. > Elda Palumbo
  109. > Pacifico Giordano
  110. > Sig. Avide Guerra
  111. > Yago Amato
  112. > Eustachio Messina
  113. > Dott. Violante Lombardo
  114. > Sig. Alighieri Monti
  115. > Costanzo Costa
  116. > Nazzareno Barbieri
  117. > Max Coppola
  118. You can check available Faker locales in the source code, under the
  119. providers package. The localization of Faker is an ongoing process, for
  120. which we need your help. Please don't hesitate to create a localized
  121. provider for your own locale and submit a Pull Request (PR).
  122. Included localized providers:
  123. - `ar\_EG <https://faker.readthedocs.io/en/master/locales/ar_EG.html>`__ - Arabic (Egypt)
  124. - `ar\_PS <https://faker.readthedocs.io/en/master/locales/ar_PS.html>`__ - Arabic (Palestine)
  125. - `ar\_SA <https://faker.readthedocs.io/en/master/locales/ar_SA.html>`__ - Arabic (Saudi Arabia)
  126. - `bg\_BG <https://faker.readthedocs.io/en/master/locales/bg_BG.html>`__ - Bulgarian
  127. - `cs\_CZ <https://faker.readthedocs.io/en/master/locales/cs_CZ.html>`__ - Czech
  128. - `de\_DE <https://faker.readthedocs.io/en/master/locales/de_DE.html>`__ - German
  129. - `dk\_DK <https://faker.readthedocs.io/en/master/locales/dk_DK.html>`__ - Danish
  130. - `el\_GR <https://faker.readthedocs.io/en/master/locales/el_GR.html>`__ - Greek
  131. - `en\_AU <https://faker.readthedocs.io/en/master/locales/en_AU.html>`__ - English (Australia)
  132. - `en\_CA <https://faker.readthedocs.io/en/master/locales/en_CA.html>`__ - English (Canada)
  133. - `en\_GB <https://faker.readthedocs.io/en/master/locales/en_GB.html>`__ - English (Great Britain)
  134. - `en\_NZ <https://faker.readthedocs.io/en/master/locales/en_NZ.html>`__ - English (New Zealand)
  135. - `en\_US <https://faker.readthedocs.io/en/master/locales/en_US.html>`__ - English (United States)
  136. - `es\_ES <https://faker.readthedocs.io/en/master/locales/es_ES.html>`__ - Spanish (Spain)
  137. - `es\_MX <https://faker.readthedocs.io/en/master/locales/es_MX.html>`__ - Spanish (Mexico)
  138. - `et\_EE <https://faker.readthedocs.io/en/master/locales/et_EE.html>`__ - Estonian
  139. - `fa\_IR <https://faker.readthedocs.io/en/master/locales/fa_IR.html>`__ - Persian (Iran)
  140. - `fi\_FI <https://faker.readthedocs.io/en/master/locales/fi_FI.html>`__ - Finnish
  141. - `fr\_FR <https://faker.readthedocs.io/en/master/locales/fr_FR.html>`__ - French
  142. - `hi\_IN <https://faker.readthedocs.io/en/master/locales/hi_IN.html>`__ - Hindi
  143. - `hr\_HR <https://faker.readthedocs.io/en/master/locales/hr_HR.html>`__ - Croatian
  144. - `hu\_HU <https://faker.readthedocs.io/en/master/locales/hu_HU.html>`__ - Hungarian
  145. - `it\_IT <https://faker.readthedocs.io/en/master/locales/it_IT.html>`__ - Italian
  146. - `ja\_JP <https://faker.readthedocs.io/en/master/locales/ja_JP.html>`__ - Japanese
  147. - `ko\_KR <https://faker.readthedocs.io/en/master/locales/ko_KR.html>`__ - Korean
  148. - `lt\_LT <https://faker.readthedocs.io/en/master/locales/lt_LT.html>`__ - Lithuanian
  149. - `lv\_LV <https://faker.readthedocs.io/en/master/locales/lv_LV.html>`__ - Latvian
  150. - `ne\_NP <https://faker.readthedocs.io/en/master/locales/ne_NP.html>`__ - Nepali
  151. - `nl\_NL <https://faker.readthedocs.io/en/master/locales/nl_NL.html>`__ - Dutch (Netherlands)
  152. - `no\_NO <https://faker.readthedocs.io/en/master/locales/no_NO.html>`__ - Norwegian
  153. - `pl\_PL <https://faker.readthedocs.io/en/master/locales/pl_PL.html>`__ - Polish
  154. - `pt\_BR <https://faker.readthedocs.io/en/master/locales/pt_BR.html>`__ - Portuguese (Brazil)
  155. - `pt\_PT <https://faker.readthedocs.io/en/master/locales/pt_PT.html>`__ - Portuguese (Portugal)
  156. - `ro\_RO <https://faker.readthedocs.io/en/master/locales/ro_RO.html>`__ - Romanian
  157. - `ru\_RU <https://faker.readthedocs.io/en/master/locales/ru_RU.html>`__ - Russian
  158. - `sl\_SI <https://faker.readthedocs.io/en/master/locales/sl_SI.html>`__ - Slovene
  159. - `sv\_SE <https://faker.readthedocs.io/en/master/locales/sv_SE.html>`__ - Swedish
  160. - `tr\_TR <https://faker.readthedocs.io/en/master/locales/tr_TR.html>`__ - Turkish
  161. - `uk\_UA <https://faker.readthedocs.io/en/master/locales/uk_UA.html>`__ - Ukrainian
  162. - `zh\_CN <https://faker.readthedocs.io/en/master/locales/zh_CN.html>`__ - Chinese (China)
  163. - `zh\_TW <https://faker.readthedocs.io/en/master/locales/zh_TW.html>`__ - Chinese (Taiwan)
  164. - `ka\_GE <https://faker.readthedocs.io/en/master/locales/ka_GE.html>`__ - Georgian (Georgia)
  165. Command line usage
  166. ------------------
  167. When installed, you can invoke faker from the command-line:
  168. .. code:: bash
  169. faker [-h] [--version] [-o output]
  170. [-l {bg_BG,cs_CZ,...,zh_CN,zh_TW}]
  171. [-r REPEAT] [-s SEP]
  172. [-i {package.containing.custom_provider otherpkg.containing.custom_provider}]
  173. [fake] [fake argument [fake argument ...]]
  174. Where:
  175. - ``faker``: is the script when installed in your environment, in
  176. development you could use ``python -m faker`` instead
  177. - ``-h``, ``--help``: shows a help message
  178. - ``--version``: shows the program's version number
  179. - ``-o FILENAME``: redirects the output to the specified filename
  180. - ``-l {bg_BG,cs_CZ,...,zh_CN,zh_TW}``: allows use of a localized
  181. provider
  182. - ``-r REPEAT``: will generate a specified number of outputs
  183. - ``-s SEP``: will generate the specified separator after each
  184. generated output
  185. - ``-i {my.custom_provider other.custom_provider}`` list of additional custom providers to use.
  186. Note that is the import path of the package containing your Provider class, not the custom Provider class itself.
  187. - ``fake``: is the name of the fake to generate an output for, such as
  188. ``name``, ``address``, or ``text``
  189. - ``[fake argument ...]``: optional arguments to pass to the fake (e.g. the profile fake takes an optional list of comma separated field names as the first argument)
  190. Examples:
  191. .. code:: bash
  192. $ faker address
  193. 968 Bahringer Garden Apt. 722
  194. Kristinaland, NJ 09890
  195. $ faker -l de_DE address
  196. Samira-Niemeier-Allee 56
  197. 94812 Biedenkopf
  198. $ faker profile ssn,birthdate
  199. {'ssn': u'628-10-1085', 'birthdate': '2008-03-29'}
  200. $ faker -r=3 -s=";" name
  201. Willam Kertzmann;
  202. Josiah Maggio;
  203. Gayla Schmitt;
  204. How to create a Provider
  205. ------------------------
  206. .. code:: python
  207. from faker import Faker
  208. fake = Faker()
  209. # first, import a similar Provider or use the default one
  210. from faker.providers import BaseProvider
  211. # create new provider class. Note that the class name _must_ be ``Provider``.
  212. class Provider(BaseProvider):
  213. def foo(self):
  214. return 'bar'
  215. # then add new provider to faker instance
  216. fake.add_provider(Provider)
  217. # now you can use:
  218. fake.foo()
  219. > 'bar'
  220. How to customize the Lorem Provider
  221. -----------------------------------
  222. You can provide your own sets of words if you don't want to use the
  223. default lorem ipsum one. The following example shows how to do it with a list of words picked from `cakeipsum <http://www.cupcakeipsum.com/>`__ :
  224. .. code:: python
  225. from faker import Faker
  226. fake = Faker()
  227. my_word_list = [
  228. 'danish','cheesecake','sugar',
  229. 'Lollipop','wafer','Gummies',
  230. 'sesame','Jelly','beans',
  231. 'pie','bar','Ice','oat' ]
  232. fake.sentence()
  233. #'Expedita at beatae voluptatibus nulla omnis.'
  234. fake.sentence(ext_word_list=my_word_list)
  235. # 'Oat beans oat Lollipop bar cheesecake.'
  236. How to use with Factory Boy
  237. ---------------------------
  238. `Factory Boy` already ships with integration with ``Faker``. Simply use the
  239. ``factory.Faker`` method of ``factory_boy``:
  240. .. code:: python
  241. import factory
  242. from myapp.models import Book
  243. class BookFactory(factory.Factory):
  244. class Meta:
  245. model = Book
  246. title = factory.Faker('sentence', nb_words=4)
  247. author_name = factory.Faker('name')
  248. Accessing the `random` instance
  249. -------------------------------
  250. The ``.random`` property on the generator returns the instance of ``random.Random``
  251. used to generate the values:
  252. .. code:: python
  253. from faker import Faker
  254. fake = Faker()
  255. fake.random
  256. fake.random.getstate()
  257. By default all generators share the same instance of ``random.Random``, which
  258. can be accessed with ``from faker.generator import random``. Using this may
  259. be useful for plugins that want to affect all faker instances.
  260. Seeding the Generator
  261. ---------------------
  262. When using Faker for unit testing, you will often want to generate the same
  263. data set. For convenience, the generator also provide a ``seed()`` method, which
  264. seeds the shared random number generator. Calling the same methods with the
  265. same version of faker and seed produces the same results.
  266. .. code:: python
  267. from faker import Faker
  268. fake = Faker()
  269. fake.seed(4321)
  270. print(fake.name())
  271. > Margaret Boehm
  272. Each generator can also be switched to its own instance of ``random.Random``,
  273. separate to the shared one, by using the ``seed_instance()`` method, which acts
  274. the same way. For example:
  275. .. code-block:: python
  276. from faker import Faker
  277. fake = Faker()
  278. fake.seed_instance(4321)
  279. print(fake.name())
  280. > Margaret Boehm
  281. Please note that as we keep updating datasets, results are not guaranteed to be
  282. consistent across patch versions. If you hardcode results in your test, make sure
  283. you pinned the version of ``Faker`` down to the patch number.
  284. Tests
  285. -----
  286. Installing dependencies:
  287. .. code:: bash
  288. $ pip install -r tests/requirements.txt
  289. Run tests:
  290. .. code:: bash
  291. $ python setup.py test
  292. or
  293. .. code:: bash
  294. $ python -m unittest -v tests
  295. Write documentation for providers:
  296. .. code:: bash
  297. $ python -m faker > docs.txt
  298. Contribute
  299. ----------
  300. Please see `CONTRIBUTING`_.
  301. License
  302. -------
  303. Faker is released under the MIT License. See the bundled `LICENSE`_ file for details.
  304. Credits
  305. -------
  306. - `FZaninotto`_ / `PHP Faker`_
  307. - `Distribute`_
  308. - `Buildout`_
  309. - `modern-package-template`_
  310. .. _FZaninotto: https://github.com/fzaninotto
  311. .. _PHP Faker: https://github.com/fzaninotto/Faker
  312. .. _Perl Faker: http://search.cpan.org/~jasonk/Data-Faker-0.07/
  313. .. _Ruby Faker: https://github.com/stympy/faker
  314. .. _Distribute: https://pypi.org/project/distribute/
  315. .. _Buildout: http://www.buildout.org/
  316. .. _modern-package-template: https://pypi.org/project/modern-package-template/
  317. .. _extended docs: https://faker.readthedocs.io/en/latest/
  318. .. _bundled providers: https://faker.readthedocs.io/en/latest/providers.html
  319. .. _community providers: https://faker.readthedocs.io/en/latest/communityproviders.html
  320. .. _LICENSE: https://github.com/joke2k/faker/blob/master/LICENSE.txt
  321. .. _CONTRIBUTING: https://github.com/joke2k/faker/blob/master/CONTRIBUTING.rst
  322. .. _Factory Boy: https://github.com/FactoryBoy/factory_boy
  323. .. |pypi| image:: https://img.shields.io/pypi/v/Faker.svg?style=flat-square&label=version
  324. :target: https://pypi.org/project/Faker/
  325. :alt: Latest version released on PyPi
  326. .. |coverage| image:: https://img.shields.io/coveralls/joke2k/faker/master.svg?style=flat-square
  327. :target: https://coveralls.io/r/joke2k/faker?branch=master
  328. :alt: Test coverage
  329. .. |unix_build| image:: https://img.shields.io/travis/joke2k/faker/master.svg?style=flat-square&label=unix%20build
  330. :target: http://travis-ci.org/joke2k/faker
  331. :alt: Build status of the master branch on Mac/Linux
  332. .. |windows_build| image:: https://img.shields.io/appveyor/ci/joke2k/faker/master.svg?style=flat-square&label=windows%20build
  333. :target: https://ci.appveyor.com/project/joke2k/faker
  334. :alt: Build status of the master branch on Windows
  335. .. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
  336. :target: https://raw.githubusercontent.com/joke2k/faker/master/LICENSE.txt
  337. :alt: Package license