Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Transform YANG models into pydantic datastructures

License

NotificationsYou must be signed in to change notification settings

pydantify/pydantify

Repository files navigation

Aprototype CLI tool to transform YANG models into Pydantic datastructures that can be initialized with config values and serialized into RESTCONF payloads.

Check out the documentation https://pydantify.github.io/pydantify/

For users

Installation

Prerequisites:

  • Python 3.10
  • pip

Installing from PYPI:

pip install pydantify

Installing from local folder:

pip install.

Usage

Example:

pydantify-i./models_dir-o./output_dir-tinterfaces/ethernetmodel.yang

Transforms the/interfaces/ethernet node and its children (located inmodel.yang) into a Python script located in./output_dir. Imports of definitions found in./models_dir are included if relevant to the specified model and node.

Command syntax:

pydantify [-h] [-v] [-V] [-S] [-iINPUT_DIR] [-oOUTPUT_DIR] [-tTRIM_PATH]input_filepositionalarguments:input_fileTheYANGfilecontainingtheentrypointtothemodeltoevaluate.options:-h,--helpshowthishelpmessageandexit-v,--verboseEnablesdebugoutput-V,--include-verificationAddsvalidationcode,aswellastherelevantYANGfiles,totheoutputmodel.-S,--standaloneGeneratedoutputmodelhasnodependencyonPydantify.Allrequiredcodeiscopiedintotheoutputmodel.-iINPUT_DIR,--input-dirINPUT_DIR,--pathINPUT_DIRThedirectorythatcontainstheYANGinputmodel.Defaultstotheinputfile'sfolder.-oOUTPUT_DIR,--output-dirOUTPUT_DIRThedirectorythatshouldbeusedtostoretheoutputmodel.Defaultsto"$CWD/out".-fOUTPUT_FILE,--output-fileOUTPUT_FILEThenameoftheoutputfile.Defaultsto"out.py".-tTRIM_PATH,--trim-pathTRIM_PATHGetonlythespecifiedbranchofthewholetree.-j,--json-schemaOutputJSONschemainsteadofPydanticmodels.-d,--data-type {config,state}Limitoutputtoconfigorstateonly.Defaultisconfigandstatecombined.NOTE:AllunknownargumentswillbepassedtoPyangas-isandwithoutguarantees.

For developers

Requirements

Instructions

Note: instructions with the same indentation are alternatives to eachother.

  • Install
    • dependencies through pdm (pdm install in project root)
      • into the local__pypackages__ folder
    • project through pip (see guide for users)
  • Build
    • through pdm (pdm build)
      • into the localdist folder
        • to be published on pypi
          • through twine (twine upload dist/*)

Links relevant to project

Pydantic

Explanations

Yang models

Pyang


Thanks

  • Dejan Jovicic and Dominic Walther, who laid the foundations of pydantify

[8]ページ先頭

©2009-2025 Movatter.jp