30 lines
788 B
Python
30 lines
788 B
Python
|
import re
|
||
|
|
||
|
re_newlines = re.compile( '[\r\n]+', re.UNICODE )
|
||
|
re_multiple_spaces = re.compile( '\\s+', re.UNICODE )
|
||
|
re_trailing_space = re.compile( '\\s+$', re.UNICODE )
|
||
|
re_leading_space = re.compile( '^\\s+', re.UNICODE )
|
||
|
re_leading_space_or_garbage = re.compile( '^(\\s|-|system:)+', re.UNICODE )
|
||
|
re_leading_single_colon = re.compile( '^:(?!:)', re.UNICODE )
|
||
|
|
||
|
def DeserialiseNewlinedTexts( text ):
|
||
|
|
||
|
text = text.replace( '\r', '' )
|
||
|
|
||
|
texts = text.split( '\n' )
|
||
|
|
||
|
texts = [ StripTrailingAndLeadingSpaces( line ) for line in texts ]
|
||
|
|
||
|
texts = [ line for line in texts if line != '' ]
|
||
|
|
||
|
return texts
|
||
|
|
||
|
def StripTrailingAndLeadingSpaces( t ):
|
||
|
|
||
|
t = re_trailing_space.sub( '', t )
|
||
|
|
||
|
t = re_leading_space.sub( '', t )
|
||
|
|
||
|
return t
|
||
|
|