...

YAML KEYGEN

Github

YAML KEYGEN

A Python module for extracting keys from a YAML file. If a YAML contains a nested hierarchy then the complete path is listed from parent to child key.

Installation

Use the package manager pip to install yaml_keygen.

pip install yaml_keygen

The source code is currently hosted on GitHub at: https://github.com/fa1zali/yaml_keygen

Get Started

from yaml_keygen import YAML

 

# Initialize the YAML object
yk = YAML()

 

# Reads the YAML and return a dictionary object
yaml = yk.read(filename="<PATH>")

 

# Extracts the keys from dictionary object and stores them in a list
keys = yk.get_keys(data=yaml, sep='/')

 

# Saves the extracted keys to a text file
yk.to_text(data=keys, filename="<PATH>")