fakeverse 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. fakeverse-0.1.0/.github/CODEOWNERS +8 -0
  2. fakeverse-0.1.0/.gitignore +26 -0
  3. fakeverse-0.1.0/CHANGELOG.md +54 -0
  4. fakeverse-0.1.0/LICENSE +21 -0
  5. fakeverse-0.1.0/NOTICE +1 -0
  6. fakeverse-0.1.0/PKG-INFO +253 -0
  7. fakeverse-0.1.0/README.md +215 -0
  8. fakeverse-0.1.0/docs/problems.md +94 -0
  9. fakeverse-0.1.0/pyproject.toml +164 -0
  10. fakeverse-0.1.0/releases.toml +16 -0
  11. fakeverse-0.1.0/schema/universe.schema.json +1307 -0
  12. fakeverse-0.1.0/scripts/build_snapshots.py +117 -0
  13. fakeverse-0.1.0/scripts/check_commits.py +115 -0
  14. fakeverse-0.1.0/scripts/check_deployment.sh +73 -0
  15. fakeverse-0.1.0/scripts/check_wheel.sh +35 -0
  16. fakeverse-0.1.0/scripts/release.py +287 -0
  17. fakeverse-0.1.0/src/fakeverse/__init__.py +22 -0
  18. fakeverse-0.1.0/src/fakeverse/api/__init__.py +1 -0
  19. fakeverse-0.1.0/src/fakeverse/api/app.py +240 -0
  20. fakeverse-0.1.0/src/fakeverse/api/cache.py +38 -0
  21. fakeverse-0.1.0/src/fakeverse/api/formats.py +54 -0
  22. fakeverse-0.1.0/src/fakeverse/api/metrics.py +58 -0
  23. fakeverse-0.1.0/src/fakeverse/api/problems.py +107 -0
  24. fakeverse-0.1.0/src/fakeverse/api/ratelimit.py +137 -0
  25. fakeverse-0.1.0/src/fakeverse/api/routes.py +612 -0
  26. fakeverse-0.1.0/src/fakeverse/api/schemas.py +161 -0
  27. fakeverse-0.1.0/src/fakeverse/api/settings.py +74 -0
  28. fakeverse-0.1.0/src/fakeverse/api/snapshots.py +114 -0
  29. fakeverse-0.1.0/src/fakeverse/capabilities.py +115 -0
  30. fakeverse-0.1.0/src/fakeverse/cli.py +369 -0
  31. fakeverse-0.1.0/src/fakeverse/coherence.py +210 -0
  32. fakeverse-0.1.0/src/fakeverse/engine/__init__.py +1 -0
  33. fakeverse-0.1.0/src/fakeverse/engine/colocate.py +123 -0
  34. fakeverse-0.1.0/src/fakeverse/engine/explain.py +50 -0
  35. fakeverse-0.1.0/src/fakeverse/engine/generators/__init__.py +135 -0
  36. fakeverse-0.1.0/src/fakeverse/engine/generators/address.py +51 -0
  37. fakeverse-0.1.0/src/fakeverse/engine/generators/common.py +53 -0
  38. fakeverse-0.1.0/src/fakeverse/engine/generators/extensions.py +44 -0
  39. fakeverse-0.1.0/src/fakeverse/engine/generators/organization.py +56 -0
  40. fakeverse-0.1.0/src/fakeverse/engine/generators/person.py +79 -0
  41. fakeverse-0.1.0/src/fakeverse/engine/index.py +305 -0
  42. fakeverse-0.1.0/src/fakeverse/engine/revision.py +10 -0
  43. fakeverse-0.1.0/src/fakeverse/engine/template.py +173 -0
  44. fakeverse-0.1.0/src/fakeverse/engine/unique.py +97 -0
  45. fakeverse-0.1.0/src/fakeverse/errors.py +107 -0
  46. fakeverse-0.1.0/src/fakeverse/faker.py +169 -0
  47. fakeverse-0.1.0/src/fakeverse/fakeverse.py +333 -0
  48. fakeverse-0.1.0/src/fakeverse/formats.py +92 -0
  49. fakeverse-0.1.0/src/fakeverse/hierarchy.py +74 -0
  50. fakeverse-0.1.0/src/fakeverse/loader.py +202 -0
  51. fakeverse-0.1.0/src/fakeverse/locale.py +97 -0
  52. fakeverse-0.1.0/src/fakeverse/model/__init__.py +47 -0
  53. fakeverse-0.1.0/src/fakeverse/model/base.py +148 -0
  54. fakeverse-0.1.0/src/fakeverse/model/universe.py +253 -0
  55. fakeverse-0.1.0/src/fakeverse/patterns/__init__.py +25 -0
  56. fakeverse-0.1.0/src/fakeverse/patterns/parser.py +186 -0
  57. fakeverse-0.1.0/src/fakeverse/patterns/renderer.py +132 -0
  58. fakeverse-0.1.0/src/fakeverse/py.typed +0 -0
  59. fakeverse-0.1.0/src/fakeverse/releases.py +80 -0
  60. fakeverse-0.1.0/src/fakeverse/rng.py +80 -0
  61. fakeverse-0.1.0/src/fakeverse/types.py +115 -0
  62. fakeverse-0.1.0/src/fakeverse/validation.py +579 -0
  63. fakeverse-0.1.0/tests/api/api_support.py +16 -0
  64. fakeverse-0.1.0/tests/api/conftest.py +53 -0
  65. fakeverse-0.1.0/tests/api/test_api_cache.py +80 -0
  66. fakeverse-0.1.0/tests/api/test_api_colocate.py +57 -0
  67. fakeverse-0.1.0/tests/api/test_api_endpoints.py +191 -0
  68. fakeverse-0.1.0/tests/api/test_api_fuzz.py +105 -0
  69. fakeverse-0.1.0/tests/api/test_api_generate.py +186 -0
  70. fakeverse-0.1.0/tests/api/test_api_operations.py +236 -0
  71. fakeverse-0.1.0/tests/api/test_api_template.py +130 -0
  72. fakeverse-0.1.0/tests/api/test_api_template_get.py +137 -0
  73. fakeverse-0.1.0/tests/bench/bench_generate.py +38 -0
  74. fakeverse-0.1.0/tests/conftest.py +39 -0
  75. fakeverse-0.1.0/tests/fixtures/invalid/r01-duplicate-key.yaml +47 -0
  76. fakeverse-0.1.0/tests/fixtures/invalid/r01-unknown-key.yaml +47 -0
  77. fakeverse-0.1.0/tests/fixtures/invalid/r01-yaml-alias.yaml +46 -0
  78. fakeverse-0.1.0/tests/fixtures/invalid/r01-yaml-syntax.yaml +46 -0
  79. fakeverse-0.1.0/tests/fixtures/invalid/r02-id-mismatch.yaml +46 -0
  80. fakeverse-0.1.0/tests/fixtures/invalid/r02-invalid-id.yaml +46 -0
  81. fakeverse-0.1.0/tests/fixtures/invalid/r03-duplicate-id.yaml +48 -0
  82. fakeverse-0.1.0/tests/fixtures/invalid/r04-unknown-homeland.yaml +46 -0
  83. fakeverse-0.1.0/tests/fixtures/invalid/r04-unknown-parent.yaml +46 -0
  84. fakeverse-0.1.0/tests/fixtures/invalid/r04-unknown-vocab.yaml +46 -0
  85. fakeverse-0.1.0/tests/fixtures/invalid/r05-area-with-parent.yaml +47 -0
  86. fakeverse-0.1.0/tests/fixtures/invalid/r05-locality-under-locality.yaml +50 -0
  87. fakeverse-0.1.0/tests/fixtures/invalid/r06-homeland-without-locality.yaml +49 -0
  88. fakeverse-0.1.0/tests/fixtures/invalid/r07-missing-default-locale.yaml +46 -0
  89. fakeverse-0.1.0/tests/fixtures/invalid/r07-undeclared-locale.yaml +46 -0
  90. fakeverse-0.1.0/tests/fixtures/invalid/r08-invalid-locale.yaml +46 -0
  91. fakeverse-0.1.0/tests/fixtures/invalid/r09-field-not-allowed.yaml +46 -0
  92. fakeverse-0.1.0/tests/fixtures/invalid/r09-pattern-syntax.yaml +46 -0
  93. fakeverse-0.1.0/tests/fixtures/invalid/r10-no-locality.yaml +42 -0
  94. fakeverse-0.1.0/tests/fixtures/invalid/r10-no-people.yaml +41 -0
  95. fakeverse-0.1.0/tests/fixtures/invalid/r11-string-too-long.yaml +46 -0
  96. fakeverse-0.1.0/tests/fixtures/invalid/r13-reserved-extension-id.yaml +53 -0
  97. fakeverse-0.1.0/tests/fixtures/universes/test-world.yaml +218 -0
  98. fakeverse-0.1.0/tests/fixtures/valid/minimal.yaml +48 -0
  99. fakeverse-0.1.0/tests/golden/address-fr-1.json +63 -0
  100. fakeverse-0.1.0/tests/golden/aliases-en-11.json +74 -0
  101. fakeverse-0.1.0/tests/golden/aliases-fr-11.json +74 -0
  102. fakeverse-0.1.0/tests/golden/barge-en-6.json +55 -0
  103. fakeverse-0.1.0/tests/golden/barge-fr-6-explain.json +65 -0
  104. fakeverse-0.1.0/tests/golden/first-name-en-2-unique.json +27 -0
  105. fakeverse-0.1.0/tests/golden/organization-en-5.json +119 -0
  106. fakeverse-0.1.0/tests/golden/organization-fr-5-explain.json +131 -0
  107. fakeverse-0.1.0/tests/golden/person-en-42.json +105 -0
  108. fakeverse-0.1.0/tests/golden/person-en-9-options.json +87 -0
  109. fakeverse-0.1.0/tests/golden/person-fr-3-people.json +69 -0
  110. fakeverse-0.1.0/tests/golden/person-fr-42.json +105 -0
  111. fakeverse-0.1.0/tests/golden/person-fr-7-explain.json +191 -0
  112. fakeverse-0.1.0/tests/golden/relic-fr-4.json +35 -0
  113. fakeverse-0.1.0/tests/golden/template-en-8-explain.json +207 -0
  114. fakeverse-0.1.0/tests/golden/template-fr-8.json +67 -0
  115. fakeverse-0.1.0/tests/golden/test_golden.py +97 -0
  116. fakeverse-0.1.0/tests/property/test_invariants.py +47 -0
  117. fakeverse-0.1.0/tests/property/test_robustness.py +192 -0
  118. fakeverse-0.1.0/tests/support.py +8 -0
  119. fakeverse-0.1.0/tests/unit/test_build_snapshots.py +127 -0
  120. fakeverse-0.1.0/tests/unit/test_capabilities.py +96 -0
  121. fakeverse-0.1.0/tests/unit/test_check_commits.py +123 -0
  122. fakeverse-0.1.0/tests/unit/test_cli.py +123 -0
  123. fakeverse-0.1.0/tests/unit/test_cli_generate.py +228 -0
  124. fakeverse-0.1.0/tests/unit/test_codeowners.py +34 -0
  125. fakeverse-0.1.0/tests/unit/test_coherence.py +92 -0
  126. fakeverse-0.1.0/tests/unit/test_colocate.py +143 -0
  127. fakeverse-0.1.0/tests/unit/test_determinism_guard.py +63 -0
  128. fakeverse-0.1.0/tests/unit/test_engine.py +197 -0
  129. fakeverse-0.1.0/tests/unit/test_errors.py +27 -0
  130. fakeverse-0.1.0/tests/unit/test_faker_provider.py +101 -0
  131. fakeverse-0.1.0/tests/unit/test_formats.py +66 -0
  132. fakeverse-0.1.0/tests/unit/test_generators.py +216 -0
  133. fakeverse-0.1.0/tests/unit/test_hierarchy.py +53 -0
  134. fakeverse-0.1.0/tests/unit/test_loader.py +100 -0
  135. fakeverse-0.1.0/tests/unit/test_locale.py +84 -0
  136. fakeverse-0.1.0/tests/unit/test_model.py +98 -0
  137. fakeverse-0.1.0/tests/unit/test_package.py +39 -0
  138. fakeverse-0.1.0/tests/unit/test_patterns_parser.py +76 -0
  139. fakeverse-0.1.0/tests/unit/test_release.py +238 -0
  140. fakeverse-0.1.0/tests/unit/test_renderer.py +120 -0
  141. fakeverse-0.1.0/tests/unit/test_rng.py +68 -0
  142. fakeverse-0.1.0/tests/unit/test_template.py +130 -0
  143. fakeverse-0.1.0/tests/unit/test_universes.py +41 -0
  144. fakeverse-0.1.0/tests/unit/test_validation_rules.py +401 -0
  145. fakeverse-0.1.0/universes/LICENSE +121 -0
  146. fakeverse-0.1.0/universes/lotr.yaml +843 -0
  147. fakeverse-0.1.0/universes/starwars.yaml +659 -0
@@ -0,0 +1,8 @@
1
+ # Core of the project: main maintainer.
2
+ /src/ @Kentrow
3
+ /schema/ @Kentrow
4
+ /.github/ @Kentrow
5
+
6
+ # Universe files: their declared maintainers (universe.maintainers).
7
+ /universes/lotr.yaml @Kentrow
8
+ /universes/starwars.yaml @Kentrow
@@ -0,0 +1,26 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+
6
+ # Environments
7
+ .venv/
8
+
9
+ # Build
10
+ build/
11
+ dist/
12
+
13
+ # Tooling caches
14
+ .mypy_cache/
15
+ .ruff_cache/
16
+ .pytest_cache/
17
+ .hypothesis/
18
+ .coverage
19
+ .coverage.*
20
+ coverage.xml
21
+ htmlcov/
22
+
23
+ # Editors and OS
24
+ .idea/
25
+ .vscode/
26
+ .DS_Store
@@ -0,0 +1,54 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+ Changes to `ENGINE_REVISION` are always listed, since they change generated output. See
8
+ [CONTRIBUTING.md](CONTRIBUTING.md#versioning) for the versioning policy.
9
+
10
+ ## [Unreleased]
11
+
12
+ ## [0.1.0] - 2026-10-07
13
+
14
+ First release. `ENGINE_REVISION` = 1.
15
+
16
+ ### Added
17
+
18
+ - Universes `lotr` (The Lord of the Rings, books only) and `starwars` (Star Wars, Disney
19
+ canon), in English and French. French names follow the reference translations.
20
+ - Core types `person`, `address` and `organization`, their atomic projections, and extension
21
+ types declared by each universe (`weapon`, `starship`...).
22
+ - Deterministic generation: the same seed, data version and request always give the same
23
+ result, stable by prefix; a random seed is drawn and returned when none is given.
24
+ - Locales in BCP-47 form, with normalization and reported fallbacks.
25
+ - Uniqueness by default, as far as the pool allows, with duplicates counted in
26
+ `meta.duplicates`; `unique=true` is strict and `unique=false` allows duplicates.
27
+ - Explain mode: origin (`canon` or `generated`), locale and fallback of each value.
28
+ - Templates: rows combining several types, with shared instances, and colocation groups of
29
+ instances located in the same locality.
30
+ - Python API: `Fakeverse`, `UniverseGenerator`, `GenerationResult`.
31
+ - Faker provider (extra `faker`): `fake.fakeverse(universe)`, with one method per core type,
32
+ `generate`, `template` and `.unique`.
33
+ - Command line: `generate`, `template`, `info`, and for contributors `validate`, `coverage`,
34
+ `check-coherence` and `schema export`; JSON, NDJSON and CSV output.
35
+ - HTTP API (extra `api`): every endpoint of `/v1`, JSON, NDJSON and CSV formats, template
36
+ generation by `POST` or by a cacheable `GET`, RFC 9457 problems whose types lead to their
37
+ documentation, per-client rate limiting with trusted proxies, HTTP caching with ETag,
38
+ several data versions, configuration by environment variables, JSON access logs and
39
+ optional Prometheus metrics.
40
+ - Docker image of the API, with the data of every release of the current engine revision.
41
+ - Universe file format with a JSON Schema (`schema/universe.schema.json`), and validation with
42
+ YAML paths, line numbers and stable error codes.
43
+ - Documentation: universe guide, how generation works, API reference, API problems,
44
+ deployment guide, architecture, security policy and release procedure.
45
+ - Releases with signed provenance: PyPI distributions with PEP 740 attestations, and a
46
+ multi-platform image (`linux/amd64`, `linux/arm64`) with an SBOM.
47
+ - Hardening: YAML anchors and aliases are refused in universe files, invalid encodings and
48
+ excessive nesting are reported instead of crashing; in the API, template generation runs
49
+ off the event loop with a work budget, bodies are read as a stream and capped at 64 KB,
50
+ IPv6 clients are rate limited per /64 network, and every `X-Forwarded-For` header is taken
51
+ into account.
52
+
53
+ [Unreleased]: https://github.com/Kentrow/fakeverse/compare/v0.1.0...HEAD
54
+ [0.1.0]: https://github.com/Kentrow/fakeverse/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kentrow
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
fakeverse-0.1.0/NOTICE ADDED
@@ -0,0 +1 @@
1
+ Fakeverse is an independent, non-commercial open source project. It is not affiliated with, endorsed by, or sponsored by any rights holder of the works it draws inspiration from. All names, characters, places and trademarks belong to their respective owners. The licenses of this repository (MIT for code, CC0-1.0 for universe files) apply only to the contributions of the Fakeverse project (data structure, patterns, generated vocabulary and original content), not to the underlying names and trademarks. Universe files contain only short names and labels; no text, quotes or images from the original works.
@@ -0,0 +1,253 @@
1
+ Metadata-Version: 2.5
2
+ Name: fakeverse
3
+ Version: 0.1.0
4
+ Summary: Coherent fake data generator themed by fictional universes.
5
+ Project-URL: Homepage, https://github.com/Kentrow/fakeverse
6
+ Project-URL: Documentation, https://github.com/Kentrow/fakeverse/tree/main/docs
7
+ Project-URL: Repository, https://github.com/Kentrow/fakeverse
8
+ Project-URL: Issues, https://github.com/Kentrow/fakeverse/issues
9
+ Project-URL: Changelog, https://github.com/Kentrow/fakeverse/blob/main/CHANGELOG.md
10
+ Author: Kentrow
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ License-File: universes/LICENSE
15
+ Keywords: fake,faker,fiction,fixtures,test-data
16
+ Classifier: Development Status :: 4 - Beta
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Software Development :: Testing
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.12
27
+ Requires-Dist: pydantic>=2.11
28
+ Requires-Dist: pyyaml>=6.0.2
29
+ Requires-Dist: typer>=0.16
30
+ Provides-Extra: api
31
+ Requires-Dist: fastapi>=0.115; extra == 'api'
32
+ Requires-Dist: prometheus-client>=0.21; extra == 'api'
33
+ Requires-Dist: pydantic-settings>=2.9; extra == 'api'
34
+ Requires-Dist: uvicorn>=0.34; extra == 'api'
35
+ Provides-Extra: faker
36
+ Requires-Dist: faker>=37; extra == 'faker'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # Fakeverse
40
+
41
+ [![CI](https://github.com/Kentrow/fakeverse/actions/workflows/ci.yml/badge.svg)](https://github.com/Kentrow/fakeverse/actions/workflows/ci.yml)
42
+ [![PyPI](https://img.shields.io/pypi/v/fakeverse)](https://pypi.org/project/fakeverse/)
43
+ [![Python](https://img.shields.io/pypi/pyversions/fakeverse)](https://pypi.org/project/fakeverse/)
44
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://github.com/Kentrow/fakeverse/blob/main/LICENSE)
45
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/Kentrow/fakeverse/badge)](https://scorecard.dev/viewer/?uri=github.com/Kentrow/fakeverse)
46
+
47
+ Fakeverse generates fake data themed by works of fiction. Think
48
+ [Faker](https://faker.readthedocs.io/), but the people, addresses and organizations come from
49
+ a fictional world, and they are **consistent with each other**: a hobbit lives in a town of
50
+ the Shire, the town is in the right region, and the email is built from the name.
51
+
52
+ For instance, `lotr.one("person", people="hobbit", seed=7)` gives:
53
+
54
+ ```json
55
+ {
56
+ "first_name": "Gilly",
57
+ "last_name": "Took",
58
+ "full_name": "Gilly Took",
59
+ "gender": "feminine",
60
+ "people": "Hobbit",
61
+ "address": {
62
+ "street_address": "7 Smithy Street",
63
+ "postal_code": "SH-594",
64
+ "locality": "Oatbarton",
65
+ "subdivision": "The Shire",
66
+ "area": "Eriador",
67
+ "formatted": "7 Smithy Street\nOatbarton SH-594\nThe Shire, Eriador"
68
+ },
69
+ "email": "gilly.took@post.example",
70
+ "username": "gilly972",
71
+ "phone": "+35 872 9950"
72
+ }
73
+ ```
74
+
75
+ - **Coherent**: generated values respect the relations between peoples, places and names.
76
+ - **Multilingual**: every universe is translated, following a reference translation, and
77
+ fallbacks to another language are reported.
78
+ - **Reproducible**: the same seed and the same data version always give the same result.
79
+ - **Easy to contribute**: one YAML file per universe, validated automatically.
80
+ - **Everywhere**: Python package, Faker provider, command line and HTTP API.
81
+
82
+ ## Universes
83
+
84
+ | Id | Universe | Scope | Locales |
85
+ | --- | --- | --- | --- |
86
+ | `lotr` | The Lord of the Rings | The books only, no film adaptations | English, French |
87
+ | `starwars` | Star Wars | The Disney canon (2014 and later) | English, French |
88
+
89
+ New universes are welcome: see [Contributing](#contributing).
90
+
91
+ ## Installation
92
+
93
+ ```bash
94
+ pip install fakeverse # package and command line
95
+ pip install "fakeverse[faker]" # with the Faker provider
96
+ pip install "fakeverse[api]" # with the HTTP API
97
+ ```
98
+
99
+ Fakeverse needs Python 3.12 or later.
100
+
101
+ ## Python package
102
+
103
+ ```python
104
+ from fakeverse import Fakeverse
105
+
106
+ fv = Fakeverse()
107
+ lotr = fv.universe("lotr")
108
+
109
+ result = lotr.generate("first_name", count=3, seed=42)
110
+ result.items # ['Andwise', 'Orodreth', 'Dáin']
111
+ result.meta.seed # 42
112
+
113
+ lotr.one("full_name", seed=1, gender="feminine") # 'Dís'
114
+ lotr.generate("person", count=5, people="hobbit") # five hobbits, no duplicates
115
+ lotr.generate("weapon", count=2, seed=3).items # a type specific to the universe
116
+ # [{'name': 'Glamdring', 'kind': 'Sword'}, {'name': 'Aeglos', 'kind': 'Spear'}]
117
+
118
+ fv.universe("lotr", locale="fr").generate("full_name", count=3, seed=42).items
119
+ # ['Flói', 'Hugo Goold', 'Fréaláf']
120
+ ```
121
+
122
+ Templates combine several types in one row. Leaves that reference the same instance describe
123
+ the same entity, and `colocate` puts instances in the same locality:
124
+
125
+ ```python
126
+ lotr.template(
127
+ {
128
+ "name": "person.full_name",
129
+ "employer": "organization.name",
130
+ "town": "person.address.locality",
131
+ },
132
+ count=2,
133
+ seed=7,
134
+ colocate=[["person", "organization"]],
135
+ ).items
136
+ # [{'name': 'Théodred', 'employer': 'The Wild Boar', 'town': 'Aldburg'},
137
+ # {'name': 'Náli', 'employer': 'The Old Mill', 'town': 'Erebor'}]
138
+ ```
139
+
140
+ Types: the composites `person`, `address` and `organization`, their projections
141
+ (`first_name`, `last_name`, `full_name`, `email`, `username`, `phone`, `street_address`,
142
+ `postal_code`, `locality`, `subdivision`, `area`, `organization_name`), and the types specific
143
+ to each universe. Options include `unique` (on by default, as far as the pool allows) and
144
+ `explain`, which tells for each value whether it comes from the works (`canon`) or was made
145
+ up (`generated`).
146
+
147
+ [How generation works](https://github.com/Kentrow/fakeverse/blob/main/docs/generation.md)
148
+ describes types, seeds, locales, uniqueness and templates in detail.
149
+
150
+ ## Faker provider
151
+
152
+ ```python
153
+ from faker import Faker
154
+ from fakeverse.faker import FakeverseProvider
155
+
156
+ fake = Faker("fr_FR")
157
+ fake.add_provider(FakeverseProvider)
158
+
159
+ fake.fakeverse("lotr").person()
160
+ fake.fakeverse("lotr").first_name(gender="feminine")
161
+ fake.fakeverse("lotr").generate("weapon")
162
+ fake.fakeverse("lotr").template({"name": "person.full_name"})
163
+ fake.fakeverse("lotr").unique.first_name() # never twice the same value
164
+ ```
165
+
166
+ `Faker.seed()` makes sequences reproducible. The locale of Faker is used when the universe
167
+ supports its language, and the default locale of the universe otherwise;
168
+ `fake.fakeverse("lotr", strict_locale=True)` raises an error instead.
169
+
170
+ ## Command line
171
+
172
+ ```bash
173
+ fakeverse generate lotr person -n 3 --seed 42 --locale fr
174
+ fakeverse generate lotr full_name -n 100 --format csv > names.csv
175
+ echo '{"name": "person.full_name", "employer": "organization.name"}' \
176
+ | fakeverse template lotr - -n 10 --format ndjson --colocate person,organization
177
+ fakeverse info
178
+ ```
179
+
180
+ `fakeverse --help` lists every command. Contributors also use `fakeverse validate`,
181
+ `fakeverse coverage` and `fakeverse check-coherence`.
182
+
183
+ ## HTTP API
184
+
185
+ ```bash
186
+ pip install "fakeverse[api]"
187
+ uvicorn fakeverse.api.app:app --no-access-log
188
+
189
+ curl "http://localhost:8000/v1/universes/lotr/generate/person?count=3&seed=42&locale=fr"
190
+ curl "http://localhost:8000/v1/universes/starwars/generate/starship?count=10&format=csv"
191
+ curl -X POST "http://localhost:8000/v1/universes/lotr/generate" \
192
+ -H "Content-Type: application/json" \
193
+ -d '{"template": {"name": "person.full_name", "town": "person.address.locality"}, "count": 10}'
194
+ ```
195
+
196
+ The API supports JSON, NDJSON and CSV, reports errors in the RFC 9457 format, applies rate
197
+ limiting, and sets HTTP cache headers on requests with a seed. The interactive documentation
198
+ is served at `/docs`. See the
199
+ [API reference](https://github.com/Kentrow/fakeverse/blob/main/docs/api.md) and the
200
+ [deployment guide](https://github.com/Kentrow/fakeverse/blob/main/docs/deployment.md), which
201
+ covers the Docker image.
202
+
203
+ ## Stability
204
+
205
+ Fakeverse is young: until 1.0.0, a minor release (0.2.0, 0.3.0...) may change the API, the
206
+ universe file format or the generated output, and the
207
+ [changelog](https://github.com/Kentrow/fakeverse/blob/main/CHANGELOG.md) always says so. A patch
208
+ release (0.1.1) never changes any output. Whatever the version, a given version of the package,
209
+ or a given `data_version` of the API, always gives the same output for the same request and
210
+ seed. Pin the version when you rely on generated values, in tests or fixtures.
211
+
212
+ ## Documentation
213
+
214
+ - [How generation works](https://github.com/Kentrow/fakeverse/blob/main/docs/generation.md):
215
+ types, seeds, locales, uniqueness, templates.
216
+ - [API reference](https://github.com/Kentrow/fakeverse/blob/main/docs/api.md) and
217
+ [API problems](https://github.com/Kentrow/fakeverse/blob/main/docs/problems.md).
218
+ - [Deployment guide](https://github.com/Kentrow/fakeverse/blob/main/docs/deployment.md).
219
+ - [Universe guide](https://github.com/Kentrow/fakeverse/blob/main/docs/universe-guide.md), to
220
+ write or extend a universe, and
221
+ [architecture](https://github.com/Kentrow/fakeverse/blob/main/docs/architecture.md), to change
222
+ the code.
223
+ - [Changelog](https://github.com/Kentrow/fakeverse/blob/main/CHANGELOG.md) and
224
+ [security policy](https://github.com/Kentrow/fakeverse/blob/main/SECURITY.md).
225
+
226
+ ## Contributing
227
+
228
+ New universes, names, translations and fixes are welcome. Read the
229
+ [contributing guide](https://github.com/Kentrow/fakeverse/blob/main/CONTRIBUTING.md) and the
230
+ [universe guide](https://github.com/Kentrow/fakeverse/blob/main/docs/universe-guide.md).
231
+
232
+ ## License
233
+
234
+ - Code: [MIT](https://github.com/Kentrow/fakeverse/blob/main/LICENSE).
235
+ - Universe files (`universes/`):
236
+ [CC0-1.0](https://github.com/Kentrow/fakeverse/blob/main/universes/LICENSE).
237
+
238
+ These licenses cover only the contributions of the Fakeverse project (data structure, patterns,
239
+ generated vocabulary and original content), not the names and trademarks of the original works.
240
+ See [NOTICE](https://github.com/Kentrow/fakeverse/blob/main/NOTICE). Rights holders can follow
241
+ the [takedown procedure](https://github.com/Kentrow/fakeverse/blob/main/TAKEDOWN.md).
242
+
243
+ ## Disclaimer
244
+
245
+ Fakeverse is an independent, non-commercial open source project. It is not affiliated with,
246
+ endorsed by, or sponsored by any rights holder of the works it draws inspiration from. All names,
247
+ characters, places and trademarks belong to their respective owners. Universe files contain only
248
+ short names and labels; no text, quotes or images from the original works.
249
+
250
+ ## Code of conduct
251
+
252
+ This project follows the
253
+ [Contributor Covenant 2.1](https://github.com/Kentrow/fakeverse/blob/main/CODE_OF_CONDUCT.md).
@@ -0,0 +1,215 @@
1
+ # Fakeverse
2
+
3
+ [![CI](https://github.com/Kentrow/fakeverse/actions/workflows/ci.yml/badge.svg)](https://github.com/Kentrow/fakeverse/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/fakeverse)](https://pypi.org/project/fakeverse/)
5
+ [![Python](https://img.shields.io/pypi/pyversions/fakeverse)](https://pypi.org/project/fakeverse/)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://github.com/Kentrow/fakeverse/blob/main/LICENSE)
7
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/Kentrow/fakeverse/badge)](https://scorecard.dev/viewer/?uri=github.com/Kentrow/fakeverse)
8
+
9
+ Fakeverse generates fake data themed by works of fiction. Think
10
+ [Faker](https://faker.readthedocs.io/), but the people, addresses and organizations come from
11
+ a fictional world, and they are **consistent with each other**: a hobbit lives in a town of
12
+ the Shire, the town is in the right region, and the email is built from the name.
13
+
14
+ For instance, `lotr.one("person", people="hobbit", seed=7)` gives:
15
+
16
+ ```json
17
+ {
18
+ "first_name": "Gilly",
19
+ "last_name": "Took",
20
+ "full_name": "Gilly Took",
21
+ "gender": "feminine",
22
+ "people": "Hobbit",
23
+ "address": {
24
+ "street_address": "7 Smithy Street",
25
+ "postal_code": "SH-594",
26
+ "locality": "Oatbarton",
27
+ "subdivision": "The Shire",
28
+ "area": "Eriador",
29
+ "formatted": "7 Smithy Street\nOatbarton SH-594\nThe Shire, Eriador"
30
+ },
31
+ "email": "gilly.took@post.example",
32
+ "username": "gilly972",
33
+ "phone": "+35 872 9950"
34
+ }
35
+ ```
36
+
37
+ - **Coherent**: generated values respect the relations between peoples, places and names.
38
+ - **Multilingual**: every universe is translated, following a reference translation, and
39
+ fallbacks to another language are reported.
40
+ - **Reproducible**: the same seed and the same data version always give the same result.
41
+ - **Easy to contribute**: one YAML file per universe, validated automatically.
42
+ - **Everywhere**: Python package, Faker provider, command line and HTTP API.
43
+
44
+ ## Universes
45
+
46
+ | Id | Universe | Scope | Locales |
47
+ | --- | --- | --- | --- |
48
+ | `lotr` | The Lord of the Rings | The books only, no film adaptations | English, French |
49
+ | `starwars` | Star Wars | The Disney canon (2014 and later) | English, French |
50
+
51
+ New universes are welcome: see [Contributing](#contributing).
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install fakeverse # package and command line
57
+ pip install "fakeverse[faker]" # with the Faker provider
58
+ pip install "fakeverse[api]" # with the HTTP API
59
+ ```
60
+
61
+ Fakeverse needs Python 3.12 or later.
62
+
63
+ ## Python package
64
+
65
+ ```python
66
+ from fakeverse import Fakeverse
67
+
68
+ fv = Fakeverse()
69
+ lotr = fv.universe("lotr")
70
+
71
+ result = lotr.generate("first_name", count=3, seed=42)
72
+ result.items # ['Andwise', 'Orodreth', 'Dáin']
73
+ result.meta.seed # 42
74
+
75
+ lotr.one("full_name", seed=1, gender="feminine") # 'Dís'
76
+ lotr.generate("person", count=5, people="hobbit") # five hobbits, no duplicates
77
+ lotr.generate("weapon", count=2, seed=3).items # a type specific to the universe
78
+ # [{'name': 'Glamdring', 'kind': 'Sword'}, {'name': 'Aeglos', 'kind': 'Spear'}]
79
+
80
+ fv.universe("lotr", locale="fr").generate("full_name", count=3, seed=42).items
81
+ # ['Flói', 'Hugo Goold', 'Fréaláf']
82
+ ```
83
+
84
+ Templates combine several types in one row. Leaves that reference the same instance describe
85
+ the same entity, and `colocate` puts instances in the same locality:
86
+
87
+ ```python
88
+ lotr.template(
89
+ {
90
+ "name": "person.full_name",
91
+ "employer": "organization.name",
92
+ "town": "person.address.locality",
93
+ },
94
+ count=2,
95
+ seed=7,
96
+ colocate=[["person", "organization"]],
97
+ ).items
98
+ # [{'name': 'Théodred', 'employer': 'The Wild Boar', 'town': 'Aldburg'},
99
+ # {'name': 'Náli', 'employer': 'The Old Mill', 'town': 'Erebor'}]
100
+ ```
101
+
102
+ Types: the composites `person`, `address` and `organization`, their projections
103
+ (`first_name`, `last_name`, `full_name`, `email`, `username`, `phone`, `street_address`,
104
+ `postal_code`, `locality`, `subdivision`, `area`, `organization_name`), and the types specific
105
+ to each universe. Options include `unique` (on by default, as far as the pool allows) and
106
+ `explain`, which tells for each value whether it comes from the works (`canon`) or was made
107
+ up (`generated`).
108
+
109
+ [How generation works](https://github.com/Kentrow/fakeverse/blob/main/docs/generation.md)
110
+ describes types, seeds, locales, uniqueness and templates in detail.
111
+
112
+ ## Faker provider
113
+
114
+ ```python
115
+ from faker import Faker
116
+ from fakeverse.faker import FakeverseProvider
117
+
118
+ fake = Faker("fr_FR")
119
+ fake.add_provider(FakeverseProvider)
120
+
121
+ fake.fakeverse("lotr").person()
122
+ fake.fakeverse("lotr").first_name(gender="feminine")
123
+ fake.fakeverse("lotr").generate("weapon")
124
+ fake.fakeverse("lotr").template({"name": "person.full_name"})
125
+ fake.fakeverse("lotr").unique.first_name() # never twice the same value
126
+ ```
127
+
128
+ `Faker.seed()` makes sequences reproducible. The locale of Faker is used when the universe
129
+ supports its language, and the default locale of the universe otherwise;
130
+ `fake.fakeverse("lotr", strict_locale=True)` raises an error instead.
131
+
132
+ ## Command line
133
+
134
+ ```bash
135
+ fakeverse generate lotr person -n 3 --seed 42 --locale fr
136
+ fakeverse generate lotr full_name -n 100 --format csv > names.csv
137
+ echo '{"name": "person.full_name", "employer": "organization.name"}' \
138
+ | fakeverse template lotr - -n 10 --format ndjson --colocate person,organization
139
+ fakeverse info
140
+ ```
141
+
142
+ `fakeverse --help` lists every command. Contributors also use `fakeverse validate`,
143
+ `fakeverse coverage` and `fakeverse check-coherence`.
144
+
145
+ ## HTTP API
146
+
147
+ ```bash
148
+ pip install "fakeverse[api]"
149
+ uvicorn fakeverse.api.app:app --no-access-log
150
+
151
+ curl "http://localhost:8000/v1/universes/lotr/generate/person?count=3&seed=42&locale=fr"
152
+ curl "http://localhost:8000/v1/universes/starwars/generate/starship?count=10&format=csv"
153
+ curl -X POST "http://localhost:8000/v1/universes/lotr/generate" \
154
+ -H "Content-Type: application/json" \
155
+ -d '{"template": {"name": "person.full_name", "town": "person.address.locality"}, "count": 10}'
156
+ ```
157
+
158
+ The API supports JSON, NDJSON and CSV, reports errors in the RFC 9457 format, applies rate
159
+ limiting, and sets HTTP cache headers on requests with a seed. The interactive documentation
160
+ is served at `/docs`. See the
161
+ [API reference](https://github.com/Kentrow/fakeverse/blob/main/docs/api.md) and the
162
+ [deployment guide](https://github.com/Kentrow/fakeverse/blob/main/docs/deployment.md), which
163
+ covers the Docker image.
164
+
165
+ ## Stability
166
+
167
+ Fakeverse is young: until 1.0.0, a minor release (0.2.0, 0.3.0...) may change the API, the
168
+ universe file format or the generated output, and the
169
+ [changelog](https://github.com/Kentrow/fakeverse/blob/main/CHANGELOG.md) always says so. A patch
170
+ release (0.1.1) never changes any output. Whatever the version, a given version of the package,
171
+ or a given `data_version` of the API, always gives the same output for the same request and
172
+ seed. Pin the version when you rely on generated values, in tests or fixtures.
173
+
174
+ ## Documentation
175
+
176
+ - [How generation works](https://github.com/Kentrow/fakeverse/blob/main/docs/generation.md):
177
+ types, seeds, locales, uniqueness, templates.
178
+ - [API reference](https://github.com/Kentrow/fakeverse/blob/main/docs/api.md) and
179
+ [API problems](https://github.com/Kentrow/fakeverse/blob/main/docs/problems.md).
180
+ - [Deployment guide](https://github.com/Kentrow/fakeverse/blob/main/docs/deployment.md).
181
+ - [Universe guide](https://github.com/Kentrow/fakeverse/blob/main/docs/universe-guide.md), to
182
+ write or extend a universe, and
183
+ [architecture](https://github.com/Kentrow/fakeverse/blob/main/docs/architecture.md), to change
184
+ the code.
185
+ - [Changelog](https://github.com/Kentrow/fakeverse/blob/main/CHANGELOG.md) and
186
+ [security policy](https://github.com/Kentrow/fakeverse/blob/main/SECURITY.md).
187
+
188
+ ## Contributing
189
+
190
+ New universes, names, translations and fixes are welcome. Read the
191
+ [contributing guide](https://github.com/Kentrow/fakeverse/blob/main/CONTRIBUTING.md) and the
192
+ [universe guide](https://github.com/Kentrow/fakeverse/blob/main/docs/universe-guide.md).
193
+
194
+ ## License
195
+
196
+ - Code: [MIT](https://github.com/Kentrow/fakeverse/blob/main/LICENSE).
197
+ - Universe files (`universes/`):
198
+ [CC0-1.0](https://github.com/Kentrow/fakeverse/blob/main/universes/LICENSE).
199
+
200
+ These licenses cover only the contributions of the Fakeverse project (data structure, patterns,
201
+ generated vocabulary and original content), not the names and trademarks of the original works.
202
+ See [NOTICE](https://github.com/Kentrow/fakeverse/blob/main/NOTICE). Rights holders can follow
203
+ the [takedown procedure](https://github.com/Kentrow/fakeverse/blob/main/TAKEDOWN.md).
204
+
205
+ ## Disclaimer
206
+
207
+ Fakeverse is an independent, non-commercial open source project. It is not affiliated with,
208
+ endorsed by, or sponsored by any rights holder of the works it draws inspiration from. All names,
209
+ characters, places and trademarks belong to their respective owners. Universe files contain only
210
+ short names and labels; no text, quotes or images from the original works.
211
+
212
+ ## Code of conduct
213
+
214
+ This project follows the
215
+ [Contributor Covenant 2.1](https://github.com/Kentrow/fakeverse/blob/main/CODE_OF_CONDUCT.md).