str.replace
str.replace(...)Description
Documentation for str.replace.
Real-World Examples
Practical code examples showing how str.replace is used in real projects.
Example 1
From gorse-io/gitrec (x.py)
@command.command()
@click.argument("full_name")
def get_repo(full_name):
item = gorse_client.get_item(full_name.replace('/', ':').lower())
print('GET', item)
@command.command()
@click.argument("full_name")
def delete_repo(full_name):
gorse_client.delete_item(full_name.replace('/', ':').lower())
print('DELETE', full_name)
def search_and_upsert(topic: Optional[str] = None, language: Optional[str] = None):
query = "stars:>100"
if topic is not None:
query += " topic:" + topic
if language is not None:
query += " language:" + language
print("SEARCH " + query)
repos = github_client.search_repositories(query)
for repo in repos:
content = data.get("content", "")
encoding = data.get("encoding", "")
if encoding == "base64" and content:
return base64.b64decode(content).decode(
"utf-8", errors="replace"
)
return content
else:
logger.warning(
f"Could not get README for {repo_full_name}: {response.status_code}"
)
return ""
except Exception:
logger.exception(f"Error getting README for {repo_full_name}")
return ""
def _get_recent_issues(
self, repo_full_name: str, limit: int = 5
) -> List[Dict[str, Any]]:
"""
Get recent issues for a repository.
Args: