{ "info": { "author": "David Eyk", "author_email": "david.eyk@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Artistic Software", "Topic :: Games/Entertainment" ], "description": "=========\nBlueprint\n=========\n\nMagical blueprints for procedural generation of content. Based roughly\non a `series of articles`_ by Sean Howard. `Overview here`_.\n\n.. _series of articles: http://www.squidi.net/mapmaker/index.php\n.. _Overview here: http://www.squidi.net/mapmaker/musings/m100402.php\n\n- `Introduction`_\n- `Fields and Generators`_\n- `Tags`_\n- `Mods`_\n- `Factories`_\n- `TODO`_\n- `HELP`_\n- `Changelog`_\n\n\n============\nIntroduction\n============\n\nBlueprints are data objects. The essential idea is that you write\nsubclasses of ``blueprint.Blueprint`` with fields that define the\ngeneral parameters of their values (e.g. an integer between 0 and\n10). When you instantiate a blueprint, you get a \"mastered\" blueprint\nwith well-defined values for each field. Mastered blueprints may\ndefine special \"generator\" instance methods that build final objects\nfrom the master.\n\n**Think of it as prototypal inheritance for Python!** (Yeah, I\nprobably don't know what I'm talking about.)\n\nMost of the big moving parts have their documentation, often with\nexamples, in the docstring. Blueprint is best played with at the\ncommand line, trying out how things work. For the impatient, an\nexample::\n\n import blueprint\n\n\n class Item(blueprint.Blueprint):\n value = 1\n tags = 'foo bar'\n\n class Meta:\n abstract = True\n\n\n class Weapon(Item):\n name = 'Some Weapon'\n tags = 'dangerous equippable'\n damage = blueprint.RandomInt(1, 5)\n\n class Meta:\n abstract = True\n\n\n class Spear(Weapon):\n tags = 'primitive piercing'\n name = 'Worn Spear'\n damage = blueprint.RandomInt(10, 15)\n value = blueprint.RandomInt(4, 6)\n\n\n class PointedStick(Weapon):\n tags = 'primitive piercing'\n name = 'Pointed Stick'\n damage = 6\n value = 2\n\n\n class Club(Weapon):\n tags = 'primitive crushing'\n name = 'Big Club'\n damage = blueprint.RandomInt(10, 15)\n value = 2\n\n\n class Actor(blueprint.Blueprint):\n tags = 'active'\n\n\n class CaveMan(Actor):\n name = 'Cave Man'\n weapon = blueprint.PickOne(\n Club, Spear, PointedStick\n )\n\nAnd then:\n\n >>> actor = CaveMan()\n >>> actor\n \n >\n >>> actor.weapon.name\n 'Spear'\n\n\nNow, we can take our reified master data object and do something with\nit--use it as-is, or build another entity using the generated data.\n\n\n=====================\nFields and Generators\n=====================\n\nBlueprints are data objects. By default, every member of a blueprint\nis treated as a field, either static or dynamic. Static fields are\nsimple data attributes. Dynamic fields are callable objects that take\none positional argument, the blueprint on which they are being called.\n\nDynamic fields make blueprints quite useful. A few basic fields are\nprovided to get you started, and Blueprints themselves can be used as\nfields. Fields are designed to be nestable. They can rely upon each\nother too--use the ``blueprint.depends_on`` decorator to declare these\ndependencies.\n\nIf you really must have a callable method on your mastered blueprint,\nuse the ``blueprint.generator`` decorator (or mark your callable\nobject with the ``is_generator`` flag). These are called \"generators\"\n(\"contractors\" in squidi's terminology) because they're intended to be\nused to generate your final entity, whether it be a ``dict`` or a WAD\nfile.\n\n\n====\nTags\n====\n\nBlueprints automatically organize themselves using tags (domains in\nsquidi's parlance). A direct descendant of Blueprint has its own tag\nrepository (``blueprint.taggables.TagRepository``), which all its\nsubclasses will share. So, in the above example, you can query\n``Weapon.tag_repo.query(with_tags=('piercing'))`` and receive\n``set([Spear, PointedStick])``.\n\nBlueprints are also automatically tagged by their class name (and\ntheir ancestor superclass names!), with camel-cased words separated\nout. So ``CaveMan`` will automatically get the tags ``set(['cave', 'man',\n'actor'])``.\n\nThis makes the following possible::\n\n class MammothHunter(CaveMan):\n weapon = blueprint.PickFrom(\n blueprint.WithTags('pointed weapon')\n )\n\n\n====\nMods\n====\n\nSometimes, you'll want to dynamically modify a blueprint. To do this,\ncreate a subclass of ``Mod``. Mods are just special blueprints::\n\n class OfDoom(blueprint.Mod):\n name = blueprint.FormatTemplate('{meta.source.name} of DOOM')\n value = lambda _: _.meta.source.value * 5\n\n\nThen, apply it to another blueprint::\n\n >>> club = OfDoom(Club)\n >>> club.name\n 'Big Club of DOOM'\n\nMods always produce mastered blueprints.\n\n\n=========\nFactories\n=========\n\nFactories put all the pieces together--they're rather a blueprint\nfactory. Say that you want an item drop that selects from a few common\nWeapon blueprints and adds a couple magical Mods to make it\ncooler. Here's our second mod::\n\n class MagicalItemPrefix(blueprint.Mod):\n prefix = blueprint.PickOne(\n 'Gnarled',\n 'Inscribed',\n 'Magnificent',\n )\n name = blueprint.depends_on('prefix')(\n blueprint.FormatTemplate('{parent.prefix} {meta.source.name}'))\n\n\nNow, here's our Magical Item factory::\n\n class MagicalItemFactory(blueprint.Factory):\n product = blueprint.PickFrom(\n blueprint.WithTags('weapon'))\n mods = [MagicalItemPrefix, OfDoom]\n\n\nNow, when we call the factory, we get a random Weapon with magical properties::\n\n >>> weapon = MagicalItemFactory()\n >>> weapon.name\n 'Gnarled Worn Spear of DOOM'\n\nFactories always produce mastered blueprints.\n\n\n====\nTODO\n====\n\n- Better documentation. :\\)\n- Support all operators on ``blueprint.Field``\n\n\n====\nHELP\n====\n\nIf you run into trouble, or find a bug, file an issue in the `tracker\non github `_.\n\nOn github, bleeding-edge development work is done on the ``develop``\nbranch. ``master`` *should* always be stable.\n\nTests are written using the `behave`_ BDD framework, and may be found\nin the ``features/`` folder. To run the test suite, invoke ``behave``\nfrom the project root.\n\n.. _behave: http://packages.python.org/behave/\n\n\n===========\nDEVELOPMENT\n===========\n\nItching to hack on blueprint? Fork the repository on `on github`_ and\nsubmit a pull request. If you're not sure what you're doing, follow\n`these guidelines`_.\n\n.. _on github: http://github.com/eykd/blueprint/\n.. _these guidelines: https://gun.io/blog/how-to-github-fork-branch-and-pull-request/\n\nIf you're really high class, your code will be `PEP8`_ compliant, and\nwill pass the `pep8`_ static checker like so::\n\n pep8 --ignore=E221,E701,E202,E203,E225,E251,E5,W291,W293 mymodule.py\n\n.. _PEP8: http://www.python.org/dev/peps/pep-0008/\n.. _pep8: http://pypi.python.org/pypi/pep8/\n\n\n=========\nCHANGELOG\n=========\n\n- **0.6.1**: Fixed Python 3 compatibility in dice roller.\n\n- **0.6**: Experimental Python 3 compatibility, and bug-fixes:\n\n - **Feature:** Experimental Python 3 compatibility, thanks to `0ion9`_.\n\n - **Major bug fix:** Fixed bug in dice compilation.\n\n- **0.5**: A couple new features, some interfaces and many bug-fixes:\n\n - **Feature:** Added Property descriptor which acts like a field. May not actually be useful.\n\n - **Feature:** Dice rolls now return a results list, which auto-sums\n when doing integer or floating point arithmetic. No more mandatory\n ``sum()`` in your dice expressions.\n\n - **Major bug fix:** Fixed bug where Dice fields did not use the\n correct random object, with nondeterministic results.\n\n - **Bug fix/Interface change:** Improved (though not yet perfect)\n field resolution mechanics. Fields that depend on other, deferred\n fields now have a fighting chance at resolving.\n\n - **Bug fix/Interface change:** DiceTable no longer accepts `-` or\n arbitrary numbers of `.` or `:` as a range separator. Only `..` or\n `:` work now.\n\n - **Interface change:** Operators are now Fields in their own right,\n with all resulting rights and privileges.\n\n- **0.4**: Added a dice roller through ``blueprint.dice.roll``, and a\n corresponding ``Dice`` and ``DiceTable`` fields. Blueprint\n subclasses now have a better ``__repr__`` through the\n metaclass. **METACLASSES ROCK.**\n\n Modified the behavior of field resolution. All fields now use\n ``fields.resolve`` to consistently handle nested callables.\n\n- **0.3.4**: Learned how to read. Corrected Sean Howard's name in the\n intro copy. Three micro-releases in 1 hour!\n\n- **0.3.3**: Learned how to use distutils. :P (Fixed a unicode string\n in ``setup([packages=[...]])``.)\n\n- **0.3.2**: Added the LICENSE file to the source distribution, so pip\n won't fail.\n\n- **0.3.1**: Radically improved docstrings, with relevant\n examples. Added a changelog!\n\n- **0.3**: Added Factories. Bugfixes.\n\n- **0.2**: Added Mods. Bugfixes.\n\n- **0.1**: Initial release.\n\n\n.. _0ion9: https://github.com/0ion9", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/eykd/blueprint", "keywords": null, "license": "Copyright (c) 2012, David Eyk\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "maintainer": null, "maintainer_email": null, "name": "python-blueprint", "package_url": "https://pypi.org/project/python-blueprint/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-blueprint/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/eykd/blueprint" }, "release_url": "https://pypi.org/project/python-blueprint/0.6.1/", "requires_dist": null, "requires_python": null, "summary": "Magical blueprints for procedural generation of content.", "version": "0.6.1" }, "last_serial": 797865, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d8618a71ed0be30ae134c36bf9fb116f", "sha256": "31e8f42811deb6c1c4bce376f9e3d01f89200d7135ba78c018a395d77b42dc2a" }, "downloads": -1, "filename": "python-blueprint-0.1.tar.gz", "has_sig": false, "md5_digest": "d8618a71ed0be30ae134c36bf9fb116f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11434, "upload_time": "2012-02-14T08:31:30", "url": "https://files.pythonhosted.org/packages/c4/d7/269d1b045fdebff183b664b47aa932021ab4e48cf06709df7facc82df561/python-blueprint-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "d3495f5de9f94a1f3a31d66152b0e2a2", "sha256": "b666862144fbf02a7e4e0d349e1029c6feeddaef07fc57832f7eba2abc19c520" }, "downloads": -1, "filename": "python-blueprint-0.2.tar.gz", "has_sig": false, "md5_digest": "d3495f5de9f94a1f3a31d66152b0e2a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13384, "upload_time": "2012-02-17T08:38:48", "url": "https://files.pythonhosted.org/packages/47/4d/dab2b77b44d2a9f99f81000bb4aba9ed5f12d603c972d533d6dc1abd9971/python-blueprint-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "565761433e3827c76707a6532835ebbe", "sha256": "705d018a674761f79ce1da230cac9e8eee0751b2fb749b77081bb8086737297e" }, "downloads": -1, "filename": "python-blueprint-0.3.tar.gz", "has_sig": false, "md5_digest": "565761433e3827c76707a6532835ebbe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14382, "upload_time": "2012-02-18T08:20:11", "url": "https://files.pythonhosted.org/packages/c2/32/f234550b8f1fb282f4ae6fdab511e1baffcdc079ed45115e667cbd38a301/python-blueprint-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "e6432bfc448e1ee86432cebef3ee7ce2", "sha256": "60b2b7aa49ae4768cf26c9233b3f693ec6329129568cf786dd094aa7aa759a50" }, "downloads": -1, "filename": "python-blueprint-0.3.1.tar.gz", "has_sig": false, "md5_digest": "e6432bfc448e1ee86432cebef3ee7ce2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16184, "upload_time": "2012-02-19T07:54:15", "url": "https://files.pythonhosted.org/packages/f5/19/6ae1c8db3c01720e3eac7f3f634605b3e4e1dee9b92d867526d1fb3e5d14/python-blueprint-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "cab67fbd5fcfdab6a8bf1b17f433b920", "sha256": "59de198c4472a877f7524e9b2f6b4c32ea7d8704de063ae5801d58df2087be1b" }, "downloads": -1, "filename": "python-blueprint-0.3.2.tar.gz", "has_sig": false, "md5_digest": "cab67fbd5fcfdab6a8bf1b17f433b920", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16290, "upload_time": "2012-02-28T19:45:45", "url": "https://files.pythonhosted.org/packages/1b/67/0a3bf26435f6fdd79b48a634e741a05250207f992d6badb162a895181991/python-blueprint-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "a9c15e48680caae9701e949afc1f3f24", "sha256": "986125ab955e3a272d31c1b76e5de14a8eef0dcadadbeebe6dad90f6397172e3" }, "downloads": -1, "filename": "python-blueprint-0.3.3.tar.gz", "has_sig": false, "md5_digest": "a9c15e48680caae9701e949afc1f3f24", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16347, "upload_time": "2012-02-28T19:52:45", "url": "https://files.pythonhosted.org/packages/65/c7/9a4a22e2a3a46fc3a49d9b484573eff30df695dd41aabf613aa4861c499a/python-blueprint-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "acbc4c41e5efe6af5c21cafc8ce6407e", "sha256": "73579ccb00a5d23a493b395cba41b98e10c1622472ed610846b7ae05039be857" }, "downloads": -1, "filename": "python-blueprint-0.3.4.tar.gz", "has_sig": false, "md5_digest": "acbc4c41e5efe6af5c21cafc8ce6407e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16409, "upload_time": "2012-02-28T20:14:16", "url": "https://files.pythonhosted.org/packages/41/3c/3bfbfb046f2dda7e6503915c7338c610b9b904a32c0f0694c5e2d215185f/python-blueprint-0.3.4.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "dcc63546323a2c993e8b38e51496f147", "sha256": "73b298738330dc5c971dcbb0ef1a00fab8d2e97e461eeb18cab0bb4090b92764" }, "downloads": -1, "filename": "python-blueprint-0.4.tar.gz", "has_sig": false, "md5_digest": "dcc63546323a2c993e8b38e51496f147", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17825, "upload_time": "2012-03-05T06:08:30", "url": "https://files.pythonhosted.org/packages/65/0a/78f05c9ae7ab7e6f5e7c77e2182024c15967cb6246f285cb20d1fe96e5ad/python-blueprint-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "6daad246cdf7438fd3a47be9039c4cc1", "sha256": "03657a5fdf474bfb1d814a4f6eed62544db2ed9436a72538943fc252352edfa8" }, "downloads": -1, "filename": "python-blueprint-0.5.tar.gz", "has_sig": false, "md5_digest": "6daad246cdf7438fd3a47be9039c4cc1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18638, "upload_time": "2012-03-11T04:06:22", "url": "https://files.pythonhosted.org/packages/ac/5b/12a2c47db85c8bab319e3e5e813fb45e04b066a4762625b6accfa8c7f3a6/python-blueprint-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "e0ff8598067016ca5a8004d0910c50a8", "sha256": "b91b98ecf7ee9f573b0d4c0b531178f7ebbff5a426309599a39d7294ba0dbef8" }, "downloads": -1, "filename": "python-blueprint-0.6.tar.gz", "has_sig": false, "md5_digest": "e0ff8598067016ca5a8004d0910c50a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20712, "upload_time": "2013-01-13T14:51:17", "url": "https://files.pythonhosted.org/packages/ba/ce/16b16127c233435dc90bae790a582aba23f75d83dab19a6428b47282becd/python-blueprint-0.6.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "b7dd064a980a78767abc00de6d78345c", "sha256": "c7f8a14be17129459117d126c77ee63278bef4adfa661b42be7c4f2c71bc9358" }, "downloads": -1, "filename": "python-blueprint-0.6.1.tar.gz", "has_sig": false, "md5_digest": "b7dd064a980a78767abc00de6d78345c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20784, "upload_time": "2013-01-15T05:56:24", "url": "https://files.pythonhosted.org/packages/21/0e/75f4411f2f2d11a8b33613b6538fca31f29cf8cf5b0e43baefe30ac2c42f/python-blueprint-0.6.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b7dd064a980a78767abc00de6d78345c", "sha256": "c7f8a14be17129459117d126c77ee63278bef4adfa661b42be7c4f2c71bc9358" }, "downloads": -1, "filename": "python-blueprint-0.6.1.tar.gz", "has_sig": false, "md5_digest": "b7dd064a980a78767abc00de6d78345c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20784, "upload_time": "2013-01-15T05:56:24", "url": "https://files.pythonhosted.org/packages/21/0e/75f4411f2f2d11a8b33613b6538fca31f29cf8cf5b0e43baefe30ac2c42f/python-blueprint-0.6.1.tar.gz" } ] }