MCPcopy Create free account
hub / github.com/Louisym/MiniCC / _normalize

Function _normalize

tutorials/06_system_prompt_builder.py:163–174  ·  view source on GitHub ↗

标准化内容:连续空行压成一行,去掉首尾空白

(content: str)

Source from the content-addressed store, hash-verified

161
162
163def _normalize(content: str) -> str:
164 """标准化内容:连续空行压成一行,去掉首尾空白"""
165 lines = content.splitlines()
166 result = []
167 last_blank = False
168 for line in lines:
169 is_blank = not line.strip()
170 if is_blank and last_blank:
171 continue
172 result.append(line)
173 last_blank = is_blank
174 return "\n".join(result).strip()
175
176
177def _truncate(content: str, max_chars: int) -> str:

Callers 1

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected