Change-Id: I0acb94ce9127214069b78e5f858e321351298268
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3822
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Vinay Kulkarni <kulkarniv@vmware.com>
Reviewed-by: Sharath George
... | ... |
@@ -95,9 +95,10 @@ class TextPane(Action): |
95 | 95 |
def read_file(self, text_file_path, line_width): |
96 | 96 |
with open(text_file_path, "r") as f: |
97 | 97 |
for line in f: |
98 |
- # remove the trailing line feeds |
|
99 |
- while line.endswith('\r') or line.endswith('\n'): |
|
100 |
- line = line[:-1] |
|
98 |
+ # remove the trailing white space. |
|
99 |
+ line = line.rstrip() |
|
100 |
+ # expand tab to 8 spaces. |
|
101 |
+ line = line.expandtabs() |
|
101 | 102 |
# Adjust the words on the lines |
102 | 103 |
while len(line) > line_width: |
103 | 104 |
sep_index = line_width |
... | ... |
@@ -109,8 +110,8 @@ class TextPane(Action): |
109 | 109 |
if sep_index == 0: |
110 | 110 |
current_line_width = line_width |
111 | 111 |
currLine = line[:current_line_width] |
112 |
- line = line.strip() |
|
113 | 112 |
line = line[current_line_width:] |
113 |
+ line = line.strip() |
|
114 | 114 |
|
115 | 115 |
# Lengthen the line with spaces |
116 | 116 |
self.lines.append(currLine + ' ' * (line_width - len(currLine))) |