A tool to fetch and extract YANG modules from IETF RFCs and Drafts
Project description
xym
xym extracts YANG modules from IETF RFCs and drafts. The source can be a local
text/RFCXML file or a URL, and extracted modules are written as .yang files.
Install
Install the latest published package from PyPI:
python -m pip install xym
Install from a local checkout:
git clone https://github.com/xym-tool/xym.git
cd xym
python -m pip install .
After installation, verify the command is available:
xym --version
xym --help
Usage
Extract all YANG modules from a local source file into the current directory:
xym path/to/rfc-or-draft.txt
Write output to a specific directory:
xym --dstdir ./yang path/to/rfc-or-draft.txt
Extract from a URL:
xym https://www.rfc-editor.org/rfc/rfc7223.txt
Use strict extraction, requiring <CODE BEGINS> and <CODE ENDS> markers:
xym --strict True path/to/rfc-or-draft.txt
Only extract valid example modules in strict mode:
xym --strict True --strict-examples path/to/rfc-or-draft.txt
Parse only selected modules:
xym --parse-only-modules ietf-interfaces example-module path/to/rfc-or-draft.txt
Skip selected modules:
xym --skip-modules example-module path/to/rfc-or-draft.txt
Check or add revisions in output filenames using pyang:
xym --force-revision-pyang path/to/rfc-or-draft.txt
Check or add revisions in output filenames using regular expressions:
xym --force-revision-regexp path/to/rfc-or-draft.txt
Parse an RFCXMLv3 source file:
xym --rfcxml path/to/rfc-or-draft.xml
Extract code snippets as well as YANG modules:
xym --extract-code-snippets --code-snippets-dir ./snippets path/to/rfc-or-draft.txt
Add source line references to extracted YANG modules:
xym --add-line-refs path/to/rfc-or-draft.txt
Strict Mode
The --strict and --strict-examples options affect which modules are written:
- No strict options: all YANG modules found in the source are extracted.
--strict True: only YANG modules inside<CODE BEGINS>and<CODE ENDS>are extracted.--strict True --strict-examples: only example modules outside<CODE BEGINS>and<CODE ENDS>with names starting withexample-are extracted.
The tool prints warnings and errors for source issues that may need inspection. For example, it reports invalid example module placement, missing revisions, and module names that do not match output filenames.
If an output .yang file already exists, xym does not overwrite it.
Development
This project uses Hatch for packaging, test environments, wheel building, and
version generation. Project metadata lives in pyproject.toml.
Install Hatch:
python -m pip install hatch
Show the version derived from Git tags:
hatch version
Run the test suite:
hatch run test:run
The tests include URL-based cases that fetch RFC text from the network. If those tests fail with DNS or connection errors, rerun them with network access.
Run the installed console command inside Hatch's test environment:
hatch run test:xym --version
Build source and wheel distributions:
hatch build
Build only the wheel:
hatch build -t wheel
Build artifacts are written to dist/.
Versioning
Versions are derived from Git tags with hatch-vcs. Release tags must use one
of these formats:
v0.10.0
v0.10.0rc1
The v prefix is stripped from the package version. During build/install, Hatch
generates xym/_version.py; that file is ignored by Git and should not be
edited or committed.
Continuous Integration
GitHub Actions are defined in .github/workflows/workflow.yaml.
Pull requests automatically run:
hatch run test:run
The workflow currently tests Python 3.10, 3.11, 3.12, and 3.13.
Publishing
Publishing uses PyPI trusted publishing with GitHub Actions OIDC. No PyPI API token secret is required.
Configure a trusted publisher for the PyPI project xym with:
- Repository owner:
xym-tool - Repository name:
xym - Workflow name:
workflow.yaml - Environment name: leave blank unless the workflow is later changed to use one
To publish a release wheel:
git tag v0.10.0
git push origin v0.10.0
To publish a release candidate wheel:
git tag v0.10.0rc1
git push origin v0.10.0rc1
The publish job runs only for pushed tags matching:
^v[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]+)?$
The publish job depends on the test job. If tests fail, the wheel is not published.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xym-0.10.0-py3-none-any.whl.
File metadata
- Download URL: xym-0.10.0-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d34d2c68d76c918d5cfb47903d4561f7758ad7b719e25bb8c9ea0263c2ecef0d
|
|
| MD5 |
f632289f2ae221072992829874161418
|
|
| BLAKE2b-256 |
706fbde3f6a61a022a714630a2098c98ac85a4f82410b7d317325110477f0a4b
|
Provenance
The following attestation bundles were made for xym-0.10.0-py3-none-any.whl:
Publisher:
workflow.yaml on xym-tool/xym
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xym-0.10.0-py3-none-any.whl -
Subject digest:
d34d2c68d76c918d5cfb47903d4561f7758ad7b719e25bb8c9ea0263c2ecef0d - Sigstore transparency entry: 1625474278
- Sigstore integration time:
-
Permalink:
xym-tool/xym@f1f0f5d4fb68c9264f273e441df6c3036aad75b0 -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/xym-tool
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yaml@f1f0f5d4fb68c9264f273e441df6c3036aad75b0 -
Trigger Event:
push
-
Statement type: