예제 #1
0
파일: lineutil.py 프로젝트: yuanbei/pyutil
def lineify_fileobjs(ifo, ofo, strip=False):
	from pyutil.strutil import pop_trailing_newlines, split_on_newlines
	for l in ifo:
		for sl in split_on_newlines(pop_trailing_newlines(l)):
			if strip:
				sl = sl.strip()
			ofo.write(pop_trailing_newlines(sl) + '\n')
예제 #2
0
 def test_split(self):
     _assert(
         strutil.split_on_newlines("x\r\ny") == [
             "x",
             "y",
         ], strutil.split_on_newlines("x\r\ny"))
     _assert(
         strutil.split_on_newlines("x\r\ny\r\n") == [
             "x",
             "y",
             '',
         ], strutil.split_on_newlines("x\r\ny\r\n"))
     _assert(
         strutil.split_on_newlines("x\n\ny\n\n") == [
             "x",
             '',
             "y",
             '',
             '',
         ], strutil.split_on_newlines("x\n\ny\n\n"))
예제 #3
0
 def test_split(self):
     _assert(strutil.split_on_newlines("x\r\ny") == ["x", "y",], strutil.split_on_newlines("x\r\ny"))
     _assert(strutil.split_on_newlines("x\r\ny\r\n") == ["x", "y", '',], strutil.split_on_newlines("x\r\ny\r\n"))
     _assert(strutil.split_on_newlines("x\n\ny\n\n") == ["x", '', "y", '', '',], strutil.split_on_newlines("x\n\ny\n\n"))