Refactor and rename OOMEntity.back()
Rename OOMEntity.back() to goto_previous_line() and align code with current usage.
This commit is contained in:
parent
cbd16d266f
commit
52d476cee2
@ -2664,12 +2664,18 @@ class OOMEntity:
|
|||||||
|
|
||||||
return stripped_lines
|
return stripped_lines
|
||||||
|
|
||||||
def back(self):
|
def goto_previous_line(self):
|
||||||
"""Return the previous line"""
|
"""Set line pointer to previous line
|
||||||
if self.current_line - 1 < 0:
|
|
||||||
raise StopIteration()
|
If using in front of an iterator:
|
||||||
self.current_line -= 1
|
The line pointer in self.current_line points to the first line of a block.
|
||||||
return self.lines[self.current_line]
|
An iterator based loop starts with a next() call (as defined by the iterator
|
||||||
|
protocol). This causes the current line to be skipped. Therefore, the line
|
||||||
|
pointer is set to the previous line.
|
||||||
|
"""
|
||||||
|
if self.current_line > 0:
|
||||||
|
self.current_line -= 1
|
||||||
|
return
|
||||||
|
|
||||||
def current(self):
|
def current(self):
|
||||||
"""Return the current line"""
|
"""Return the current line"""
|
||||||
@ -2959,7 +2965,7 @@ class OOMAnalyser:
|
|||||||
block += "{}\n".format(line)
|
block += "{}\n".format(line)
|
||||||
for line in self.oom_entity:
|
for line in self.oom_entity:
|
||||||
if ":" in line:
|
if ":" in line:
|
||||||
self.oom_entity.back()
|
self.oom_entity.goto_previous_line()
|
||||||
break
|
break
|
||||||
block += "{}\n".format(line)
|
block += "{}\n".format(line)
|
||||||
return block
|
return block
|
||||||
@ -3073,12 +3079,7 @@ class OOMAnalyser:
|
|||||||
buddy_info = self.oom_result.buddyinfo
|
buddy_info = self.oom_result.buddyinfo
|
||||||
self.oom_entity.find_text(self.oom_result.kconfig.zoneinfo_start)
|
self.oom_entity.find_text(self.oom_result.kconfig.zoneinfo_start)
|
||||||
|
|
||||||
# Currently omm_entity point to the first line of the buddyinfo.
|
self.oom_entity.goto_previous_line()
|
||||||
# The iterator protocol uses the next() call. However, this will cause the
|
|
||||||
# current line to be skipped.
|
|
||||||
# Therefore, we reset the counter by one line.
|
|
||||||
self.oom_entity.back()
|
|
||||||
|
|
||||||
for line in self.oom_entity:
|
for line in self.oom_entity:
|
||||||
match = self.REC_FREE_MEMORY_CHUNKS.match(line)
|
match = self.REC_FREE_MEMORY_CHUNKS.match(line)
|
||||||
if not match:
|
if not match:
|
||||||
@ -3135,14 +3136,9 @@ class OOMAnalyser:
|
|||||||
watermark_info = self.oom_result.watermarks
|
watermark_info = self.oom_result.watermarks
|
||||||
self.oom_entity.find_text(self.oom_result.kconfig.watermark_start)
|
self.oom_entity.find_text(self.oom_result.kconfig.watermark_start)
|
||||||
|
|
||||||
# Currently omm_entity point to the first line of the watermark information.
|
|
||||||
# The iterator protocol uses the next() call. However, this will cause the
|
|
||||||
# current line to be skipped.
|
|
||||||
# Therefore, we reset the counter by one line.
|
|
||||||
self.oom_entity.back()
|
|
||||||
|
|
||||||
node = None
|
node = None
|
||||||
zone = None
|
zone = None
|
||||||
|
self.oom_entity.goto_previous_line()
|
||||||
for line in self.oom_entity:
|
for line in self.oom_entity:
|
||||||
match = self.REC_WATERMARK.match(line)
|
match = self.REC_WATERMARK.match(line)
|
||||||
if not match:
|
if not match:
|
||||||
|
Loading…
Reference in New Issue
Block a user