To make Fenrir easier to approach for new developer, start code migration to be pep8 compliant.
This commit is contained in:
@ -6,28 +6,30 @@
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
|
||||
|
||||
def getTextBetweenMarks(firstMark, secondMark, inText):
|
||||
if inText == None:
|
||||
if inText is None:
|
||||
return ''
|
||||
if not isinstance(inText, list):
|
||||
inText = inText.split('\n')
|
||||
if len(inText) < 1:
|
||||
return ''
|
||||
if firstMark == None:
|
||||
return ''
|
||||
if secondMark == None:
|
||||
return ''
|
||||
if (firstMark['y'] + 1) * (firstMark['x'] + 1) <= (secondMark['y'] + 1) * (secondMark['x'] + 1):
|
||||
if firstMark is None:
|
||||
return ''
|
||||
if secondMark is None:
|
||||
return ''
|
||||
if (firstMark['y'] + 1) * (firstMark['x'] +
|
||||
1) <= (secondMark['y'] + 1) * (secondMark['x'] + 1):
|
||||
startMark = firstMark.copy()
|
||||
endMark = secondMark.copy()
|
||||
else:
|
||||
endMark = firstMark.copy()
|
||||
startMark = secondMark.copy()
|
||||
startMark = secondMark.copy()
|
||||
textPart = ''
|
||||
if startMark['y'] == endMark['y']:
|
||||
textPart += inText[startMark['y']][startMark['x']:endMark['x'] + 1]
|
||||
else:
|
||||
currY = startMark['y']
|
||||
currY = startMark['y']
|
||||
while currY <= endMark['y']:
|
||||
if currY < endMark['y']:
|
||||
if currY == startMark['y']:
|
||||
@ -35,7 +37,7 @@ def getTextBetweenMarks(firstMark, secondMark, inText):
|
||||
else:
|
||||
textPart += inText[currY]
|
||||
if len(inText[currY].strip()) != 0:
|
||||
if len(textPart) - len(textPart.rstrip()) > 0:
|
||||
if len(textPart) - len(textPart.rstrip()) > 0:
|
||||
textPart = textPart[:len(textPart.rstrip())] + "\n"
|
||||
else:
|
||||
textPart += '\n'
|
||||
@ -44,17 +46,22 @@ def getTextBetweenMarks(firstMark, secondMark, inText):
|
||||
currY += 1
|
||||
return textPart
|
||||
|
||||
|
||||
def getTextBeforeMark(mark, inText):
|
||||
if inText == None:
|
||||
if inText is None:
|
||||
return ''
|
||||
if mark == None:
|
||||
if mark is None:
|
||||
return ''
|
||||
return getTextBetweenMarks({'x':0,'y':0}, mark, inText)
|
||||
return getTextBetweenMarks({'x': 0, 'y': 0}, mark, inText)
|
||||
|
||||
|
||||
def getTextAfterMark(mark, inText):
|
||||
if inText == None:
|
||||
if inText is None:
|
||||
return ''
|
||||
if mark == None:
|
||||
if mark is None:
|
||||
return ''
|
||||
inText = inText.split('\n')
|
||||
return getTextBetweenMarks(mark, {'x':len(inText[0])-1,'y':len(inText)-1}, inText)
|
||||
return getTextBetweenMarks(
|
||||
mark, {
|
||||
'x': len(
|
||||
inText[0]) - 1, 'y': len(inText) - 1}, inText)
|
||||
|
Reference in New Issue
Block a user