Open RubendeBruin opened 1 week ago
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')
Option 1 is a file-diff of two .dave files
Option 2 is a node-by-node property comparison