equal
deleted
inserted
replaced
51 'This is a…' |
51 'This is a…' |
52 >>> get_text_start('This is a long string', 20) |
52 >>> get_text_start('This is a long string', 20) |
53 'This is a long…' |
53 'This is a long…' |
54 >>> get_text_start('This is a long string', 20, 7) |
54 >>> get_text_start('This is a long string', 20, 7) |
55 'This is a long string' |
55 'This is a long string' |
|
56 >>> get_text_start('This is a long string', -1) |
|
57 'This is a long string' |
56 """ |
58 """ |
57 result = text or '' |
59 result = text or '' |
58 if length > len(result): |
60 if (length < 0) or (length > len(result)): |
59 return result |
61 return result |
60 index = length - 1 |
62 index = length - 1 |
61 text_length = len(result) |
63 text_length = len(result) |
62 while (index > 0) and (result[index] != ' '): |
64 while (index > 0) and (result[index] != ' '): |
63 index -= 1 |
65 index -= 1 |