Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
source
OBSW MOD GENERATOR CORE
Commits
4e08d014
Commit
4e08d014
authored
Feb 25, 2021
by
Robin Mueller
Browse files
implemented moving window
parent
46c8d66e
Changes
1
Hide whitespace changes
Inline
Side-by-side
returnvalues/mib_returnvalues_parser.py
View file @
4e08d014
...
...
@@ -5,6 +5,8 @@ from generatore_core.utility.mib_printer import PrettyPrinter
# Intermediate solution
MAX_STRING_LEN
=
80
DEBUG_FOR_FILE_NAME
=
True
DEBUG_FILE_NAME
=
"RingBufferAnalyzer"
class
InterfaceParser
(
FileParser
):
...
...
@@ -65,7 +67,7 @@ class ReturnValueParser(FileParser):
self
.
interfaces
=
interfaces
self
.
return_value_dict
=
dict
()
self
.
count
=
0
self
.
moving_window_size
=
5
self
.
moving_window_size
=
7
# Moving window of 5 lines will be used
self
.
moving_window
=
[
""
]
*
self
.
moving_window_size
# Stores last three lines
...
...
@@ -94,15 +96,43 @@ class ReturnValueParser(FileParser):
else
:
print_truncated_entries
=
False
for
line_idx
,
line
in
enumerate
(
all_lines
):
print
(
line_idx
)
if
line_idx
<
self
.
moving_window_size
:
self
.
moving_window
[
line_idx
-
1
]
=
line
else
:
self
.
moving_window
[
4
]
=
line
for
idx
in
range
(
1
,
4
):
self
.
moving_window
[
idx
]
=
self
.
moving_window
[
idx
-
1
]
if
line_idx
>=
5
:
pass
if
DEBUG_FILE_NAME
and
DEBUG_FILE_NAME
in
file_name
:
print
(
f
"Moving window pre line anaylsis line
{
line_idx
}
"
)
print
(
self
.
moving_window
)
# The moving window will start with only the bottom being in the file
if
line_idx
==
0
:
self
.
moving_window
[
self
.
moving_window_size
-
1
]
=
line
# More and more of the window is inside the file now
elif
line_idx
<
self
.
moving_window_size
:
for
idx
in
range
(
line_idx
,
0
,
-
1
):
self
.
moving_window
[
self
.
moving_window_size
-
1
-
idx
]
=
\
self
.
moving_window
[
self
.
moving_window_size
-
idx
]
self
.
moving_window
[
self
.
moving_window_size
-
1
]
=
line
# The full window is inside the file now.
elif
line_idx
>=
self
.
moving_window_size
:
for
idx
in
range
(
self
.
moving_window_size
-
1
):
self
.
moving_window
[
idx
]
=
self
.
moving_window
[
idx
+
1
]
self
.
moving_window
[
self
.
moving_window_size
-
1
]
=
line
if
DEBUG_FILE_NAME
and
DEBUG_FILE_NAME
in
file_name
:
print
(
f
"Moving window post line anaylsis line
{
line_idx
}
"
)
print
(
self
.
moving_window
)
# Now the moving window moved past the end of the file. Sections which are outside
# the file are assigned an empty string until the window has moved out of file completely
for
remaining_windows_idx
in
range
(
self
.
moving_window_size
):
if
DEBUG_FILE_NAME
and
DEBUG_FILE_NAME
in
file_name
:
print
(
f
"Moving window pre line analysis post EOF"
)
print
(
self
.
moving_window
)
num_entries_to_clear
=
remaining_windows_idx
+
1
for
idx_to_clear
in
range
(
num_entries_to_clear
):
self
.
moving_window
[
self
.
moving_window_size
-
1
-
idx_to_clear
]
=
""
for
idx_to_reassign
in
range
(
self
.
moving_window_size
-
1
-
num_entries_to_clear
):
self
.
moving_window
[
idx_to_reassign
]
=
self
.
moving_window
[
idx_to_reassign
+
1
]
if
DEBUG_FILE_NAME
and
DEBUG_FILE_NAME
in
file_name
:
print
(
f
"Moving window post line anaylsis post EOF"
)
print
(
self
.
moving_window
)
# Clear out moving window for next cycle
self
.
moving_window
=
[
""
]
*
self
.
moving_window_size
# for line in all_lines:
# self.__handle_line_reading(line, file_name, print_truncated_entries)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment