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)')
def parse_args():
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description='Convert trace data to a file.')
add_args(parser)

View file

@ -42,7 +42,7 @@ def add_args(parser: argparse.ArgumentParser) -> None:
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 '
'directory and output model data.')
add_args(parser)

View file

@ -67,14 +67,14 @@ class MemoryUsageDataModelUtil(DataModelUtil):
:param precision: the number of digits to display after the period
"""
suffixes = ['B', 'KB', 'MB', 'GB', 'TB']
suffixIndex = 0
suffix_index = 0
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
suffixIndex += 1
suffix_index += 1
# Apply the division
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:
"""

View file

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