from pathlib import Path
def deploy_RT_Style_indirect_locators(locator_dir_path):
- locator_dir = Path(locator_dir_path)
- if not locator_dir.is_dir():
- print(f"Error: Locator directory not found at {locator_dir_path}")
- sys.exit(1)
-
- indirect_js = locator_dir / "indirect.js"
- if not indirect_js.exists():
- print("Error: indirect.js missing in the specified directory.")
- sys.exit(1)
-
- repo_home = Path(os.environ.get("REPO_HOME", "."))
- IGNORED_DIRS = {".git"}
-
- for root, dirs, files in os.walk(repo_home):
- # Prune ignored directories in place
- dirs[:] = [d for d in dirs if d not in IGNORED_DIRS]
-
- current_path = Path(root)
- if current_path.name.lower() == "document":
- target_file = current_path / "RT-Style_locator.js"
-
- # Eliminate permission denial on read-only artifacts
- if target_file.exists():
- target_file.chmod(target_file.stat().st_mode | stat.S_IWUSR)
-
- shutil.copyfile(indirect_js, target_file)
- print(f"Copied indirect.js -> {target_file}")
+ locator_dir = Path(locator_dir_path)
+ if not locator_dir.is_dir():
+ print(f"Error: Locator directory not found at {locator_dir_path}")
+ sys.exit(1)
-if __name__ == "__main__":
- if len(sys.argv) != 2:
- print("Usage: python3 deploy_RT_Style_indirect_locators.py <path_to_Locator_directory>")
- sys.exit(1)
-
- deploy_RT_Style_indirect_locators(sys.argv[1])
+ indirect_js = locator_dir / "indirect.js"
+ if not indirect_js.exists():
+ print("Error: indirect.js missing in the specified directory.")
+ sys.exit(1)
+
+ repo_home = Path(os.environ.get("REPO_HOME", "."))
+ IGNORED_DIRS = {".git"}
+ updated_dirs = set()
+
+ for root, dirs, files in os.walk(repo_home):
+ # Prune ignored directories in place
+ dirs[:] = [d for d in dirs if d not in IGNORED_DIRS]
+ current_path = Path(root)
+
+ # Skip if the directory has already received a locator during this run
+ if current_path in updated_dirs:
+ continue
+ needs_locator = False
+ for file_name in files:
+ if file_name.endswith(".html"):
+ file_path = current_path / file_name
+ try:
+ with open(file_path, "r", encoding="utf-8") as f:
+ for line in f:
+ if "RT-Style_locator.js" in line:
+ needs_locator = True
+ break
+ if "</head>" in line.lower():
+ break
+ if needs_locator:
+ break
+ except Exception as e:
+ print(f"Warning: Could not read {file_path}: {e}")
+
+ if needs_locator:
+ target_file = current_path / "RT-Style_locator.js"
+
+ # Eliminate permission denial on read-only artifacts
+ if target_file.exists():
+ target_file.chmod(target_file.stat().st_mode | stat.S_IWUSR)
+
+ shutil.copyfile(indirect_js, target_file)
+ print(f"Copied indirect.js -> {target_file}")
+
+ updated_dirs.add(current_path)
+
+if __name__ == "__main__":
+ if len(sys.argv) != 2:
+ print("Usage: python3 deploy_RT_Style_indirect_locators.py <path_to_Locator_directory>")
+ sys.exit(1)
+
+ deploy_RT_Style_indirect_locators(sys.argv[1])
#!/usr/bin/env python3
# -*- mode: python; coding: utf-8; python-indent-offset: 2; indent-tabs-mode: nil -*-
-import sys ,os ,filecmp ,stat
+import sys ,os ,filecmp ,stat ,subprocess
from pathlib import Path
def get_project_name(repo_path: Path) -> str:
return repo_path.resolve().name
+def get_git_branch(repo_path: Path) -> str:
+ try:
+ result = subprocess.run(
+ ["git" ,"-C" ,str(repo_path) ,"branch" ,"--show-current"],
+ capture_output=True ,text=True ,check=True
+ )
+ branch = result.stdout.strip()
+ return branch if branch else "unknown_branch"
+ except (subprocess.CalledProcessError ,FileNotFoundError):
+ return "unknown_branch"
+
def format_perms(mode: int) -> str:
# Extract the 9-character permission string (e.g., rwxr-xr-x), dropping the leading file type char
return stat.filemode(mode)[1:]
return 1
project_name = get_project_name(project_dir)
+ harmony_branch = get_git_branch(harmony_dir)
+ project_branch = get_git_branch(project_dir)
# Data structures for the output sections
opus_warnings = []
perms_only_changes.append(display_str)
# --- Output Generation ---
- print(f"\nSkeleton Audit: Harmony vs {project_name}")
+ print("Skeleton Audit:")
+ print(f" Harmony {harmony_branch}")
+ print(" vs")
+ print(f" {project_name} {project_branch}")
print("=" * 60)
print("\n1. 0pus File Audit")
if __name__ == "__main__":
sys.exit(CLI())
+