Skip to content
Snippets Groups Projects
Commit e372e1ef authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Convert from dynamic (nodeMeta) to hard-coded (parDefs) parameter info

def user_edit_pair(fname_stem, th, tc):

    for i in range(10):
        ex = r'(\w+?)::\1(\([^\(\)]*?\)\s*?:\s*?)(I\w+)\(\s*?{"[^"]*?",\s*?("[^"]*?"),\s*?(({{.*?}}|{}))},\s*?(P|{})\)'
        m = re.search(ex, tc, flags=re.S)
        if m:
            cname = m.group(1)
            tooltip = m.group(4)
            arr = m.group(5)

            print(f"In source pair {fname_stem} amend class {cname}")

            tc = re.sub(ex, r'\1::\1\2\3(\7)', tc, count=1, flags=re.S)

            th = re.sub(r'(class ' + cname + r'.*?std::string className.*?"; }\n)',
                        r'\1'
                        +r'    // const auto tooltip = ' + tooltip + r';\n'
                        +r'    std::vector<ParaMeta> parDefs() const final { return'
                        +r'    ' + arr + '; }\n',
                        th,
                        flags=re.S)

    th = re.sub(r'\(const NodeMeta& meta,\s+((const )?std::vector<double>&? PValues)\)',
               r'(\1)', th, flags=re.S)
    tc = re.sub(r'\(const NodeMeta& meta,\s+((const )?std::vector<double>&? PValues)\)',
               r'(\1)', tc, flags=re.S)
    tc = re.sub(r'\(meta, (PValues)\)',
               r'(\1)', tc)

    return th, tc

et.ed_argfilepairs(user_edit_pair)
parent d5d8d127
No related branches found
No related tags found
1 merge request!591Convert from dynamic (nodeMeta) to hard-coded (parDefs) parameter info
Showing
with 66 additions and 92 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment