Yet Another PYANG
An open source Python package that helps developers to translate YANG (RFC6020/RFC7950) data models to Python. YAPYANG mimics the functionality of YANG data structures, enforces types through annotations, and supports JSON/XML ser/des. YAPYANG is authored by Antonio Faria, governed as a benevolent dictatorship, and distributed under license
Quick Start
For convenience we've included a basic quick start below. Ensure that a supported version of Python and the latest version of YAPYANG is installed.
Start by choosing the YANG model to translate. We've simplified OpenConfig interfaces.
module openconfig-interfaces {
namespace "http://openconfig.net/yang/interfaces";
container interfaces {
list interface {
key "name";
leaf name {
type string;
}
}
}
}
For each YANG node (module, container, list, and leaf) in the YANG model translate it into Python with YAPYANG through subclasses of the provided node types.
from yapyang import *
class Name(LeafNode):
__identifier__ = "name"
value: str
class Interface(ListNode):
__identifier__ = "interface"
__key__ = "name"
name: Name
class Interfaces(ContainerNode):
__identifier__ = "interfaces"
interface: Interface
class OpenConfigInterfaces(ModuleNode):
__identifier__ = "openconfig-interfaces"
__namespace__ = "http://openconfig.net/yang/interfaces"
interfaces: Interfaces
Create instances of the translated YANG model nodes, add interface entries, and serialize to XML. Read the full docs.
module = OpenConfigInterfaces(Interfaces(Interface()))
module.interfaces.interface.append(Name("xe-0/0/0"))
print(module.to_xml())
...
<interfaces xmlns="http://openconfig.net/yang/interfaces"><interface><name>xe-0/0/0</name></interface></interfaces>
Versioning
Releases will follow semantic versioning (major.minor.patch). Before 1.0.0 breaking changes can be included in a minor release, therefore we highly recommend pinning this package.
Contributing
Suggest a feature or report a bug. Read our developer guide.
License
YAPYANG is distributed under the Apache 2.0 license.
Metadata
Release files for yapyang 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yapyang-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / yapyang-0.2.0-py3-none-any.whl
| Download URL | yapyang-0.2.0-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb57df5a57f0774dfb2a74aa43529272163eb15c8eea05eda3b0f25d22c8ae41
|
|
BLAKE2b-256 checksum How to use checksums |
69ab58de06782ef9de1f11624f734b72204c6a47596386e36ad5855367e3c0c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for yapyang 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.