Fix duplicated functions and minor formatting PEP8 issues

Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
This commit is contained in:
Rafal Stefanowski 2020-01-20 15:10:25 +01:00
parent dd908053fb
commit cf67105489

View File

@ -85,21 +85,25 @@ class Time(timedelta):
class FlushParametersAlru: class FlushParametersAlru:
def __init__(self, def __init__(
activity_threshold=None, self,
flush_max_buffers=None, activity_threshold=None,
staleness_time=None, flush_max_buffers=None,
wake_up_time=None): staleness_time=None,
wake_up_time=None,
):
self.activity_threshold = activity_threshold self.activity_threshold = activity_threshold
self.flush_max_buffers = flush_max_buffers self.flush_max_buffers = flush_max_buffers
self.staleness_time = staleness_time self.staleness_time = staleness_time
self.wake_up_time = wake_up_time self.wake_up_time = wake_up_time
def __eq__(self, other): def __eq__(self, other):
return self.activity_threshold == other.activity_threshold and \ return (
self.flush_max_buffers == other.flush_max_buffers and \ self.activity_threshold == other.activity_threshold
self.staleness_time == other.staleness_time and \ and self.flush_max_buffers == other.flush_max_buffers
self.wake_up_time == other.wake_up_time and self.staleness_time == other.staleness_time
and self.wake_up_time == other.wake_up_time
)
@staticmethod @staticmethod
def default_alru_params(): def default_alru_params():
@ -112,15 +116,15 @@ class FlushParametersAlru:
class FlushParametersAcp: class FlushParametersAcp:
def __init__(self, def __init__(self, flush_max_buffers=None, wake_up_time=None):
flush_max_buffers=None,
wake_up_time=None):
self.flush_max_buffers = flush_max_buffers self.flush_max_buffers = flush_max_buffers
self.wake_up_time = wake_up_time self.wake_up_time = wake_up_time
def __eq__(self, other): def __eq__(self, other):
return self.flush_max_buffers == other.flush_max_buffers and \ return (
self.wake_up_time == other.wake_up_time self.flush_max_buffers == other.flush_max_buffers
and self.wake_up_time == other.wake_up_time
)
@staticmethod @staticmethod
def default_acp_params(): def default_acp_params():
@ -146,12 +150,14 @@ class SeqCutOffParameters:
# TODO: Use case for this will be to iterate over configurations (kernel params such as # TODO: Use case for this will be to iterate over configurations (kernel params such as
# TODO: io scheduler, metadata layout) and prepare env before starting cache # TODO: io scheduler, metadata layout) and prepare env before starting cache
class CacheConfig: class CacheConfig:
def __init__(self, def __init__(
cache_line_size=CacheLineSize.DEFAULT, self,
cache_mode=CacheMode.DEFAULT, cache_line_size=CacheLineSize.DEFAULT,
cleaning_policy=CleaningPolicy.DEFAULT, cache_mode=CacheMode.DEFAULT,
eviction_policy=EvictionPolicy.DEFAULT, cleaning_policy=CleaningPolicy.DEFAULT,
metadata_mode=MetadataMode.normal): eviction_policy=EvictionPolicy.DEFAULT,
metadata_mode=MetadataMode.normal,
):
self.cache_line_size = cache_line_size self.cache_line_size = cache_line_size
self.cache_mode = cache_mode self.cache_mode = cache_mode
self.cleaning_policy = cleaning_policy self.cleaning_policy = cleaning_policy
@ -159,8 +165,10 @@ class CacheConfig:
self.metadata_mode = metadata_mode self.metadata_mode = metadata_mode
def __eq__(self, other): def __eq__(self, other):
return self.cache_line_size == other.cache_line_size and \ return (
self.cache_mode == other.cache_mode and \ self.cache_line_size == other.cache_line_size
self.cleaning_policy == other.cleaning_policy and \ and self.cache_mode == other.cache_mode
self.eviction_policy == other.eviction_policy and \ and self.cleaning_policy == other.cleaning_policy
self.metadata_mode == other.metadata_mode and self.eviction_policy == other.eviction_policy
and self.metadata_mode == other.metadata_mode
)