Files
PraisonAI/examples/python/video/02_motion_graphics_git_tools.py
MervinPraison 3967dd164f feat(video): add motion graphics examples and tools
Introduced several Python scripts demonstrating motion graphics rendering
and GitTools safety features. Includes examples for basic rendering,
Git repository validation, and agent factories. These enhancements aim
to provide a comprehensive toolkit for creating and managing motion
graphics projects efficiently.
2026-04-19 01:09:50 +01:00

53 lines
1.7 KiB
Python

"""Motion Graphics — GitTools safety demo (no network required for this demo).
GitTools is the read-only toolkit used by the code-exploration specialist in
`motion_graphics_team`. It clones repos on demand, validates paths against
traversal, and restricts to GitHub URLs or `owner/repo` format.
This example exercises the pure-Python safety helpers (URL parsing + file
path validation). Cloning is network-bound and demonstrated separately.
Requirements:
pip install praisonai-tools
"""
from praisonai_tools.tools.git_tools import GitTools
def main() -> None:
tools = GitTools(base_dir="/tmp/praison_git_repos_demo")
print("URL parsing")
print("-----------")
for repo_input in [
"octocat/Hello-World", # owner/repo
"https://github.com/octocat/Hello-World.git", # https URL
"[email protected]:octocat/Hello-World.git", # ssh URL
]:
try:
url, name = tools._parse_repo_input(repo_input)
print(f" {repo_input:<50} -> name={name}")
except ValueError as exc:
print(f" {repo_input:<50} -> REJECTED: {exc}")
print("\nFile-path validation")
print("--------------------")
for path in [
"README.md", # safe
"src/main.py", # safe
"../etc/passwd", # traversal
"../../secret.txt", # traversal
"/etc/passwd", # absolute
]:
try:
safe = tools._validate_file_path(path)
print(f" {path:<30} -> SAFE: {safe}")
except ValueError as exc:
print(f" {path:<30} -> REJECT: {exc}")
print("\nListing any previously cloned repos:", tools.list_repos())
if __name__ == "__main__":
main()