MCPcopy Create free account
hub / github.com/dot-agent/nextpy / wrap

Function wrap

nextpy/utils/format.py:70–96  ·  view source on GitHub ↗

Wrap the given text in the given open and close characters. Args: text: The text to wrap. open: The open character. close: The close character. check_first: Whether to check if the text is already wrapped. num: The number of times to wrap the text. R

(
    text: str,
    open: str,
    close: str | None = None,
    check_first: bool = True,
    num: int = 1,
)

Source from the content-addressed store, hash-verified

68
69
70def wrap(
71 text: str,
72 open: str,
73 close: str | None = None,
74 check_first: bool = True,
75 num: int = 1,
76) -> str:
77 """Wrap the given text in the given open and close characters.
78
79 Args:
80 text: The text to wrap.
81 open: The open character.
82 close: The close character.
83 check_first: Whether to check if the text is already wrapped.
84 num: The number of times to wrap the text.
85
86 Returns:
87 The wrapped text.
88 """
89 close = get_close_char(open, close)
90
91 # If desired, check if the text is already wrapped in braces.
92 if check_first and is_wrapped(text=text, open=open, close=close):
93 return text
94
95 # Wrap the text in braces.
96 return f"{open * num}{text}{close * num}"
97
98
99def indent(text: str, indent_level: int = 2) -> str:

Callers 4

format_stringFunction · 0.85
format_condFunction · 0.85
format_propFunction · 0.85
format_eventFunction · 0.85

Calls 2

get_close_charFunction · 0.85
is_wrappedFunction · 0.85

Tested by

no test coverage detected