|
| 1 | +from pathlib import Path |
| 2 | +f1=Path('pinescript_downloads/Volume_Profile_correct_from_copy_clicpboard.pine') |
| 3 | +f2=Path('pinescript_downloads/8jW3AO3z/8jW3AO3z_Volume_Profile_-_Density_of_Density_DAFE.pine') |
| 4 | +if not f1.exists() or not f2.exists(): |
| 5 | + print('files missing') |
| 6 | + raise SystemExit(1) |
| 7 | + |
| 8 | +b1=f1.read_bytes() |
| 9 | +b2=f2.read_bytes() |
| 10 | +print('len1',len(b1),'len2',len(b2)) |
| 11 | +for i,(x,y) in enumerate(zip(b1,b2)): |
| 12 | + if x!=y: |
| 13 | + print('first diff at',i,'b1',hex(x),'b2',hex(y)) |
| 14 | + print('around bytes:',b1[max(0,i-20):i+20]) |
| 15 | + print('vs:',b2[max(0,i-20):i+20]) |
| 16 | + # show heuristic: try decode segments |
| 17 | + print('\nsegment1 repr:',b1[max(0,i-20):i+20]) |
| 18 | + try: |
| 19 | + print('segment1 decoded utf8:',b1[max(0,i-20):i+20].decode('utf-8')) |
| 20 | + except Exception as e: |
| 21 | + print('utf8 decode error',e) |
| 22 | + try: |
| 23 | + print('segment1 decoded latin1:',b1[max(0,i-20):i+20].decode('latin-1')) |
| 24 | + except Exception as e: |
| 25 | + print('latin1 decode error',e) |
| 26 | + try: |
| 27 | + print('segment2 decoded utf8:',b2[max(0,i-20):i+20].decode('utf-8')) |
| 28 | + except Exception as e: |
| 29 | + print('utf8 decode error for b2',e) |
| 30 | + try: |
| 31 | + print('segment2 decoded latin1:',b2[max(0,i-20):i+20].decode('latin-1')) |
| 32 | + except Exception as e: |
| 33 | + print('latin1 decode error for b2',e) |
| 34 | + break |
| 35 | +else: |
| 36 | + if len(b1)!=len(b2): |
| 37 | + print('no byte diffs in prefix but lengths differ') |
| 38 | + else: |
| 39 | + print('files identical') |
0 commit comments