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 the latest published package from PyPI:
python -m pip install xymInstall 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 --helpExtract all YANG modules from a local source file into the current directory:
xym path/to/rfc-or-draft.txtWrite output to a specific directory:
xym --dstdir ./yang path/to/rfc-or-draft.txtExtract from a URL:
xym https://www.rfc-editor.org/rfc/rfc7223.txtUse strict extraction, requiring <CODE BEGINS> and <CODE ENDS> markers:
xym --strict True path/to/rfc-or-draft.txtOnly extract valid example modules in strict mode:
xym --strict True --strict-examples path/to/rfc-or-draft.txtParse only selected modules:
xym --parse-only-modules ietf-interfaces example-module path/to/rfc-or-draft.txtSkip selected modules:
xym --skip-modules example-module path/to/rfc-or-draft.txtCheck or add revisions in output filenames using pyang:
xym --force-revision-pyang path/to/rfc-or-draft.txtCheck or add revisions in output filenames using regular expressions:
xym --force-revision-regexp path/to/rfc-or-draft.txtParse an RFCXMLv3 source file:
xym --rfcxml path/to/rfc-or-draft.xmlExtract code snippets as well as YANG modules:
xym --extract-code-snippets --code-snippets-dir ./snippets path/to/rfc-or-draft.txtAdd source line references to extracted YANG modules:
xym --add-line-refs path/to/rfc-or-draft.txtThe --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.
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 hatchShow the version derived from Git tags:
hatch versionRun the test suite:
hatch run test:runThe 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 --versionBuild source and wheel distributions:
hatch buildBuild only the wheel:
hatch build -t wheelBuild artifacts are written to dist/.
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.
GitHub Actions are defined in .github/workflows/workflow.yaml.
Pull requests automatically run:
hatch run test:runThe workflow currently tests Python 3.10, 3.11, 3.12, and 3.13.
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.0To publish a release candidate wheel:
git tag v0.10.0rc1
git push origin v0.10.0rc1The 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.