MCPcopy Create free account
hub / github.com/webpy/webpy / splitline

Function splitline

web/template.py:61–76  ·  view source on GitHub ↗

r""" Splits the given text at newline. >>> splitline('foo\nbar') ('foo\n', 'bar') >>> splitline('foo') ('foo', '') >>> splitline('') ('', '')

(text)

Source from the content-addressed store, hash-verified

59
60
61def splitline(text):
62 r"""
63 Splits the given text at newline.
64
65 >>> splitline('foo\nbar')
66 ('foo\n', 'bar')
67 >>> splitline('foo')
68 ('foo', '')
69 >>> splitline('')
70 ('', '')
71 """
72 index = text.find("\n") + 1
73 if index:
74 return text[:index], text[index:]
75 else:
76 return text, ""
77
78
79class Parser:

Callers 8

read_defwithMethod · 0.85
read_varMethod · 0.85
readlineMethod · 0.85
read_nodeMethod · 0.85
read_keywordMethod · 0.85
read_assignmentMethod · 0.85
read_indented_blockMethod · 0.85
read_block_sectionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected