Skip to content

Instantly share code, notes, and snippets.

@larry-dalmeida
Created February 12, 2025 07:11
Show Gist options
  • Save larry-dalmeida/86954f47eb4a600d33ffc41afcd89a89 to your computer and use it in GitHub Desktop.
Save larry-dalmeida/86954f47eb4a600d33ffc41afcd89a89 to your computer and use it in GitHub Desktop.
dicts, file searching, yaml parsing

Unique Yaml Fields

Problem Statement

Given this folder that contains subfolders folders, each with one Chart.yaml file, find all the unique values of annotations.category field and return the count of each value.

Examples

find_unique_categories("./charts/bitnami")

The output should look like:

{ "Infrastructure": 23, "some_other_category": 44, .... }

Instructions

  1. Clone the https://github.com/bitnami/charts repository into the folder for your project and run your script to read from the charts/bitnami folder.
  2. You can use https://pyyaml.org/wiki/PyYAMLDocumentation to work with yaml files in python
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment