str.rstrip

str.rstrip(...)

Description

Documentation for str.rstrip.

Python Python String Methods Official Docs

Real-World Examples

Practical code examples showing how str.rstrip is used in real projects.

# Extract GitHub URL from report
    github_match = re.search(r"https://github\.com/[^\s\)>\]]+", report)
    if not github_match:
        return False

    github_url = github_match.group(0).rstrip(".,;:")

    # Extract title from TL;DR line or first line
    title = "Unknown PoC"
    tldr_match = re.search(r"TL;DR:\s*(.+?)(?:\n|$)", report)
    if tldr_match:
        title = tldr_match.group(1).strip()[:100]
    else:
        # Fallback: use repo name from URL
        repo_match = re.search(r"github\.com/[^/]+/([^/\s]+)", github_url)
        if repo_match:
            title = repo_match.group(1)

    _save_poc_to_history(title, github_url)
    logger.info(f"Saved PoC to history: {title} | {github_url}")
    return True

def _get_poc_history_context() -> str:
    """Get context string of previous PoCs for prompts."""
"""
  try:
    # Parse the identifier
    if "github.com" in repo_identifier:
      # Extract owner/repo from URL
      parts = repo_identifier.rstrip("/").split("/")
      owner, repo = parts[-2], parts[-1]
    else:
      # Assume format is owner/repo
      owner, repo = repo_identifier.split("/")

    # Fetch repository data
    repo_url = f"{GITHUB_API_BASE}/repos/{owner}/{repo}"
    repo_response = requests.get(repo_url, headers=GITHUB_HEADERS)
    repo_response.raise_for_status()
    repo_data = repo_response.json()

    # Fetch languages
    languages_url = f"{GITHUB_API_BASE}/repos/{owner}/{repo}/languages"
    languages_response = requests.get(languages_url, headers=GITHUB_HEADERS)
    languages = languages_response.json() if languages_response.ok else {}

    # Fetch latest commit
    commits_url = f"{GITHUB_API_BASE}/repos/{owner}/{repo}/commits"
    commits_response = requests.get(commits_url, headers=GITHUB_HEADERS, params={"per_page": 1})