MCPcopy Index your code
hub / github.com/beetbox/beets / _normexpr

Function _normexpr

test/test_template.py:22–41  ·  view source on GitHub ↗

Normalize an Expression object's parts, collapsing multiple adjacent text blocks and removing empty text blocks. Generates a sequence of parts.

(expr)

Source from the content-addressed store, hash-verified

20
21
22def _normexpr(expr):
23 """Normalize an Expression object's parts, collapsing multiple
24 adjacent text blocks and removing empty text blocks. Generates a
25 sequence of parts.
26 """
27 textbuf = []
28 for part in expr.parts:
29 if isinstance(part, str):
30 textbuf.append(part)
31 else:
32 if textbuf:
33 text = "".join(textbuf)
34 if text:
35 yield text
36 textbuf = []
37 yield part
38 if textbuf:
39 text = "".join(textbuf)
40 if text:
41 yield text
42
43
44def _normparse(text):

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected