summaryrefslogtreecommitdiff
path: root/grc/gui/StateCache.py
diff options
context:
space:
mode:
authorJosh Morman <jmorman@gnuradio.org>2021-11-24 12:48:20 -0500
committermormj <34754695+mormj@users.noreply.github.com>2021-11-24 14:41:53 -0500
commit817fc3ce9cdc819a291e76ec324c4e748381f035 (patch)
treeed00faf5ea2c0f5a8caaba0ce41cd816dd6ca958 /grc/gui/StateCache.py
parente776d673aa51b5ef19e16cfb6d22098c0b14a679 (diff)
grc: pep8 formatting
Signed-off-by: Josh Morman <jmorman@gnuradio.org>
Diffstat (limited to 'grc/gui/StateCache.py')
-rw-r--r--grc/gui/StateCache.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/grc/gui/StateCache.py b/grc/gui/StateCache.py
index b3eb4e9232..fff261a29e 100644
--- a/grc/gui/StateCache.py
+++ b/grc/gui/StateCache.py
@@ -9,6 +9,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
from . import Actions
from .Constants import STATE_CACHE_SIZE
+
class StateCache(object):
"""
The state cache is an interface to a list to record data/states and to revert to previous states.
@@ -23,7 +24,7 @@ class StateCache(object):
Args:
initial_state: the initial state (nested data)
"""
- self.states = [None] * STATE_CACHE_SIZE #fill states
+ self.states = [None] * STATE_CACHE_SIZE # fill states
self.current_state_index = 0
self.num_prev_states = 0
self.num_next_states = 0
@@ -38,10 +39,12 @@ class StateCache(object):
Args:
state: the new state
"""
- self.current_state_index = (self.current_state_index + 1)%STATE_CACHE_SIZE
+ self.current_state_index = (
+ self.current_state_index + 1) % STATE_CACHE_SIZE
self.states[self.current_state_index] = state
self.num_prev_states = self.num_prev_states + 1
- if self.num_prev_states == STATE_CACHE_SIZE: self.num_prev_states = STATE_CACHE_SIZE - 1
+ if self.num_prev_states == STATE_CACHE_SIZE:
+ self.num_prev_states = STATE_CACHE_SIZE - 1
self.num_next_states = 0
self.update_actions()
@@ -63,7 +66,8 @@ class StateCache(object):
the previous state or None
"""
if self.num_prev_states > 0:
- self.current_state_index = (self.current_state_index + STATE_CACHE_SIZE -1)%STATE_CACHE_SIZE
+ self.current_state_index = (
+ self.current_state_index + STATE_CACHE_SIZE - 1) % STATE_CACHE_SIZE
self.num_next_states = self.num_next_states + 1
self.num_prev_states = self.num_prev_states - 1
return self.get_current_state()
@@ -77,7 +81,8 @@ class StateCache(object):
the next state or None
"""
if self.num_next_states > 0:
- self.current_state_index = (self.current_state_index + 1)%STATE_CACHE_SIZE
+ self.current_state_index = (
+ self.current_state_index + 1) % STATE_CACHE_SIZE
self.num_next_states = self.num_next_states - 1
self.num_prev_states = self.num_prev_states + 1
return self.get_current_state()