fix upgrade from tree to list
Some checks are pending
Setup Native Action / native (3.12.7) (push) Waiting to run
Setup Native Action / docker (3.12.7) (push) Waiting to run

This commit is contained in:
KaySar12 2025-03-06 17:03:09 +07:00
parent fc8e4886f2
commit aad2ef863a
2 changed files with 7 additions and 5 deletions

@ -1 +1 @@
Subproject commit dc9809260e6e5b61dd2b3ec0eb65747df4bd656a
Subproject commit b8e46f87160050564165c7c10207a9164c2e9641

View File

@ -1,13 +1,14 @@
import re
def upgrade(file_manager):
files = [file for file in file_manager if file.path.suffix in ('.xml', '.js', '.py')]
if not files:
return
reg_tree_to_list_xml_mode = re.compile(r"""(<field[^>]* name=["'](view_mode|name|binding_view_types)["'][^>]*>([^<>]+,)?\s*)tree(\s*(,[^<>]+)?</field>)""")
reg_tree_to_list_tag = re.compile(r'\n([^:\n]|:(?!//))+([<,/])tree([ \n\r,>/])')
# Fixed pattern to properly handle attributes
reg_tree_to_list_tag = re.compile(r'<tree(\s+[^>]*)?>', re.DOTALL) # Capture attributes correctly
reg_tree_to_list_closing_tag = re.compile(r'</tree>')
reg_tree_to_list_xpath = re.compile(r"""(<xpath[^>]* expr=['"])([^<>]*/)?tree(/|[\['"])""")
reg_tree_to_list_ref = re.compile(r'tree_view_ref')
reg_tree_to_list_mode = re.compile(r"""(mode=['"][^'"]*)tree([^'"]*['"])""")
@ -21,7 +22,8 @@ def upgrade(file_manager):
content = file.content
content = content.replace(' tree view ', ' list view ')
content = reg_tree_to_list_xml_mode.sub(r'\1list\4', content)
content = reg_tree_to_list_tag.sub(r'\1list\2', content)
content = reg_tree_to_list_tag.sub(r'<list\1>', content) # Use captured attributes
content = reg_tree_to_list_closing_tag.sub(r'</list>', content)
content = reg_tree_to_list_xpath.sub(r'\1\2list\3', content)
content = reg_tree_to_list_ref.sub('list_view_ref', content)
content = reg_tree_to_list_mode.sub(r'\1list\2', content)
@ -32,4 +34,4 @@ def upgrade(file_manager):
content = reg_tree_to_list_env_ref.sub(r'\1list\2', content)
file.content = content
file_manager.print_progress(fileno, len(files))
file_manager.print_progress(fileno, len(files))