Skip to content

Commit 789e941

Browse files
Update DM XML generation script to use new path format (project-chip#37148)
* Update DM XML generation script to use new path format * Restyled by isort * Remove unused import --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 2d0f857 commit 789e941

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

scripts/spec_xml/generate_spec_xml.py

+4-15
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,18 @@
1919
import os
2020
import re
2121
import subprocess
22-
import sys
2322
import xml.etree.ElementTree as ElementTree
2423
from pathlib import Path
2524

2625
import click
27-
from paths import Branch, get_chip_root, get_data_model_path, get_documentation_file_path, get_in_progress_defines
26+
from chip.testing.spec_parsing import build_xml_clusters
27+
from paths import get_chip_root, get_documentation_file_path, get_in_progress_defines
2828

2929
# Use the get_in_progress_defines() function to fetch the in-progress defines
3030
CURRENT_IN_PROGRESS_DEFINES = get_in_progress_defines()
3131

3232
# Replace hardcoded paths with dynamic paths using paths.py functions
3333
DEFAULT_CHIP_ROOT = get_chip_root()
34-
DEFAULT_OUTPUT_DIR_1_4 = get_data_model_path(Branch.V1_4)
35-
DEFAULT_OUTPUT_DIR_IN_PROGRESS = get_data_model_path(Branch.IN_PROGRESS)
36-
DEFAULT_OUTPUT_DIR_TOT = get_data_model_path(Branch.MASTER)
3734
DEFAULT_DOCUMENTATION_FILE = get_documentation_file_path()
3835

3936

@@ -71,6 +68,7 @@ def make_asciidoc(target: str, include_in_progress: str, spec_dir: str, dry_run:
7168
help='Path to the spec root')
7269
@click.option(
7370
'--output-dir',
71+
required=True,
7472
help='Path to output xml files')
7573
@click.option(
7674
'--dry-run',
@@ -81,9 +79,6 @@ def make_asciidoc(target: str, include_in_progress: str, spec_dir: str, dry_run:
8179
'--include-in-progress',
8280
type=click.Choice(['All', 'None', 'Current']), default='All')
8381
def main(scraper, spec_root, output_dir, dry_run, include_in_progress):
84-
if not output_dir:
85-
output_dir_map = {'All': DEFAULT_OUTPUT_DIR_TOT, 'None': DEFAULT_OUTPUT_DIR_1_4, 'Current': DEFAULT_OUTPUT_DIR_IN_PROGRESS}
86-
output_dir = output_dir_map[include_in_progress]
8782
scrape_clusters(scraper, spec_root, output_dir, dry_run, include_in_progress)
8883
scrape_device_types(scraper, spec_root, output_dir, dry_run, include_in_progress)
8984
if not dry_run:
@@ -195,18 +190,12 @@ def dump_versions(scraper, spec_root, output_dir):
195190

196191

197192
def dump_cluster_ids(output_dir):
198-
python_testing_path = os.path.abspath(
199-
os.path.join(DEFAULT_CHIP_ROOT, 'src', 'python_testing'))
200-
sys.path.insert(0, python_testing_path)
201193
clusters_output_dir = os.path.abspath(
202194
os.path.join(output_dir, 'clusters'))
203-
204-
from spec_parsing_support import build_xml_clusters
205-
206195
header = '# List of currently defined spec clusters\n'
207196
header += 'This file was **AUTOMATICALLY** generated by `python scripts/generate_spec_xml.py`. DO NOT EDIT BY HAND!\n\n'
208197

209-
clusters, problems = build_xml_clusters(clusters_output_dir)
198+
clusters, problems = build_xml_clusters(Path(clusters_output_dir))
210199
all_name_lens = [len(c.name) for c in clusters.values()]
211200
name_len = max(all_name_lens)
212201
title_id_decimal = ' ID (Decimal) '

0 commit comments

Comments
 (0)