.. image:: https://img.shields.io/pypi/v/node.ext.yaml.svg
:target: https://pypi.python.org/pypi/node.ext.yaml
:alt: Latest PyPI version
.. image:: https://img.shields.io/pypi/dm/node.ext.yaml.svg
:target: https://pypi.python.org/pypi/node.ext.yaml
:alt: Number of PyPI downloads
``node.ext.yaml`` provides a node implementation to yaml files.
For more information on nodes see `node <http://pypi.python.org/pypi/node>`_
package.
For more information on plumbing see
`plumber <http://pypi.python.org/pypi/plumber>`_ package.
Usage
-----
Create a yaml file:
.. code-block:: python
from node.ext.yaml import YamlFile
class MyYamlFile(YamlFile):
@property
def fs_path(self):
return '/path/to/file.yaml'
file = MyYamlFile()
file['child'] = 'Value'
# write file to disk
file()
Define factories for child nodes:
.. code-block:: python
from node.ext.yaml import YamlNode
class SpecificChild(YamlNode):
pass
class DefaultChild(YamlNode):
pass
class MyYamlFile(YamlFile):
factories = {
'child': SpecificChild,
'*': DefaultChild
}
Define a schema for node members:
.. code-block:: python
from node import schema
from node.behaviors import SchemaAsAttributes
from plumber import plumbing
@plumbing(SchemaAsAttributes)
class MyYamlFile(YamlFile):
schema = {
'int_member': schema.Int(),
'str_member': schema.Str()
}
file = MyYamlFile()
file.attr['int_member'] = 1
file.attr['str_member'] = u'String'
Schema members can be defined directly on class.
**Note**: Be careful not to override existing API members.
.. code-block:: python
from node.behaviors import SchemaProperties
@plumbing(SchemaProperties)
class MyYamlFile(YamlFile):
int_member = schema.Int()
str_member = schema.Str()
file = MyYamlFile()
file.int_member = 1
file.str_member = u'String'
Python Versions
===============
- Python 2.7, 3.3+
Contributors
============
- Robert Niederreiter
Changes
=======
0.3 (2022-12-21)
----------------
- ``node.ext.yaml.behaviors.YamlSequenceStorage`` implements now
``__contains__``, which compares the storage values directly. This is needed
to make containment checks work because yaml child nodes are not cached on
``__getitem__``.
[rnix]
- ``node.ext.yaml.behaviors.YamlMember`` provides now
``default_mapping_factory`` and ``default_sequence_factory`` settings.
[rnix]
- ``node.ext.yaml.behaviors.YamlMember`` inherits from
``node.behaviors.WildcardFactory`` now.
[rnix]
- Use ``node.behaviors.SequenceAdopt`` and ``node.behaviors.SequenceOrder``
behaviors on ``node.ext.yaml.YamlSequence``.
[rnix]
- Use ``node.behaviors.MappingOrder`` behavior in favor of
``node.behaviors.Order`` as introduced in
``node`` 1.2 on ``node.ext.yaml.YamlMapping`` and ``node.ext.yaml.YamlFile``.
[rnix]
0.2 (2022-10-06)
----------------
- Inherit ``YamlRootStorage`` from ``node.ext.fs.FSLocation``, which provides
``fs_path`` property. Note that ``fs_path`` is handled as list now.
[rnix]
- Inherit ``IYamlRoot`` from ``node.ext.fs.interfaces.IFile``.
[rnix]
- Package depends on ``node.ext.fs`` now.
[rnix]
- Replace deprecated use of ``Adopt`` by ``MappingAdopt``.
[rnix]
- ``node.ext.yaml.YamlNode`` and ``node.ext.yaml.YamlFile`` not provides a
default child factory any more.
[rnix]
0.1 (2021-11-22)
----------------
- Initial work
[rnix]
License
=======
Copyright (c) 2021-2022, Node Contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Raw data
{
"_id": null,
"home_page": "https://github.com/conestack/node.ext.yaml",
"name": "node.ext.yaml",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "node yaml",
"author": "Node Contributors",
"author_email": "dev@conestack.org",
"download_url": "https://files.pythonhosted.org/packages/1c/2f/7e2b685c771bf9b5830d5a24b68f2730bd5e55835958813a6bff792b68c7/node.ext.yaml-0.3.tar.gz",
"platform": null,
"description": ".. image:: https://img.shields.io/pypi/v/node.ext.yaml.svg\n :target: https://pypi.python.org/pypi/node.ext.yaml\n :alt: Latest PyPI version\n\n.. image:: https://img.shields.io/pypi/dm/node.ext.yaml.svg\n :target: https://pypi.python.org/pypi/node.ext.yaml\n :alt: Number of PyPI downloads\n\n``node.ext.yaml`` provides a node implementation to yaml files.\n\nFor more information on nodes see `node <http://pypi.python.org/pypi/node>`_\npackage.\n\nFor more information on plumbing see\n`plumber <http://pypi.python.org/pypi/plumber>`_ package.\n\n\nUsage\n-----\n\nCreate a yaml file:\n\n.. code-block:: python\n\n from node.ext.yaml import YamlFile\n\n class MyYamlFile(YamlFile):\n\n @property\n def fs_path(self):\n return '/path/to/file.yaml'\n\n file = MyYamlFile()\n file['child'] = 'Value'\n\n # write file to disk\n file()\n\nDefine factories for child nodes:\n\n.. code-block:: python\n\n from node.ext.yaml import YamlNode\n\n class SpecificChild(YamlNode):\n pass\n\n class DefaultChild(YamlNode):\n pass\n\n class MyYamlFile(YamlFile):\n factories = {\n 'child': SpecificChild,\n '*': DefaultChild\n }\n\nDefine a schema for node members:\n\n.. code-block:: python\n\n from node import schema\n from node.behaviors import SchemaAsAttributes\n from plumber import plumbing\n\n @plumbing(SchemaAsAttributes)\n class MyYamlFile(YamlFile):\n schema = {\n 'int_member': schema.Int(),\n 'str_member': schema.Str()\n }\n\n file = MyYamlFile()\n file.attr['int_member'] = 1\n file.attr['str_member'] = u'String'\n\nSchema members can be defined directly on class.\n\n**Note**: Be careful not to override existing API members.\n\n.. code-block:: python\n\n from node.behaviors import SchemaProperties\n\n @plumbing(SchemaProperties)\n class MyYamlFile(YamlFile):\n int_member = schema.Int()\n str_member = schema.Str()\n\n file = MyYamlFile()\n file.int_member = 1\n file.str_member = u'String'\n\n\nPython Versions\n===============\n\n- Python 2.7, 3.3+\n\n\nContributors\n============\n\n- Robert Niederreiter\n\n\nChanges\n=======\n\n0.3 (2022-12-21)\n----------------\n\n- ``node.ext.yaml.behaviors.YamlSequenceStorage`` implements now\n ``__contains__``, which compares the storage values directly. This is needed\n to make containment checks work because yaml child nodes are not cached on\n ``__getitem__``.\n [rnix]\n\n- ``node.ext.yaml.behaviors.YamlMember`` provides now\n ``default_mapping_factory`` and ``default_sequence_factory`` settings.\n [rnix]\n\n- ``node.ext.yaml.behaviors.YamlMember`` inherits from\n ``node.behaviors.WildcardFactory`` now.\n [rnix]\n\n- Use ``node.behaviors.SequenceAdopt`` and ``node.behaviors.SequenceOrder``\n behaviors on ``node.ext.yaml.YamlSequence``.\n [rnix]\n\n- Use ``node.behaviors.MappingOrder`` behavior in favor of\n ``node.behaviors.Order`` as introduced in\n ``node`` 1.2 on ``node.ext.yaml.YamlMapping`` and ``node.ext.yaml.YamlFile``.\n [rnix]\n\n\n0.2 (2022-10-06)\n----------------\n\n- Inherit ``YamlRootStorage`` from ``node.ext.fs.FSLocation``, which provides\n ``fs_path`` property. Note that ``fs_path`` is handled as list now.\n [rnix]\n\n- Inherit ``IYamlRoot`` from ``node.ext.fs.interfaces.IFile``.\n [rnix]\n\n- Package depends on ``node.ext.fs`` now.\n [rnix]\n\n- Replace deprecated use of ``Adopt`` by ``MappingAdopt``.\n [rnix]\n\n- ``node.ext.yaml.YamlNode`` and ``node.ext.yaml.YamlFile`` not provides a\n default child factory any more.\n [rnix]\n\n\n0.1 (2021-11-22)\n----------------\n\n- Initial work\n [rnix]\n\n\nLicense\n=======\n\nCopyright (c) 2021-2022, Node Contributors\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice, this\n list of conditions and the following disclaimer in the documentation and/or\n other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n",
"bugtrack_url": null,
"license": "Simplified BSD",
"summary": "Node tree implementation for yaml files",
"version": "0.3",
"split_keywords": [
"node",
"yaml"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "aa67ce650f57d959fcad75602e62aeb7",
"sha256": "8acfa285a2959bce9178d5cebfe3bbe285c019b23427a3f32a5b086b4c508a58"
},
"downloads": -1,
"filename": "node.ext.yaml-0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "aa67ce650f57d959fcad75602e62aeb7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10374,
"upload_time": "2022-12-21T07:34:51",
"upload_time_iso_8601": "2022-12-21T07:34:51.844826Z",
"url": "https://files.pythonhosted.org/packages/3e/c5/c2dac4573bbcb36fd6d32d1620d54cbf33078b479422ab49708c55c6aeac/node.ext.yaml-0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "d7629c8a9a9c832cac05ff1925a063d5",
"sha256": "3fc7b226f39b7096ad65bc91ad6f11da0c02540b2ef9529a699f0f4884b348bc"
},
"downloads": -1,
"filename": "node.ext.yaml-0.3.tar.gz",
"has_sig": false,
"md5_digest": "d7629c8a9a9c832cac05ff1925a063d5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10940,
"upload_time": "2022-12-21T07:34:53",
"upload_time_iso_8601": "2022-12-21T07:34:53.976250Z",
"url": "https://files.pythonhosted.org/packages/1c/2f/7e2b685c771bf9b5830d5a24b68f2730bd5e55835958813a6bff792b68c7/node.ext.yaml-0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-21 07:34:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "conestack",
"github_project": "node.ext.yaml",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "node.ext.yaml"
}