From f787804bc8ff77b1eec83df6c6240f811e29f226 Mon Sep 17 00:00:00 2001 From: N3ther Date: Tue, 27 Aug 2024 13:33:15 -0400 Subject: [PATCH] added docstring for escape_important() and unescape_important() --- comfy/sd1_clip.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/comfy/sd1_clip.py b/comfy/sd1_clip.py index a1856030..da57303b 100644 --- a/comfy/sd1_clip.py +++ b/comfy/sd1_clip.py @@ -351,11 +351,55 @@ def token_weights(string, current_weight): return out def escape_important(text): + """ + Replace parentheses marked via backslashes with escape characters + + Parameters + ---------- + text : string + The string to have its important parentheses replaced + + Returns + ------- + text : string + The input string, with important parentheses replaced + + Examples + -------- + >>> text = "\\(foo\\)(bar)" + "\0\2foo\0\1(bar)" + + See Also + -------- + unescape_important : Replace escape characters with parentheses + """ text = text.replace("\\)", "\0\1") text = text.replace("\\(", "\0\2") return text def unescape_important(text): + """ + Replaces escape characters made via escape_important with parentheses + + Parameters + ---------- + text : string + The string to have its escape characters replaced + + Returns + ------- + text : string + The input string, with escape characters replaced + + Examples + -------- + >>> text = "\0\2foo\0\1(bar)" + "(foo)(bar)" + + See Also + -------- + escape_important: makes strings with the escape characters this function uses + """ text = text.replace("\0\1", ")") text = text.replace("\0\2", "(") return text