{ "info": { "author": "Philip Hodder", "author_email": "philip.hodder@encodis.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Games/Entertainment :: Role-Playing" ], "description": "# Introduction\n\nLately it seems that cards have become a popular accessory in tabletop role playing games. These can be used to provide a physical representation of items, spells or other gaming elements. Most decks are produced using image editors like GIMP or Photoshop, which is fine if you have the time, the software and the skills to use it. \n\nGamecards tries to automate this process. It takes a CSV file where each row represents an item, spell or other gaming element and each field in the row represents a property or attribute of that item, and converts it into a number of HTML pages. Each page contains a table, and each cell of the table contains a representation of the item, rendered according to a template file.\n\nThe resulting HTML file can then be printed and cut up to produce the cards themselves.\n\n## Installation\n\n```\n$ pip install --upgrade gamecards\n```\n\n## Usage\n\nThe `gamecards` script simply takes four arguments (in this order): the CSV file containing the data, a template HTML file, a CSS specification (a file name, or comma separated list of file names) and the output HTML file name:\n\n```\n$ python -m gamecards cards.csv cards.tpl cards.css cards.html\n```\n\nOr use the console script:\n\n```\n$ gamecards cards.csv cards.tpl cards.css cards.html\n```\n\nThe default is for each 'page' of the file to contain 3 rows and 3 columns. This can be changed using the `--rows` and `--cols` arguments:\n\n```\n$ gamecards cards.csv cards.tpl cards.css cards.html --rows 2 --cols 4\n```\n\n## CSV file\n\nThe CSV file must start with a header line that names each of the fields. These will be used in the template file. If a field contains a comma it must be enclosed in quotes. For example:\n\n```\nID,Field1,Field2\n1,Some text,Some more text\n2,Second row,\"Text, with a comma\"\n```\n\n## Template file\n\nThis is an HTML fragment containing standard Python template strings. These template strings should match header fields in the CSV file, and are substituted into the template using the Python string Template functionality. For example, the following template file:\n\n```\n
\n
\n

${Field1}

\n
\n
\n```\n\nwill be repeated for each line of the CSV file, once per table cell in the output file (see below). The template file must use the syntax `${Field1}` to specify the field names and they must be exact (so case is important).\n\n## CSS styling\n\nThe styling for the output HTML can be controlled by including the names of CSS files. This becomes a standard \"stylesheet\" link in the output HTML's `` element. For example, in the usage example above the `cards.css` style argument will become:\n\n```\n\n```\n\nin the output file.\n\nThe final appearance of the cards depends entirely on how you arrange the template and the corresponding CSS! It is recommended that each card be contained in a `
` element as in the example template above. Styling for this element should specify the card size, probably in 'mm' which will depend on the page size that the HTML will be printed on and the number of rows and columns. Theoretically any HTML constructs can be used but be aware of any browser limitations of *flexbox* and *grid* that might occur *when printing* (they may not show up when previewing in a browser).\n\n## Output file\n\nThe output file conforms to the HTML5 specification and consists of a number of `` elements each containing 3 rows with 3 columns (or whatever was specified using the `--rows` and `--cols` arguments). The entire body of the output document (i.e. the (only) child of ``) is a `
` element with an ID of \"gamecards\". Each `
` element within this `
` has the 'page' class which is used to enforce pagination when printed - the following style is automatically included in the output file:\n\n```\n@media print {\n .page {\n page-break-after: always;\n }\n}\n```\n\nThis can be overridden by an included CSS file if required. It is generally assumed that all styling will be done within each cell, i.e. on the supplied template; the table structure simply provides a framework.\n\n## Development notes\n\n### Unit testing\n\nA small number of tests are included in the `test_gamecards.py` file and can be run using the [pytest](https://pypi.org/project/pytest/) application.\n\n### Packaging a distribution\n\nWhen ready for a release use the [bumpversion](https://pypi.org/project/bumpversion/) application to update the version number, e.g.\n\n```\n$ bumpversion major --tag\n```\n\nThis will update the source file and the setup configuration. Then build the distribution:\n\n```\n$ python setup.py bdist_wheel\n```\n\n### Testing installation\n\nTesting that the distribution installs correctly can be accomplished using Docker. Use the following command (which will download the \"python\" Docker image if necessary, so it might take a couple of minutes when first run):\n\n```\n$ docker run -it -v \"$PWD\":/mnt --entrypoint=bash python\n```\n\nThis will start the \"python\" Docker image and execute a command prompt. From here install the \"gamecards\" distribution from the local \"dist\" folder (mounted in the Docker image under \"/mnt\"):\n\n```\nroot@382a37174524:/# pip install gamecards --no-index --find-links /mnt/dist\"\nroot@382a37174524:/# gamecards -h\nroot@382a37174524:/# python\n>>> import gamecards\n>>> exit()\n```\n\n### Upload to TestPyPi\n\nUpload the distribution to the TestPyPi site:\n\n```\n$ twine upload --repository-url https://test.pypi.org/legacy/ dist/*\n```\n\nThen run the \"python\" Docker image and attempt to install from there:\n\n```\n$ docker run -it -v \"$PWD\":/mnt --entrypoint=bash python\nroot@382a37174524:/# pip install --index-url https://test.pypi.org/simple/ gamecards\nroot@382a37174524:/# gamecards -h\n```\n\n### Upload to PyPi\n\nUpload to the real package index as follows (or specify the latest distribution):\n\n```\n$ twine upload dist/*\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/encodis/gamecards", "keywords": "gamecards cards games playing", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "gamecards", "package_url": "https://pypi.org/project/gamecards/", "platform": "", "project_url": "https://pypi.org/project/gamecards/", "project_urls": { "Homepage": "https://github.com/encodis/gamecards" }, "release_url": "https://pypi.org/project/gamecards/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "Convert a CSV file into HTML pages of cards, for subsequent printing", "version": "1.0.0" }, "last_serial": 5323204, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "a3bbed6c296ef1ae5204107441bff037", "sha256": "724afb5a44e6bf669499fb6392f2e9484eaed4a33534e2237019ebf529cf5161" }, "downloads": -1, "filename": "gamecards-0.1.0.zip", "has_sig": false, "md5_digest": "a3bbed6c296ef1ae5204107441bff037", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4871, "upload_time": "2018-05-22T22:58:35", "url": "https://files.pythonhosted.org/packages/f6/2f/953dca7d47c3449ca3b562303d0513aa09bae7e4e8458e4457a39145b710/gamecards-0.1.0.zip" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "f88e93ace35c56fd11f02023c115310c", "sha256": "bdafda52cb9e397bb2bec6a9be4c27c6d9ea2626e8e68a6933e91d57d9562e1a" }, "downloads": -1, "filename": "gamecards-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "f88e93ace35c56fd11f02023c115310c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6011, "upload_time": "2019-05-27T17:26:49", "url": "https://files.pythonhosted.org/packages/44/ed/a42ff2dea923451897c3df6037414ba7e90ecf38c14c2fd53adbc0b16f55/gamecards-1.0.0-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f88e93ace35c56fd11f02023c115310c", "sha256": "bdafda52cb9e397bb2bec6a9be4c27c6d9ea2626e8e68a6933e91d57d9562e1a" }, "downloads": -1, "filename": "gamecards-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "f88e93ace35c56fd11f02023c115310c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6011, "upload_time": "2019-05-27T17:26:49", "url": "https://files.pythonhosted.org/packages/44/ed/a42ff2dea923451897c3df6037414ba7e90ecf38c14c2fd53adbc0b16f55/gamecards-1.0.0-py3-none-any.whl" } ] }