MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / unixlinesep

Function unixlinesep

src/commoncode/text.py:73–80  ·  view source on GitHub ↗

Normalize a string to Unix line separators. Preserve character offset by replacing with spaces if preserve is True.

(text, preserve=False)

Source from the content-addressed store, hash-verified

71
72
73def unixlinesep(text, preserve=False):
74 """
75 Normalize a string to Unix line separators. Preserve character offset by
76 replacing with spaces if preserve is True.
77 """
78 if not isinstance(text, str):
79 text = as_unicode(text)
80 return text.replace(CRLF, CRLF_NO_CR if preserve else LF).replace(CR, LF)
81
82
83def nolinesep(text):

Callers 1

prepare_text_lineFunction · 0.90

Calls 2

as_unicodeFunction · 0.70
replaceMethod · 0.45

Tested by

no test coverage detected