Skip to content

Commit

Permalink
Update DM XML generation script to use new path format (#37148)
Browse files Browse the repository at this point in the history
* Update DM XML generation script to use new path format

* Restyled by isort

* Remove unused import

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
cecille and restyled-commits authored Jan 22, 2025
1 parent 2d0f857 commit 789e941
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions scripts/spec_xml/generate_spec_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,18 @@
import os
import re
import subprocess
import sys
import xml.etree.ElementTree as ElementTree
from pathlib import Path

import click
from paths import Branch, get_chip_root, get_data_model_path, get_documentation_file_path, get_in_progress_defines
from chip.testing.spec_parsing import build_xml_clusters
from paths import get_chip_root, get_documentation_file_path, get_in_progress_defines

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

# Replace hardcoded paths with dynamic paths using paths.py functions
DEFAULT_CHIP_ROOT = get_chip_root()
DEFAULT_OUTPUT_DIR_1_4 = get_data_model_path(Branch.V1_4)
DEFAULT_OUTPUT_DIR_IN_PROGRESS = get_data_model_path(Branch.IN_PROGRESS)
DEFAULT_OUTPUT_DIR_TOT = get_data_model_path(Branch.MASTER)
DEFAULT_DOCUMENTATION_FILE = get_documentation_file_path()


Expand Down Expand Up @@ -71,6 +68,7 @@ def make_asciidoc(target: str, include_in_progress: str, spec_dir: str, dry_run:
help='Path to the spec root')
@click.option(
'--output-dir',
required=True,
help='Path to output xml files')
@click.option(
'--dry-run',
Expand All @@ -81,9 +79,6 @@ def make_asciidoc(target: str, include_in_progress: str, spec_dir: str, dry_run:
'--include-in-progress',
type=click.Choice(['All', 'None', 'Current']), default='All')
def main(scraper, spec_root, output_dir, dry_run, include_in_progress):
if not output_dir:
output_dir_map = {'All': DEFAULT_OUTPUT_DIR_TOT, 'None': DEFAULT_OUTPUT_DIR_1_4, 'Current': DEFAULT_OUTPUT_DIR_IN_PROGRESS}
output_dir = output_dir_map[include_in_progress]
scrape_clusters(scraper, spec_root, output_dir, dry_run, include_in_progress)
scrape_device_types(scraper, spec_root, output_dir, dry_run, include_in_progress)
if not dry_run:
Expand Down Expand Up @@ -195,18 +190,12 @@ def dump_versions(scraper, spec_root, output_dir):


def dump_cluster_ids(output_dir):
python_testing_path = os.path.abspath(
os.path.join(DEFAULT_CHIP_ROOT, 'src', 'python_testing'))
sys.path.insert(0, python_testing_path)
clusters_output_dir = os.path.abspath(
os.path.join(output_dir, 'clusters'))

from spec_parsing_support import build_xml_clusters

header = '# List of currently defined spec clusters\n'
header += 'This file was **AUTOMATICALLY** generated by `python scripts/generate_spec_xml.py`. DO NOT EDIT BY HAND!\n\n'

clusters, problems = build_xml_clusters(clusters_output_dir)
clusters, problems = build_xml_clusters(Path(clusters_output_dir))
all_name_lens = [len(c.name) for c in clusters.values()]
name_len = max(all_name_lens)
title_id_decimal = ' ID (Decimal) '
Expand Down

0 comments on commit 789e941

Please sign in to comment.