5.9. yapydata.datatree.synyaml

5.9.1. Module

The YapyData.xml module provides XML.

Sources: yapydata/datatree/synyaml.py

5.9.2. Functions

5.9.2.1. readout_data

yapydata.datatree.synyaml.readout_data(xval, **kargs)[source]

For API call-compliance with other syntaxes. Returns here the input tree only.

Parameters

xval – The input tree from the DataTreeYAML- which is the result from yaml.load().

Returns

The returns here the input xval.

Raises

pass-through

5.9.3. DataTreeYAML

class yapydata.datatree.synyaml.DataTreeYAML(data=None, **kargs)[source]

Provides YAML based read-only configuration of capabilities. This in particular comprises the priority based readout of values and defaults. The structure hereby includes specialization by subcomponents, where the missing value will be tried from the more general enclosing super component.

The access to structured data trees offers various method to access paths of nested node attributes. This comprises the creation as well as the readout.

The following equivalent creation methods are supported, where ‘treenode’ could be either the root node, or any subordinated branch:

treenode['subnode0']['subnode1']['subnode7'] = value  # dynamic items

value = treenode(
            'subnode0', 'subnode1', 'subnode7',
            create=True,
        )  # dynamic items by '__call__'

value = treenode.subnode0.subnode1.subnode7           # static attribute addressing style

The following equivalent readout methods are supported, where ‘treenode’ could be either the root node, or any subordinated branch:

value = treenode['subnode0']['subnode1']['subnode7']  # dynamic items
value = treenode('subnode0', 'subnode1', 'subnode7')  # dynamic items by '__call__'
value = treenode.subnode0.subnode1.subnode7           # static attribute addressing style

5.9.3.1. __init__

DataTreeYAML.__init__(data=None, **kargs)[source]
Parameters

data

A YAML compliant in-memory data tree:

yaml-value := (
      object | array
    | number
    | string
    | false  | true
    | null
)

The equivalent Python types are - based on JSON-RFC7159 as canonical in-memory data:

RFC-7159-type-for-json := (
      dict | list            # see: object, array
    | int  | float           # see: number
    | str                    # see: unicode / for Python: ISSTR = (str(3) | unicode(2))
    | None | True  | False   # see: null, true, false
)

The initial data defines the permitted type of the first item within the subpath of the spanned data tree.

Thus atomic data types define a single node data tree only - new in RFC-7159.

Returns

None / initialized object

Raises

5.9.3.2. __setattr__

DataTreeYAML.__setattr__(name, value)[source]

Validates types of own data attributes.

Parameters
  • name

    Name of the attribute. Following are reserved and treated special:

    • type: str - ‘data’ The value is treated as the replacement of the internal data attribute. Replaces or creates the complete data of teh current instance.

  • value – The value of the attribute. This by default superposes present values by replacement. Non-present are created.

Returns:

Raises

YapyDataDataTreeError

5.9.3.3. isvalid_top

static DataTreeYAML.isvalid_top(value, **kargs)[source]

NOP

5.9.3.4. import_data

DataTreeYAML.import_data(fpname, key=None, node=None, **kargs)[source]

Reads a YAML file. This is a simple basic method for the application on the lower layers of the software stack. It is designed for minimal dependencies. The used library is the PyYaml package.

Parameters
  • fpname

    File path name of the YAML file.

    fpname := <yaml-file-path-name>
    yaml-file-path-name := (
          <file-path-name>           # with extension
        | <file-path-name> '.yaml'   # without extension, for multiple syntaxes
    )
    

  • key

    The key for the insertion point:

    node[key] = <file-data>
    
    default := None - replace self.data,
    

    The caller is responsible for the containment of the provided node within the data structure represented by this object. No checks are performed.

  • node

    The node for the insertion of the read data.:

    default := <top>
    

Returns

Reference to read data structure.

Raises
  • YapyDataConfigError

  • pass-through

5.9.4. Exceptions

exception yapydata.datatree.synyaml.YapyDataYAMLError[source]

Generic YAML syntax error.