prthm11 commited on
Commit
24c2c28
·
verified ·
1 Parent(s): 9f685c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -2
app.py CHANGED
@@ -2244,6 +2244,44 @@ def similarity_matching(sprites_data: dict, project_folder: str, top_k: int = 1,
2244
  matched_image_path = paths_list[matched_idx]
2245
  matched_folder = os.path.dirname(matched_image_path)
2246
  matched_filename = os.path.basename(matched_image_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2247
 
2248
  # If it's a sprite (under SPRITE_DIR) -> copy sprite assets and read sprite.json
2249
  # if matched_folder.startswith(sprite_base_path) and matched_folder not in copied_sprite_folders:
@@ -2656,8 +2694,9 @@ def process_pdf():
2656
  "temp_pseudo_code":[],
2657
  }
2658
 
2659
- final_state_dict = app_graph.invoke(initial_state_dict,config={"recursion_limit": 200})
2660
- final_project_json = final_state_dict['project_json'] # Access as dict
 
2661
 
2662
  # Save the *final* filled project JSON, overwriting the skeleton
2663
  with open(project_output, "w") as f:
 
2244
  matched_image_path = paths_list[matched_idx]
2245
  matched_folder = os.path.dirname(matched_image_path)
2246
  matched_filename = os.path.basename(matched_image_path)
2247
+ try:
2248
+ # Normalize many forms so we can compare apples-to-apples
2249
+ mf_abs = os.path.normpath(os.path.abspath(matched_folder))
2250
+ mf_repr = repr(matched_folder)
2251
+ mf_abspath_repr = repr(mf_abs)
2252
+
2253
+ # backdrop / sprite base (may be pathlib.Path in prod)
2254
+ bb = os.path.normpath(os.path.abspath(str(backdrop_base_path)))
2255
+ sb = os.path.normpath(os.path.abspath(str(sprite_base_path)))
2256
+
2257
+ # quick membership tests
2258
+ starts_with_backdrop = matched_folder.startswith(backdrop_base_path) or mf_abs.startswith(bb)
2259
+ starts_with_sprite = matched_folder.startswith(sprite_base_path) or mf_abs.startswith(sb)
2260
+
2261
+ # cross-platform commonpath test
2262
+ try:
2263
+ common_with_backdrop = (os.path.commonpath([mf_abs, bb]) == bb)
2264
+ except Exception:
2265
+ common_with_backdrop = False
2266
+ try:
2267
+ common_with_sprite = (os.path.commonpath([mf_abs, sb]) == sb)
2268
+ except Exception:
2269
+ common_with_sprite = False
2270
+
2271
+ print("DEBUG matched_idx:", matched_idx)
2272
+ print("DEBUG matched_image_path:", matched_image_path)
2273
+ print("DEBUG matched_folder (raw):", mf_repr)
2274
+ print("DEBUG matched_folder (abs):", mf_abspath_repr)
2275
+ print("DEBUG backdrop_base_path (raw):", repr(backdrop_base_path))
2276
+ print("DEBUG backdrop_base_path (abs):", repr(bb))
2277
+ print("DEBUG sprite_base_path (raw):", repr(sprite_base_path))
2278
+ print("DEBUG sprite_base_path (abs):", repr(sb))
2279
+ print("DEBUG startswith_backdrop:", starts_with_backdrop, " startswith_sprite:", starts_with_sprite)
2280
+ print("DEBUG common_with_backdrop:", common_with_backdrop, " common_with_sprite:", common_with_sprite)
2281
+ # Show a short sample of the reference path for matched index
2282
+ print("DEBUG sample paths_list entry:", repr(paths_list[matched_idx])[:400])
2283
+ except Exception as _e:
2284
+ print("DEBUG diagnostics failed:", _e)
2285
 
2286
  # If it's a sprite (under SPRITE_DIR) -> copy sprite assets and read sprite.json
2287
  # if matched_folder.startswith(sprite_base_path) and matched_folder not in copied_sprite_folders:
 
2694
  "temp_pseudo_code":[],
2695
  }
2696
 
2697
+ # final_state_dict = app_graph.invoke(initial_state_dict,config={"recursion_limit": 200})
2698
+ # final_project_json = final_state_dict['project_json'] # Access as dict
2699
+ final_project_json = project_skeleton
2700
 
2701
  # Save the *final* filled project JSON, overwriting the skeleton
2702
  with open(project_output, "w") as f: