Skip to content

Instantly share code, notes, and snippets.

@daveh71
daveh71 / validate_xml.py
Created October 3, 2025 07:14
validate_xml.py
#!/usr/bin/env python3
"""
validate_xml.py
- Auto-installs required Python packages (pyyaml, packaging) if missing.
- Auto-clones a shallow copy of microsoft/winget-pkgs into the same folder as this script
(folder name: 'winget-pkgs') unless --no-clone is specified or --repo-path is provided.
- If a repo exists, optionally updates it (git pull / fetch+reset fallback) unless --no-update.
- Builds an index of Winget package IDs -> versions by scanning manifests/*.yaml.
- Parses the provided XML, finds all <win .../> elements, compares declared Version to latest found,