Updated to be pure bash and remove references to the web pages.

This commit is contained in:
Scott Garrett committed 2026-09-01 17:40:24 -04:00
1 parent 589ebaff46
commit f56678833e
7 files changed
+133 -1719

No files matched your search

+4 -13
View File
@@ -2,8 +2,8 @@
# Regenerate manufacturers.tsv from the Matter/CHIP manufacturer ID map.
#
# The TSV has two columns, "<decimal vendor id>\t<name>", sorted by vendor id. It
# is consumed by matter-decode.sh and is mirrored by the embedded <map> in
# matter-qr-decoder.html. It is derived from upstream project-chip/connectedhomeip's
# is consumed by matter-decode.sh and is derived from upstream
# project-chip/connectedhomeip's
# manufacturers.xml -- refresh from there rather than hand-editing.
#
# https://raw.githubusercontent.com/project-chip/connectedhomeip/refs/heads/master/src/app/zap-templates/zcl/data-model/manufacturers.xml
@@ -19,11 +19,10 @@
# Override the source with a positional argument that is a URL or a local file:
#
# python3 gen-manufacturers.py <url-or-file>
# python3 gen-manufacturers.py matter-qr-decoder.html # offline: embedded block
# python3 gen-manufacturers.py -o out.tsv <source>
#
# The default network fetch uses curl (falling back to urllib if curl is
# missing); a .html source and a plain XML file need no network. Requires only
# missing); a local XML file needs no network. Requires only
# the Python 3 standard library.
import argparse
@@ -105,13 +104,6 @@ def read_source(source):
path = Path(source)
if not path.exists():
sys.exit(f"error: no such file: {path}")
if path.suffix.lower() == ".html":
html = path.read_text(encoding="utf-8")
m = re.search(r'<script\s+type="text/xml"[^>]*>(.*?)</script>',
html, re.DOTALL | re.IGNORECASE)
if not m:
sys.exit('error: no <script type="text/xml"> block in ' + str(path))
return m.group(1)
return path.read_text(encoding="utf-8")
@@ -129,8 +121,7 @@ def main():
ap.add_argument(
"source", nargs="?", default=UPSTREAM_RAW,
help="a URL or local file (default: pinned upstream manufacturers.xml). "
"A GitHub blob/ URL is auto-converted to its raw form; a .html path "
'uses its embedded <script type="text/xml"> block.')
"A GitHub blob/ URL is auto-converted to its raw form.")
ap.add_argument(
"-o", "--output", default=str(SCRIPT_DIR / "manufacturers.tsv"),
help="output path (default: manufacturers.tsv next to this script)")