Files
TashaSkyUp-EternalKernelPyt…/git.py
T
Tasha Upchurch b3510c8c36 aider: Refactored validate_git_repo_url function to accept keyword arguments instead of specific parameters, and updated the example usage accordingly.
# Context:
USER: the paramaters for the function come from the return statement of def `INPUT_TYPES` in this case however please just use kwargs
2023-07-07 02:23:26 -04:00

21 lines
724 B
Python

import giturlparse
class PublicGitRepo:
"""replaces the text in the given text string with a given other text at some key positions"""
CATEGORY = "text"
RETURN_TYPES = ("STRING",)
FUNCTION = "validate_git_repo_url"
def validate_git_repo_url(self, text: str, replacement, key1, **kwargs):
"""
>>> PublicGitRepo().validate_git_repo_url("hello world", "universe", "world", git_url="https://github.com/example/repo.git")
'hello universe'
"""
git_url = kwargs.get("git_url")
parsed_url = giturlparse.parse(git_url)
if not parsed_url.valid:
raise ValueError("Invalid Git repository URL")
return (text.replace(key1, replacement),)