fix display_menu recursive schema gen (#4045)

This commit is contained in:
Guillermo Ruffino 2022-11-21 21:43:01 -03:00 committed by GitHub
parent f2b63d9c67
commit c1f696c32a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -283,6 +283,32 @@ def fix_script():
config_schema["is_list"] = True config_schema["is_list"] = True
def fix_menu():
# # Menu has a recursive schema which is not kept properly
schemas = output["display_menu_base"][S_SCHEMAS]
# 1. Move items to a new schema
schemas["MENU_TYPES"] = {
S_TYPE: S_SCHEMA,
S_SCHEMA: {
S_CONFIG_VARS: {
"items": schemas["DISPLAY_MENU_BASE_SCHEMA"][S_SCHEMA][S_CONFIG_VARS][
"items"
]
}
},
}
# 2. Remove items from the base schema
schemas["DISPLAY_MENU_BASE_SCHEMA"][S_SCHEMA][S_CONFIG_VARS].pop("items")
# 3. Add extends to this
schemas["DISPLAY_MENU_BASE_SCHEMA"][S_SCHEMA][S_EXTENDS].append(
"display_menu_base.MENU_TYPES"
)
# 4. Configure menu items inside as recursive
menu = schemas["MENU_TYPES"][S_SCHEMA][S_CONFIG_VARS]["items"]["types"]["menu"]
menu[S_CONFIG_VARS].pop("items")
menu[S_EXTENDS] = ["display_menu_base.MENU_TYPES"]
def get_logger_tags(): def get_logger_tags():
pattern = re.compile(r'^static const char \*const TAG = "(\w.*)";', re.MULTILINE) pattern = re.compile(r'^static const char \*const TAG = "(\w.*)";', re.MULTILINE)
# tags not in components dir # tags not in components dir
@ -565,6 +591,7 @@ def build_schema():
fix_script() fix_script()
add_logger_tags() add_logger_tags()
shrink() shrink()
fix_menu()
# aggregate components, so all component info is in same file, otherwise we have dallas.json, dallas.sensor.json, etc. # aggregate components, so all component info is in same file, otherwise we have dallas.json, dallas.sensor.json, etc.
data = {} data = {}