Path.with_name
Path.with_name(...)Description
Documentation for Path.with_name.
Real-World Examples
Practical code examples showing how Path.with_name is used in real projects.
Example 1
From GeorgeRCAdamJohnson/ColorLang_Energylang (energy_lang/knowledge_base/scrape_github_gitlab.py)
except Exception as e:
print(f"[GitLab] Project list API call failed: {e}")
return
for project in projects:
try:
print(f"[GitLab] Fetching full project object for {getattr(project, 'path_with_namespace', 'unknown')} (i...
full_project = gl.projects.get(project.id)
print(f"[GitLab] Attempting to fetch README.md for {full_project.path_with_namespace}...")
try:
readme_file = full_project.files.get(file_path='README.md', ref=full_project.default_branch)
import base64
readme_content = base64.b64decode(readme_file.content).decode('utf-8', errors='replace')
print(f"[GitLab] Got README.md for {full_project.path_with_namespace} (length: {len(readme_content)})")
benchmarks = extract_benchmarks_from_readme(readme_content)
print(f"[GitLab] Extracted {len(benchmarks)} benchmark(s) from README.md.")
for b in benchmarks:
insert_benchmark("GitLab", full_project.path_with_namespace, *b)
except Exception as e:
print(f"[GitLab] Could not fetch README.md for {full_project.path_with_namespace}: {e}")
except Exception as e:
print(f"[GitLab] Error in {getattr(project, 'path_with_namespace', 'unknown')} (id={project.id}): {e}")
print("[GitLab] Done.")
def main():
print("[Main] Starting GitHub scrape...")
Example 2
Example 1: Using with_name
# Basic usage of Path.with_name
from Path import with_name
# Simple example
result = with_name("example_input")
print(f"Result: {result}")