Path.read_text
Path.read_text(...)Description
Documentation for Path.read_text.
Real-World Examples
Practical code examples showing how Path.read_text is used in real projects.
def _load_poc_history() -> list[str]:
"""Load list of previously created PoCs."""
global _poc_topics
if POC_HISTORY_FILE.exists():
lines = POC_HISTORY_FILE.read_text().strip().split("\n")
# Also populate topics set from history
for line in lines:
if "|" in line:
title = line.split("|")[0].strip()
keywords = _normalize_topic(title)
if keywords:
_poc_topics.add(",".join(sorted(keywords)))
return lines
return []
def _save_poc_to_history(title: str, url: str) -> None:
"""Save a PoC to history."""
global _poc_topics
RESEARCH_DIR.mkdir(parents=True, exist_ok=True)
with open(POC_HISTORY_FILE, "a") as f:
f.write(f"{title} | {url}\n")
# Also add to in-memory topic tracking
@classmethod
def load(cls, path: Path) -> FetchState:
"""Load state from JSON file."""
if path.exists():
return cls.from_dict(json.loads(path.read_text()))
return cls()
class GitHubClient:
"""Client for GitHub REST API with Code Search."""
CODE_SEARCH_URL = "https://api.github.com/search/code"
REPOS_URL = "https://api.github.com/repos"
def __init__(self, token: str):
self.token = token
self.client = httpx.Client(
headers={
"Authorization": f"Bearer {token}",
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
timeout=30.0,
)