Update line_utils.py

This commit is contained in:
chrys87 2016-10-28 14:52:51 +02:00 committed by GitHub
parent 4ebd476c63
commit 3ec6697b58

View File

@ -40,8 +40,35 @@ def getNextLine(currX,currY, currText):
currLine = wrappedLines[y]
return x, y, currLine
#!/bin/python
def insertNewlines(string, every=64):
return b'\n'.join(string[i:i+every] for i in range(0, len(string), every))
return '\n'.join(string[i:i+every] for i in range(0, len(string), every))
def splitAtrrLines(string, every=64):
return list(string[i:i+every] for i in range(0, len(string), every))
old = b'das ist ein test'
new = b'das axd ein test'
text = 'das iet ein test'
text = insertNewlines(text,4)
alts = splitAtrrLines(old,4)
neus = splitAtrrLines(new,4)
def trackHighlights(old, new, text):
result = ''
text = text.split('\n')
if len(old) != len(new):
return result
if len(text) != len(new):
return result
for line in range(len(new)):
if old[line] != new[line]:
for column in range(len(new)):
if old[line][column] != new[line][column]:
result += text[line][column]
result += ' '
return result
print(trackHighlights(alts,neus,text))