1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-18 12:06:08 +00:00

wa/utils: Fix pylint errors

This commit is contained in:
Marc Bonnici 2018-07-03 12:33:24 +01:00
parent 1550e9a788
commit 185bff9029
9 changed files with 19 additions and 17 deletions

View File

@ -57,7 +57,7 @@ class LogcatParser(object):
if event:
yield event
def parse_line(self, line):
def parse_line(self, line): #pylint: disable=no-self-use
line = line.strip()
if not line or line.startswith('-') or ': ' not in line:
return None

View File

@ -564,7 +564,7 @@ class CpuUtilizationTimeline(object):
def update(self, timestamp, core_states): # NOQA
row = [timestamp]
for core, [idle_state, frequency] in enumerate(core_states):
for core, [_, frequency] in enumerate(core_states):
if frequency is not None:
frequency /= float(self._max_freq_list[core])
row.append(frequency)
@ -584,7 +584,7 @@ def build_idle_state_map(cpus):
for cpu_idx, cpu in enumerate(cpus):
related_cpus = set(cpu.cpufreq.related_cpus) - set([cpu_idx])
first_cluster_state = cpu.cpuidle.num_states - 1
for state_idx, state in enumerate(cpu.cpuidle.states):
for state_idx, _ in enumerate(cpu.cpuidle.states):
if state_idx < first_cluster_state:
idle_state_map[(cpu_idx, state_idx)] = []
else:

View File

@ -17,8 +17,8 @@ import os
import re
import logging
#pyline disable=redefined-builtin
from builtins import zip
from builtins import zip #pyline disable=redefined-builtin
from future.moves.itertools import zip_longest
from wa.utils.misc import diff_tokens, write_table
@ -70,7 +70,7 @@ def diff_interrupt_files(before, after, result): # pylint: disable=R0914
def diff_sysfs_dirs(before, after, result): # pylint: disable=R0914
before_files = []
for root, dirs, files in os.walk(before):
for root, _, files in os.walk(before):
before_files.extend([os.path.join(root, f) for f in files])
before_files = list(filter(os.path.isfile, before_files))
files = [os.path.relpath(f, before) for f in before_files]

View File

@ -49,7 +49,7 @@ _indent_width = 4
_console_handler = None
_init_handler = None
#pylint: disable=global-statement
def init(verbosity=logging.INFO, color=True, indent_with=4,
regular_fmt='%(levelname)-8s %(message)s',
verbose_fmt='%(asctime)s %(levelname)-8s %(name)10.10s: %(message)s',
@ -95,6 +95,7 @@ def set_level(level):
_console_handler.setLevel(level)
#pylint: disable=global-statement
def add_file(filepath, level=logging.DEBUG,
fmt='%(asctime)s %(levelname)-8s %(name)10.10s: %(message)s'):
global _init_handler
@ -139,11 +140,13 @@ def __disable_logger(logger):
logger.propagate = False
#pylint: disable=global-statement
def indent():
global _indent_level
_indent_level += 1
#pylint: disable=global-statement
def dedent():
global _indent_level
_indent_level -= 1
@ -158,6 +161,7 @@ def indentcontext():
dedent()
#pylint: disable=global-statement
def set_indent_level(level):
global _indent_level
old_level = _indent_level
@ -265,11 +269,11 @@ class LineFormatter(logging.Formatter):
record.asctime = self.formatTime(record, self.datefmt)
indent_level = getattr(record, 'indent_level', _indent_level)
indent = _indent_width * indent_level
cur_indent = _indent_width * indent_level
d = record.__dict__
parts = []
for line in record.message.split('\n'):
line = ' ' * indent + line
line = ' ' * cur_indent + line
d.update({'message': line.strip('\r')})
parts.append(self._fmt % d)

View File

@ -418,7 +418,7 @@ def categorize(v):
else:
return 'c'
#pylint: disable=too-many-return-statements,too-many-branches
def merge_config_values(base, other):
"""
This is used to merge two objects, typically when setting the value of a

View File

@ -65,6 +65,7 @@ from datetime import datetime
import yaml as _yaml
import dateutil.parser
#pylint: disable=redefined-builtin
from past.builtins import basestring
from wa.framework.exception import SerializerSyntaxError
@ -274,7 +275,7 @@ class python(object):
exec(s, pod) # pylint: disable=exec-used
except SyntaxError as e:
raise SerializerSyntaxError(e.message, e.lineno)
for k in list(pod.keys()):
for k in list(pod.keys()): # pylint: disable=consider-iterating-dictionary
if k.startswith('__'):
del pod[k]
return pod
@ -350,7 +351,7 @@ def _write_pod(pod, wfh, fmt=None):
def is_pod(obj):
if type(obj) not in POD_TYPES:
if type(obj) not in POD_TYPES: #pylint: disable=unidiomatic-typecheck
return False
if hasattr(obj, 'items'):
for k, v in obj.items():
@ -361,6 +362,3 @@ def is_pod(obj):
if not is_pod(v):
return False
return True

View File

@ -105,4 +105,3 @@ def _get_terminal_size_linux():
if __name__ == "__main__":
sizex, sizey = get_terminal_size()
print('width =', sizex, 'height =', sizey)

View File

@ -266,6 +266,7 @@ class TraceCmdParser(object):
by trace-cmd
"""
inside_maked_region = False
#pylint: disable=superfluous-parens
filters = [re.compile('^{}$'.format(e)) for e in (self.events or [])]
filter_markers = self.filter_markers
if filter_markers and self.check_for_markers:

View File

@ -800,7 +800,7 @@ class cpu_mask(object):
elif isinstance(cpus, list):
self._mask = list_to_mask(cpus)
elif isinstance(cpus, cpu_mask):
self._mask = cpus._mask
self._mask = cpus._mask # pylint: disable=protected-access
else:
msg = 'Unknown conversion from {} to cpu mask'
raise ValueError(msg.format(cpus))