{ "info": { "author": "Daniel Mentiplay", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "Phantom config\n==============\n\n> [Phantom](https://bitbucket.org/danielprice/phantom) config files: parse, convert, modify, and generate.\n\nphantom-config can read Phantom `.in` and `.setup` files. (They have the same format.) You can, for example:\n\n- modify config values or comment strings,\n- add new variables or delete old ones,\n- write the config to a JSON or TOML file,\n- generate a config file from a dictionary.\n\n[![Build Status](https://travis-ci.org/dmentipl/phantom-config.svg?branch=master)](https://travis-ci.org/dmentipl/phantom-config)\n[![Coverage Status](https://coveralls.io/repos/github/dmentipl/phantom-config/badge.svg?branch=master)](https://coveralls.io/github/dmentipl/phantom-config?branch=master)\n[![PyPI](https://img.shields.io/pypi/v/phantomconfig)](https://pypi.org/project/phantomconfig/)\n\nInstallation\n------------\n\nInstall phantom-config with pip\n\n```bash\npip install phantomconfig\n```\n\nUsage\n-----\n\n### Basic usage\n\nImport phantom-config.\n\n```python\n>>> import phantomconfig\n```\n\nTo read in a Phantom config file\n\n```python\n>>> input_file = phantomconfig.read_config('prefix.in')\n```\n\nPrint a summary\n\n```python\n>>> input_file.summary()\n```\n\nThe variables, with their values, comment string, and the block they are a member of, are stored in a dictionary accessed by the `.config` method.\n\n```python\n>>> dtmax = input_file.config['dtmax']\n```\n\nThe keys of this dictionary correspond to the variable name, and values are a `ConfigVariable` named tuple with the variable name, value, comment, and block.\n\n```python\n>>> dtmax.name\n>>> dtmax.value\n>>> dtmax.comment\n>>> dtmax.block\n```\n\nYou can just get the value if you want.\n\n```python\ninput_file.get_value('dtmax')\n```\n\nIf you like, you can write the Phantom config as a JSON file, and you can read the JSON file.\n\n```python\n>>> input_file.write_json('prefix-in.json')\n>>> json_file = phantomconfig.read_json('prefix-in.json')\n```\n\nCheck that the configs are equal\n\n```python\n>>> input_file.config == json_file.config\n```\n\nYou can also read and write TOML files.\n\n```python\n>>> input_file.write_toml('prefix-in.toml')\n>>> toml_file = phantomconfig.read_toml('prefix-in.toml')\n```\n\nYou can add a new variable, remove a variable, and change the value of a variable.\n\n```python\n# Add new variable\n>>> input_file.add_variable(\n... 'new_var',\n... 12345678,\n... comment='Sets thing',\n... block='options controlling things',\n... )\n\n# Remove a variable\n>>> input_file.remove_variable('dtmax')\n\n# Change the value of a variable\n>>> input_file.change_value('dumpfile', 'new_dumpfile_name')\n```\n\nThen you can write the Phantom config file with the modified values.\n\n```python\n>>> input_file.write_phantom('new.in')\n```\n\nExamples\n--------\n\n### Generate a config from a dictionary\n\nYou can create a Phantom `.setup` file from a Python dictionary. First create the dictionary\n\n```python\n>>> setup = {}\n>>> setup['gas properties'] = {\n... 'cs': (cs, 'sound speed'),\n... 'npart': (npart, 'number of particles in x direction'),\n... 'rhozero': (rhozero, 'initial density'),\n... 'ilattice': (ilattice, 'lattice type'),\n... }\n```\n\nThen you can read the dictionary with `phantomconfig`, and write to a Phantom `.setup` file\n\n```python\n>>> setup_config = phantomconfig.read_dict(setup)\n>>> setup_config.header = [\n... 'input file for some particular setup routine',\n... 'short description of what it does']\n... ]\n>>> setup_config.write_phantom('filename.setup')\n```\n\nThis writes a file like\n\n```\n# input file for some particular setup routine\n# short description of what it does\n\n# gas properties\n cs = 1.000 ! sound speed\n npart = 9999 ! number of particles in x direction\n rhozero = 0.100 ! initial density\n ilattice = 2 ! lattice type\n```\n\n### Writing multiple configs\n\nSay you want to write multiple configs, each with a different parameter value. For example, you have a template `.in` file and you want to vary the alpha parameter. The following\n\n1. reads the template file\n2. loops over a list of `alpha` values, writing a new `.in` file for each value in the list\n\n```python\nalphas = [0.1, 0.2, 0.3]\ninfile = phantomconfig.read_config('template.in')\n\nfor alpha in alphas:\n infile.change_value('alpha', alpha)\n infile.write_phantom(f'alpha={alpha}.in')\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": "http://github.com/dmentipl/phantom-config", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "phantomconfig", "package_url": "https://pypi.org/project/phantomconfig/", "platform": "", "project_url": "https://pypi.org/project/phantomconfig/", "project_urls": { "Homepage": "http://github.com/dmentipl/phantom-config" }, "release_url": "https://pypi.org/project/phantomconfig/0.3.2/", "requires_dist": [ "tomlkit" ], "requires_python": ">=3.7", "summary": "Phantom config files: parse, convert, modify, and generate.", "version": "0.3.2" }, "last_serial": 5876565, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "726bc29a4a116d012706c46113f7cc5d", "sha256": "fea906388fcdd438d72ddce4fd0b10d17b8650993600b1dba42aaf874f5f2341" }, "downloads": -1, "filename": "phantomconfig-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "726bc29a4a116d012706c46113f7cc5d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7581, "upload_time": "2019-08-22T12:24:25", "url": "https://files.pythonhosted.org/packages/0b/ea/2f2743be15c01eb8a6699d921ca1050149c62fd78e21ccdc4bfbbc502043/phantomconfig-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ad991a4980923c93e447aa5d40b2eeba", "sha256": "8b9cd2976845fea7bccfccf9549b3284a54b0454f3beb3ebabc8fc4afc59abbf" }, "downloads": -1, "filename": "phantomconfig-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ad991a4980923c93e447aa5d40b2eeba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7174, "upload_time": "2019-08-22T12:24:28", "url": "https://files.pythonhosted.org/packages/ca/12/7ba461786634908bf7a3a352c4c8e9804568bf96df784119d097e0a6eb1f/phantomconfig-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "ad1b3eca33cc79ec5ce23c0b4e81b890", "sha256": "3105f0690aaecfb9d119a7d771eeea6c31caa166c9cb5ea7583dd4424bafb078" }, "downloads": -1, "filename": "phantomconfig-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ad1b3eca33cc79ec5ce23c0b4e81b890", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8289, "upload_time": "2019-08-26T00:17:22", "url": "https://files.pythonhosted.org/packages/16/37/4463219ee979a06470f24f106f39c5bf1737cbfccf7641c7ef35102d236f/phantomconfig-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "132fba582020e48dca478de757bf95df", "sha256": "581a8eca79eba4154791c71b8fadcb700bac0fdb1b0aa3aa558ccb117739ab37" }, "downloads": -1, "filename": "phantomconfig-0.2.0.tar.gz", "has_sig": false, "md5_digest": "132fba582020e48dca478de757bf95df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7857, "upload_time": "2019-08-26T00:17:24", "url": "https://files.pythonhosted.org/packages/1c/8f/7832ccd0c52fd60155da14d3fc418707485b45854051d6d3bba96ceac5cb/phantomconfig-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "9a785e2e4d42ad96040ed8f5f237fd4c", "sha256": "41b1aa8ed225337af56b79020d3de596a598d2c4cb23c16c87fe40cf0f70ed75" }, "downloads": -1, "filename": "phantomconfig-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "9a785e2e4d42ad96040ed8f5f237fd4c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8271, "upload_time": "2019-08-26T01:23:31", "url": "https://files.pythonhosted.org/packages/cf/56/6fe29cece6dfb6fde7956bba2d90e9ecd2ca89d0b9014f9ce693d680a834/phantomconfig-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dd1c677e99d2aa5ef05312097f3362d2", "sha256": "7222db790ea8c92d89a011d74697d7cf04b7319edd43111e9a5456e60b897efb" }, "downloads": -1, "filename": "phantomconfig-0.2.1.tar.gz", "has_sig": false, "md5_digest": "dd1c677e99d2aa5ef05312097f3362d2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7674, "upload_time": "2019-08-26T01:23:33", "url": "https://files.pythonhosted.org/packages/99/00/1e50bc75d4f81c60b308013e36269240a1a8427f88f390b302ec941ce11a/phantomconfig-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "079861f85bbc874a24793e08b678ff46", "sha256": "85a6c333e65c51831748c6f63ffc7ad5a692fd350d4d5eb84ba4cfb7324db5c5" }, "downloads": -1, "filename": "phantomconfig-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "079861f85bbc874a24793e08b678ff46", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8879, "upload_time": "2019-09-03T02:42:11", "url": "https://files.pythonhosted.org/packages/4f/58/1f196bba77b28ba2d8871eb17856d671396e29d4b80cf0ec75ba5da95439/phantomconfig-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3ee1ba61d3995e57e0601e25a989362a", "sha256": "1c35f3e655a401238d94eeb326b913adcdf160ebff349f78681233d9011ce4e3" }, "downloads": -1, "filename": "phantomconfig-0.3.0.tar.gz", "has_sig": false, "md5_digest": "3ee1ba61d3995e57e0601e25a989362a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9368, "upload_time": "2019-09-03T02:42:12", "url": "https://files.pythonhosted.org/packages/53/12/3f09dc9af8aa2628bbc643adc39ddfc57b7b1984c5bf8ef4e5f8f50df666/phantomconfig-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "907c606d5ec5638540f67f2ad84b7703", "sha256": "63b157d2a67c2b579f9dc7489f7624011c79b74333a80c5b4931b4970179c1a2" }, "downloads": -1, "filename": "phantomconfig-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "907c606d5ec5638540f67f2ad84b7703", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9504, "upload_time": "2019-09-11T01:03:06", "url": "https://files.pythonhosted.org/packages/29/fb/c82b6b5998c221c84b64a688cb8a0bf95a1cb29bee5168e862b66d3613ad/phantomconfig-0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "12dd309da72e7939c053e6913623b4e6", "sha256": "cc716293fed9b8effe5f26e4b161288f2df95cf716fa19cc32795ff8dc85f758" }, "downloads": -1, "filename": "phantomconfig-0.3.1.tar.gz", "has_sig": false, "md5_digest": "12dd309da72e7939c053e6913623b4e6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10435, "upload_time": "2019-09-11T01:03:08", "url": "https://files.pythonhosted.org/packages/80/7b/eb6eeeeace8453d3d8e5a8ee8d1d1a826e283e0da1ca32480189ec2ec612/phantomconfig-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "b13d6029389ab79d57dcf24d2fd22f2f", "sha256": "70038194a4f5666d1c0ec7bd4bf3a5831031303b04445bc92e6c2175fe0fd4e5" }, "downloads": -1, "filename": "phantomconfig-0.3.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b13d6029389ab79d57dcf24d2fd22f2f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 10761, "upload_time": "2019-09-23T23:17:50", "url": "https://files.pythonhosted.org/packages/33/fa/ee400ac9dc51007623ff6f167abefedcd12d53cea0ea56910704d0750092/phantomconfig-0.3.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b552431d4d5076df48c4555816c37eb7", "sha256": "ab788940f095ddbf218ab3cb642d89839abe73e3a80642985cde2c30e5e0153a" }, "downloads": -1, "filename": "phantomconfig-0.3.2.tar.gz", "has_sig": false, "md5_digest": "b552431d4d5076df48c4555816c37eb7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 11320, "upload_time": "2019-09-23T23:17:54", "url": "https://files.pythonhosted.org/packages/60/ad/480caf0b3d68dff342ab3b06ac8c617055eb16a3c9fcca8bd74f8be8a5a7/phantomconfig-0.3.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b13d6029389ab79d57dcf24d2fd22f2f", "sha256": "70038194a4f5666d1c0ec7bd4bf3a5831031303b04445bc92e6c2175fe0fd4e5" }, "downloads": -1, "filename": "phantomconfig-0.3.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b13d6029389ab79d57dcf24d2fd22f2f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 10761, "upload_time": "2019-09-23T23:17:50", "url": "https://files.pythonhosted.org/packages/33/fa/ee400ac9dc51007623ff6f167abefedcd12d53cea0ea56910704d0750092/phantomconfig-0.3.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b552431d4d5076df48c4555816c37eb7", "sha256": "ab788940f095ddbf218ab3cb642d89839abe73e3a80642985cde2c30e5e0153a" }, "downloads": -1, "filename": "phantomconfig-0.3.2.tar.gz", "has_sig": false, "md5_digest": "b552431d4d5076df48c4555816c37eb7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 11320, "upload_time": "2019-09-23T23:17:54", "url": "https://files.pythonhosted.org/packages/60/ad/480caf0b3d68dff342ab3b06ac8c617055eb16a3c9fcca8bd74f8be8a5a7/phantomconfig-0.3.2.tar.gz" } ] }