Merge branch 'fix-flake8-errors-and-add-typing' into 'master'

Fix flake8 errors and add typing

See merge request micro-ROS/ros_tracing/tracetools_analysis!64
This commit is contained in:
Christophe Bedard 2020-05-23 13:37:05 +00:00
commit 5e845fe196
4 changed files with 15 additions and 15 deletions

View file

@ -39,7 +39,7 @@ def add_args(parser: argparse.ArgumentParser) -> None:
'under $trace_directory (default: %(default)s)') 'under $trace_directory (default: %(default)s)')
def parse_args(): def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Convert trace data to a file.') description='Convert trace data to a file.')
add_args(parser) add_args(parser)

View file

@ -42,7 +42,7 @@ def add_args(parser: argparse.ArgumentParser) -> None:
help='hide/suppress results from being printed') help='hide/suppress results from being printed')
def parse_args(): def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description='Process a file converted from a trace ' parser = argparse.ArgumentParser(description='Process a file converted from a trace '
'directory and output model data.') 'directory and output model data.')
add_args(parser) add_args(parser)

View file

@ -67,14 +67,14 @@ class MemoryUsageDataModelUtil(DataModelUtil):
:param precision: the number of digits to display after the period :param precision: the number of digits to display after the period
""" """
suffixes = ['B', 'KB', 'MB', 'GB', 'TB'] suffixes = ['B', 'KB', 'MB', 'GB', 'TB']
suffixIndex = 0 suffix_index = 0
mem_size = float(size) mem_size = float(size)
while mem_size > 1024.0 and suffixIndex < 4: while mem_size > 1024.0 and suffix_index < 4:
# Increment the index of the suffix # Increment the index of the suffix
suffixIndex += 1 suffix_index += 1
# Apply the division # Apply the division
mem_size = mem_size / 1024.0 mem_size = mem_size / 1024.0
return f'{mem_size:.{precision}f} {suffixes[suffixIndex]}' return f'{mem_size:.{precision}f} {suffixes[suffix_index]}'
def get_max_memory_usage_per_tid(self) -> DataFrame: def get_max_memory_usage_per_tid(self) -> DataFrame:
""" """

View file

@ -64,13 +64,13 @@ class Ros2DataModelUtil(DataModelUtil):
# remove spaces # remove spaces
pretty = pretty.replace(' ', '') pretty = pretty.replace(' ', '')
# allocator # allocator
STD_ALLOCATOR = '_<std::allocator<void>>' std_allocator = '_<std::allocator<void>>'
pretty = pretty.replace(STD_ALLOCATOR, '') pretty = pretty.replace(std_allocator, '')
# default_delete # default_delete
STD_DEFAULTDELETE = 'std::default_delete' std_defaultdelete = 'std::default_delete'
if STD_DEFAULTDELETE in pretty: if std_defaultdelete in pretty:
dd_start = pretty.find(STD_DEFAULTDELETE) dd_start = pretty.find(std_defaultdelete)
template_param_open = dd_start + len(STD_DEFAULTDELETE) template_param_open = dd_start + len(std_defaultdelete)
# find index of matching/closing GT sign # find index of matching/closing GT sign
template_param_close = template_param_open template_param_close = template_param_open
level = 0 level = 0
@ -86,10 +86,10 @@ class Ros2DataModelUtil(DataModelUtil):
level -= 1 level -= 1
pretty = pretty[:dd_start] + pretty[(template_param_close + 1):] pretty = pretty[:dd_start] + pretty[(template_param_close + 1):]
# bind # bind
STD_BIND = 'std::_Bind<' std_bind = 'std::_Bind<'
if pretty.startswith(STD_BIND): if pretty.startswith(std_bind):
# remove bind<> # remove bind<>
pretty = pretty.replace(STD_BIND, '') pretty = pretty.replace(std_bind, '')
pretty = pretty[:-1] pretty = pretty[:-1]
# remove placeholder stuff # remove placeholder stuff
placeholder_from = pretty.find('*') placeholder_from = pretty.find('*')