Most of the pep8 changes finished. Be careful, things may be horribly broken.
This commit is contained in:
@ -7,12 +7,12 @@
|
||||
from fenrirscreenreader.core import debug
|
||||
|
||||
|
||||
def getTextBetweenMarks(firstMark, secondMark, inText):
|
||||
if inText is None:
|
||||
def get_text_between_marks(firstMark, secondMark, in_text):
|
||||
if in_text is None:
|
||||
return ''
|
||||
if not isinstance(inText, list):
|
||||
inText = inText.split('\n')
|
||||
if len(inText) < 1:
|
||||
if not isinstance(in_text, list):
|
||||
in_text = in_text.split('\n')
|
||||
if len(in_text) < 1:
|
||||
return ''
|
||||
if firstMark is None:
|
||||
return ''
|
||||
@ -20,48 +20,48 @@ def getTextBetweenMarks(firstMark, secondMark, inText):
|
||||
return ''
|
||||
if (firstMark['y'] + 1) * (firstMark['x'] +
|
||||
1) <= (secondMark['y'] + 1) * (secondMark['x'] + 1):
|
||||
startMark = firstMark.copy()
|
||||
endMark = secondMark.copy()
|
||||
start_mark = firstMark.copy()
|
||||
end_mark = secondMark.copy()
|
||||
else:
|
||||
endMark = firstMark.copy()
|
||||
startMark = secondMark.copy()
|
||||
textPart = ''
|
||||
if startMark['y'] == endMark['y']:
|
||||
textPart += inText[startMark['y']][startMark['x']:endMark['x'] + 1]
|
||||
end_mark = firstMark.copy()
|
||||
start_mark = secondMark.copy()
|
||||
text_part = ''
|
||||
if start_mark['y'] == end_mark['y']:
|
||||
text_part += in_text[start_mark['y']][start_mark['x']:end_mark['x'] + 1]
|
||||
else:
|
||||
currY = startMark['y']
|
||||
while currY <= endMark['y']:
|
||||
if currY < endMark['y']:
|
||||
if currY == startMark['y']:
|
||||
textPart += inText[currY][startMark['x']:]
|
||||
curr_y = start_mark['y']
|
||||
while curr_y <= end_mark['y']:
|
||||
if curr_y < end_mark['y']:
|
||||
if curr_y == start_mark['y']:
|
||||
text_part += in_text[curr_y][start_mark['x']:]
|
||||
else:
|
||||
textPart += inText[currY]
|
||||
if len(inText[currY].strip()) != 0:
|
||||
if len(textPart) - len(textPart.rstrip()) > 0:
|
||||
textPart = textPart[:len(textPart.rstrip())] + "\n"
|
||||
text_part += in_text[curr_y]
|
||||
if len(in_text[curr_y].strip()) != 0:
|
||||
if len(text_part) - len(text_part.rstrip()) > 0:
|
||||
text_part = text_part[:len(text_part.rstrip())] + "\n"
|
||||
else:
|
||||
textPart += '\n'
|
||||
text_part += '\n'
|
||||
else:
|
||||
textPart += inText[currY][:endMark['x'] + 1]
|
||||
currY += 1
|
||||
return textPart
|
||||
text_part += in_text[curr_y][:end_mark['x'] + 1]
|
||||
curr_y += 1
|
||||
return text_part
|
||||
|
||||
|
||||
def getTextBeforeMark(mark, inText):
|
||||
if inText is None:
|
||||
def get_text_before_mark(mark, in_text):
|
||||
if in_text is None:
|
||||
return ''
|
||||
if mark is None:
|
||||
return ''
|
||||
return getTextBetweenMarks({'x': 0, 'y': 0}, mark, inText)
|
||||
return get_text_between_marks({'x': 0, 'y': 0}, mark, in_text)
|
||||
|
||||
|
||||
def getTextAfterMark(mark, inText):
|
||||
if inText is None:
|
||||
def get_text_after_mark(mark, in_text):
|
||||
if in_text is None:
|
||||
return ''
|
||||
if mark is None:
|
||||
return ''
|
||||
inText = inText.split('\n')
|
||||
return getTextBetweenMarks(
|
||||
in_text = in_text.split('\n')
|
||||
return get_text_between_marks(
|
||||
mark, {
|
||||
'x': len(
|
||||
inText[0]) - 1, 'y': len(inText) - 1}, inText)
|
||||
in_text[0]) - 1, 'y': len(in_text) - 1}, in_text)
|
||||
|
Reference in New Issue
Block a user