Merge pull request #7673 from bridadan/allow_memap_script_to_execute_alone

Fixing import paths of memap.py when excuted as a script
pull/7635/merge
Cruz Monrreal 2018-08-24 19:30:05 -05:00 committed by GitHub
commit ce43f8b9d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -4,10 +4,15 @@
from __future__ import print_function, division, absolute_import from __future__ import print_function, division, absolute_import
from abc import abstractmethod, ABCMeta from abc import abstractmethod, ABCMeta
from sys import stdout, exit, argv from sys import stdout, exit, argv, path
from os import sep, rename, remove from os import sep, rename, remove
from os.path import (basename, dirname, join, relpath, abspath, commonprefix, from os.path import (basename, dirname, join, relpath, abspath, commonprefix,
splitext, exists) splitext, exists)
# Be sure that the tools directory is in the search path
ROOT = abspath(join(dirname(__file__), ".."))
path.insert(0, ROOT)
import re import re
import csv import csv
import json import json
@ -18,9 +23,9 @@ from prettytable import PrettyTable
from jinja2 import FileSystemLoader, StrictUndefined from jinja2 import FileSystemLoader, StrictUndefined
from jinja2.environment import Environment from jinja2.environment import Environment
from .utils import (argparse_filestring_type, argparse_lowercase_hyphen_type, from tools.utils import (argparse_filestring_type, argparse_lowercase_hyphen_type,
argparse_uppercase_type) argparse_uppercase_type)
from .settings import COMPARE_FIXED from tools.settings import COMPARE_FIXED
class _Parser(object): class _Parser(object):
@ -93,7 +98,7 @@ class _GccParser(_Parser):
_Parser.MISC_FLASH_SECTIONS + ('unknown', 'OUTPUT') _Parser.MISC_FLASH_SECTIONS + ('unknown', 'OUTPUT')
def check_new_section(self, line): def check_new_section(self, line):
""" Check whether a new section in a map file has been detected """ Check whether a new section in a map file has been detected
Positional arguments: Positional arguments:
line - the line to check for a new section line - the line to check for a new section
@ -790,7 +795,7 @@ class MemapParser(object):
self.mem_report.append({ self.mem_report.append({
"module": name, "module": name,
"size":{ "size":{
k: sizes.get(k, 0) for k in (self.print_sections + k: sizes.get(k, 0) for k in (self.print_sections +
self.delta_sections) self.delta_sections)
} }
}) })