Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model compare to track changes between revisions #191

Open
RubendeBruin opened this issue Sep 9, 2024 · 1 comment
Open

Model compare to track changes between revisions #191

RubendeBruin opened this issue Sep 9, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@RubendeBruin
Copy link
Owner

Option 1 is a file-diff of two .dave files

Option 2 is a node-by-node property comparison

@RubendeBruin
Copy link
Owner Author

Option 2: There are way more properties than actually needed. Also settable has double properties such as global and local position.

Option 1: Implementation using difflib:

from DAVE import *

s1 = Scene(r'C:\data\DAVE\public\DAVE\tests\files\basic_nodes.dave')
s2 = Scene(r'C:\data\DAVE\public\DAVE\tests\files\basic_nodes.dave')

s2['Point'].name = 'point2'
s1['Point'].position = (1,2,3)

code1= s1.give_python_code()
code2= s2.give_python_code()

def clean(lines):

    r = []
    for line in lines:
        if line.startswith('#'):
            continue
        if "solved(" in line:
            continue
        if 'return number' in line:
            continue

        r.append(line)
    return '\n'.join(r)


code1 = clean(code1.splitlines())
code2 = clean(code2.splitlines())

# use difflib to compare the two code strings
# and show the result in html
from difflib import HtmlDiff


diff = HtmlDiff().make_file(code1.splitlines(), code2.splitlines(), fromdesc='model1', todesc='model2')
diff = diff.replace('¶', '')

with open('scratch_85.html', 'w') as f:
    f.write(diff)

# open the html file in the browser
import webbrowser
webbrowser.open('scratch_85.html')

@RubendeBruin RubendeBruin added the enhancement New feature or request label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant