{ "info": { "author": "Vadim Fedorenko (Meiblorn)", "author_email": "meiblorn@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup" ], "description": "PyYAML-Tags\n===\nAdds to PyYAML custom tags support\n\n\nBranch | CI status\n---------|-------------------\nmaster | [![Build Status](https://travis-ci.org/meiblorn/pyyaml-tags.svg?branch=master)](https://travis-ci.org/meiblorn/pyyaml-tags)[![codecov](https://codecov.io/gh/meiblorn/pyyaml-tags/branch/master/graph/badge.svg)](https://codecov.io/gh/meiblorn/pyyaml-tags)\ndevelop | [![Build Status](https://travis-ci.org/meiblorn/pyyaml-tags.svg?branch=develop)](https://travis-ci.org/meiblorn/pyyaml-tags)[![codecov](https://codecov.io/gh/meiblorn/pyyaml-tags/branch/develop/graph/badge.svg)](https://codecov.io/gh/meiblorn/pyyaml-tags)\n\n## Getting Started\n\n**PyYAML-Tags** is a library for advanced YAML processing in Python. It's built on the mature and full-featured [**PyYAML**](https://pyyaml.org) library. \n\nIt comes with 6 predefined tags and allows you to write your own. Use only those tags that you need or connect all at once with a great and simple decorators and meta API.\n\n### Installing\n\n`pip install pyyaml-tags`\n\n### Usage\n\nThe most sweet part of the `readme.md` file :)\n\nLibrary offers 6 predefined tags: `include`, `env`, `random_int`, `randmom_float`, `random_str`, `time_now`.\n\n#### API\n\nBy default all the PyYAML tags are in the **`disabled`** state. \nIt means that they will not work after you install the library. \n\nTo use tags you need to require them first. \nJust run the following code anywhere in your program:\n```python\nfrom yaml_tags import tag_registry\n\ntag_registry.require() # enable all tags \n# or\ntag_registry.require(tags='__all__') # same as above\n# or\ntag_registry.require('include,env,random_int') # enable 'include', 'env' and 'random_int' tags\n# or\ntag_registry.require(tags=['include', 'env']) # enable 'include', 'env' tags\n# or\ntag_registry.require('include', 'env', 'time_now') # enable 'include', 'env' and 'time_now' tags\n\n```\n\nthen call yaml.load() in your program (_anywhere_):\n```python\nimport yaml\n\nwith open('data/a/b/c.yml') as fh:\n data = yaml.load(fh)\n\nprint(data)\n```\nand check \u2014 it works !\n\n#### Tags\n\n- ##### `include` tag\n\n `include` tag allows you to include one yaml files into another.\n\n ###### Sample:\n ```yaml\n humans:\n managers: <% include(path=\"path/to/managers.yaml\") %>\n accountants: <% include(path=\"path/to/**/accountant*.yaml\", recursive=True, encoding='ascii') %>\n aliens: <% include(aliens.txt)\n robots: \n - <% include(main-robot.yaml) %> \n - <% include(robots/robot*.yaml) %> \n ```\n\n ###### Signature\n Parameter | Required | Type | Default | Description\n ----------|----------|------|---------|--------------------------------------------\n path | yes | str | | Path to file. Supports **glob** syntax\n recursive | no | bool | False | If **glob** is used, defines is glob recursive or not\n encoding | no | str | utf-8 | Files encoding\n\n- ##### `env` tag\n\n `env` tag allows you to pass environment variables values into yaml files\n\n ###### Sample:\n ```yaml\n welcome: Hello, <% env('WORLD_VAR') %> !\n java_home: <% env('JAVA_HOME') %>\n ```\n\n ###### Signature\n Parameter | Required | Type | Default | Description\n ----------|----------|------|---------|--------------------------\n var | yes | str | | Environment variable name\n\n- ##### `random_int` tag\n\n `random_int` tag generates random **integer** values and passes them into yaml file\n\n ###### Sample:\n ```yaml\n rolls:\n - roll_1: <% random_int %> # feel free to omit brackets. It's ok\n - roll_2: And this is <% random_int() %> !! Am I lacky ? \n - roll_3: <% random_int(0, 10) %> \n - roll_4: <% random_int(-50) %> \n - final: Final one: <% random_int(-10, 10) %> \n ```\n\n ###### Signature\n Parameter | Required | Type | Default | Description\n ----------|----------|------|---------------|-------------\n a | no | int | 0 | Left bound\n b | no | int | `sys.maxsize` | Right bound\n\n- ##### `random_float` tag\n\n `random_float` tag generates random **float** values (between 0 and 1) and passes them into yaml file\n\n ###### Sample:\n ```yaml\n rolls:\n - roll_1: <% random_float %> # Feel free to omit brackets\n - roll_2: Is it PI? <% random_float() %> ?? Nope ...\n ```\n\n- ##### `random_str` tag\n\n `random_str` tag generates random **str** values of desired length and passes them into yaml file\n\n ###### Sample:\n ```yaml\n rolls:\n - roll_1: <% random_str %> # Feel free to omit brackets\n - roll_2: <% random_str(10) %>\n - roll_3: My value is <% random_str(5, True) %>\n - roll_5: And mine is <% random_str(20, False, True) %>\n - roll_6: <% random_str(uppercase=True) %>\n - roll_7: Hoho !!! <% random_str(10, lowercase=True) %> Haha !!!\n ```\n\n ###### Signature\n Parameter | Required | Type | Default | Description\n ----------|----------|-------|-----------|--------------------------\n length | no | int | 10 | String length\n uppercase | no | bool | False | Convert text to uppercase\n lowercase | no | bool | False | Convert text to lowercase\n\n- ##### `time_now` tag\n\n `time_now` tag gets current timestamp in a desired format and passes it into yaml file\n\n ###### Sample:\n ```yaml\n context:\n - timestamp: <% time_now %> # Feel free to omit brackets\n - datetime: <% time_now(False) %> \n - datetime_fmt: <% time_now(timestamp=False, fmt=\"%Y-%m-%d %H:%M:%S\") %> \n ```\n\n ###### Signature\n Parameter | Required | Type | Default | Description\n ----------|----------|-------|-------------------|----------------------------------\n timestamp | no | bool | True | Paste raw timestamp\n fmt | no | str | %Y-%m-%d %H:%M:%S | Format to use when timestamp=False\n\n\n\n#### Write your own tags\n\nTo write your own tag use one of the following Python templates:\n\n- Using `tag_registry`\n\n ```python\n from yaml_tags import BaseTag, tag_registry\n\n @tag_registry.register('my_own_tag') # you can set tag name here\n class MyOwnTag(BaseTag):\n # tag_name = 'my_own_tag' # or set it here as alternative\n\n def _from_yaml(self, _loader, _work_dir, _prefix, _suffix,\n param1=None, param2=None, param3=False, param4='utf-8',\n *args, **kwargs):\n\n if not param1:\n raise ValueError(\"Param1 is required\")\n\n # your computations here\n result = \"smth\"\n\n if some_condition(result): # it doesn't matter what condition is this\n return result # w/o prefix and suffix\n\n return _prefix + result + _suffix\n ```\n\n- Using `TagAutoRegister` meta class. `tag_name` attribute is mandatory here.\n\n ```python \n from six import with_metaclass\n from yaml_tags import BaseTag, TagAutoRegister\n\n class MyOwnTag(with_metaclass(TagAutoRegister(), BaseTag)):\n tag_name = 'my_own_tag' # tag name\n\n def _from_yaml(self, _loader, _work_dir, _prefix, _suffix,\n param1=None, param2=None, param3=False, param4='utf-8',\n *args, **kwargs):\n\n if not param1:\n raise ValueError(\"Param1 is required\")\n\n # your computations here\n result = \"smth\"\n\n if some_condition(result): # it doesn't matter what condition is this\n return result # w/o prefix and suffix\n\n return _prefix + result + _suffix\n ```\n\nThen just require your own tag somewhere:\n```python\nfrom yaml_tags import tag_registry\n\ntag_registry.require('my_own_tag')\n# or\ntag_registry.require(tags='__all__') # require all\n```\n\nAnd use it in your yaml files like this:\n```yaml\nmy_own_data: <% my_own_tag(param1=\"test\", param2=2, param3=True, param4='ascii') %>\n```\n\nThat's all !\n\n## Running the tests\n\nWe are using [Tox](https://tox.readthedocs.io/en/latest). It is a generic virtualenv management and test command line tool.\n\n### Unit tests\n\n\n- To run tests just type `tox` in the command shell. \n- To run tests for a specific Python version use the following commands:\n\t- For Python 2: `tox -e py2` (or `py27`)\n\t- For Python 3: `tox -e py3` (or `py34`, `py35`, `py36`, `py37`)\n\n\n### Coding style tests\n\nTo check your codestyle just run `tox -e pep8` in your command shell.\n\n### Coverage\n\nFor coverage use `tox -e codecov` command.\n\n\n## Built With\n\n* [PyYAML](https://pyyaml.org) - Full-featured YAML framework for the Python programming language.\n* [AST](https://docs.python.org/3/library/ast.html) - Helps Python applications to process trees of the Python abstract syntax grammar.\n* [Path.py](https://github.com/jaraco/path.py) - Path objects for the Python 2.x\n\n## Contributing\n\nYou are welcome to contribute ! Just submit your PR and become a part of PyYAML community!\n\nPlease read [contributing.md](contributing.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/meiblorn/pyyaml-tags/tags). \n\n## Authors\n\n* **Vadim Fedorenko** - [Meiblorn](https://github.com/meiblorn) -*Initial work*\n\nSee also the list of [authors](authors.md) who participated in this project.\n\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n## Acknowledgments\n\n* It's my first Python opensource project. Hah.\n**Vadim Fedorenko** - [Meiblorn](https://github.com/meiblorn) - *Initial work* \n- 1.0.0 \u2014 First release. Added `include`, `env`, `random_int`, `random_float`, \n `random_str` and `time_now` tags. \n\n- 1.0.1 - Added `readme.md` and `contributing.md` files. \n Changed `authors.md` and `changelog.md` files\n\n- 1.0.2 - Changed configuration for the Travis CI PyPI deployment \n\n- 1.0.3 - Changed Travis CI PyPI deployment destination Python version.\n Reconfigured 'deploy_on' condition.\n\n- 1.0.4 - Updated setup.py flow. Added coverage badges to readme.md file. \n Fixed tags link in the readme.md file. \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/meiblorn/pyyaml-tags", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pyyaml-tags", "package_url": "https://pypi.org/project/pyyaml-tags/", "platform": "", "project_url": "https://pypi.org/project/pyyaml-tags/", "project_urls": { "Homepage": "https://github.com/meiblorn/pyyaml-tags" }, "release_url": "https://pypi.org/project/pyyaml-tags/1.0.4/", "requires_dist": null, "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "summary": "PyYAML custom tags", "version": "1.0.4" }, "last_serial": 4316759, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "bcfab9e94800cc980e3051738a657b7b", "sha256": "c416fb3a5ce466c2dd582ea18cbbb28584ce7698f427b0d234bbea4f3b65d8b6" }, "downloads": -1, "filename": "pyyaml_tags-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bcfab9e94800cc980e3051738a657b7b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 8234, "upload_time": "2018-09-26T19:38:17", "url": "https://files.pythonhosted.org/packages/a4/ec/5ec0d3889c6a1ece8f92f6c9e3fb38123702c552eb4eb3dcfb66ba7b983d/pyyaml_tags-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "efa7cfb814a0ee9ee843e7c1500c6276", "sha256": "f3deb4d262cc822466923ece5e591324234d70075c7b1af60e4026ff9b98f952" }, "downloads": -1, "filename": "pyyaml-tags-1.0.0.tar.gz", "has_sig": false, "md5_digest": "efa7cfb814a0ee9ee843e7c1500c6276", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 11669, "upload_time": "2018-09-26T19:38:19", "url": "https://files.pythonhosted.org/packages/3a/50/2a24931edb76f22a1e914e57a1c7431a5ce59826ef24147a7f12426a2839/pyyaml-tags-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "39f3d5ef0a198ec3ac815a6d822d4133", "sha256": "a19151e86b947d408f7a239b8ba34ee210c7c5be3b3bbfd783d25e350bea3309" }, "downloads": -1, "filename": "pyyaml_tags-1.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "39f3d5ef0a198ec3ac815a6d822d4133", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 11426, "upload_time": "2018-09-26T22:28:56", "url": "https://files.pythonhosted.org/packages/93/d7/c4564f13def0d28b68f9bda3ad7d7a920f278afdc60b7a2d173521904908/pyyaml_tags-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "02785b393f8e40617c393369abc21ea0", "sha256": "92a3b809993609d420d56b6f802737b373b2e741d29cc75b2b8e86e037f6841e" }, "downloads": -1, "filename": "pyyaml-tags-1.0.1.tar.gz", "has_sig": false, "md5_digest": "02785b393f8e40617c393369abc21ea0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 20198, "upload_time": "2018-09-26T22:28:58", "url": "https://files.pythonhosted.org/packages/89/30/3abcda2deb0b8eb217fc85b4c20574fb0d16dc526df9d7f005725c923f1a/pyyaml-tags-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "b9f174fbfbea007a681906e685fc1e5a", "sha256": "ae581515a2b23fc441b29f6268f7a607310cb49c79ce7daf9e4735c55e679db4" }, "downloads": -1, "filename": "pyyaml-tags-1.0.2.tar.gz", "has_sig": false, "md5_digest": "b9f174fbfbea007a681906e685fc1e5a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 20901, "upload_time": "2018-09-26T22:56:39", "url": "https://files.pythonhosted.org/packages/87/f8/da45573f8f6764af8de9ff300ae755b90ca9433994e75d169bc153dbb1b0/pyyaml-tags-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "0750d7beca502a41c87d5705b1d6f596", "sha256": "55aafbbf858b0fedacbae653e1c9588d5007158fd6c6dcc35193cd397fc98f4d" }, "downloads": -1, "filename": "pyyaml_tags-1.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0750d7beca502a41c87d5705b1d6f596", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 11492, "upload_time": "2018-09-26T23:13:45", "url": "https://files.pythonhosted.org/packages/e8/f9/c0cc8c5cf69dbdea80640ca6b44c45fdb390dc0b6e18de1ba589a5865cad/pyyaml_tags-1.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1440416028ecbf7a510668cec12ac6c5", "sha256": "ac7836541b8439ecba140d76b53081fd8f0cf4e269f1993b701e1816b2c0101a" }, "downloads": -1, "filename": "pyyaml-tags-1.0.3.tar.gz", "has_sig": false, "md5_digest": "1440416028ecbf7a510668cec12ac6c5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 21014, "upload_time": "2018-09-26T23:13:46", "url": "https://files.pythonhosted.org/packages/dd/d4/013b4496f44dafc0ef429ddce8989735efbd9259e09101f2f645c6b5e181/pyyaml-tags-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "dd97496b8989437f7d2a351010c68395", "sha256": "c377408c0c6c4b8498b4fd0224c086a36d10e18f0685a66c872b47a2f8b69d79" }, "downloads": -1, "filename": "pyyaml_tags-1.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "dd97496b8989437f7d2a351010c68395", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 11589, "upload_time": "2018-09-27T16:07:56", "url": "https://files.pythonhosted.org/packages/39/ce/5264aa26038144a7f73adc04e14aba60b65778dca6c2114b817d52bd2530/pyyaml_tags-1.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f509369a44a97e0f6cd3510428016bc7", "sha256": "efa4657e91eca7b9a65da123eb805652d8fae90a48dd01c05d3f667d4ad20c9c" }, "downloads": -1, "filename": "pyyaml-tags-1.0.4.tar.gz", "has_sig": false, "md5_digest": "f509369a44a97e0f6cd3510428016bc7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 21559, "upload_time": "2018-09-27T16:07:57", "url": "https://files.pythonhosted.org/packages/01/f4/3c134ceef67957c1469f69e83077482f3310e62298caff8370df3f1beb29/pyyaml-tags-1.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dd97496b8989437f7d2a351010c68395", "sha256": "c377408c0c6c4b8498b4fd0224c086a36d10e18f0685a66c872b47a2f8b69d79" }, "downloads": -1, "filename": "pyyaml_tags-1.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "dd97496b8989437f7d2a351010c68395", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 11589, "upload_time": "2018-09-27T16:07:56", "url": "https://files.pythonhosted.org/packages/39/ce/5264aa26038144a7f73adc04e14aba60b65778dca6c2114b817d52bd2530/pyyaml_tags-1.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f509369a44a97e0f6cd3510428016bc7", "sha256": "efa4657e91eca7b9a65da123eb805652d8fae90a48dd01c05d3f667d4ad20c9c" }, "downloads": -1, "filename": "pyyaml-tags-1.0.4.tar.gz", "has_sig": false, "md5_digest": "f509369a44a97e0f6cd3510428016bc7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 21559, "upload_time": "2018-09-27T16:07:57", "url": "https://files.pythonhosted.org/packages/01/f4/3c134ceef67957c1469f69e83077482f3310e62298caff8370df3f1beb29/pyyaml-tags-1.0.4.tar.gz" } ] }