Skip to content

Commit ce43f8b

Browse files
author
Cruz Monrreal
authored
Merge pull request #7673 from bridadan/allow_memap_script_to_execute_alone
Fixing import paths of memap.py when excuted as a script
2 parents 31a6fb4 + b5a187d commit ce43f8b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tools/memap.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
from __future__ import print_function, division, absolute_import
55

66
from abc import abstractmethod, ABCMeta
7-
from sys import stdout, exit, argv
7+
from sys import stdout, exit, argv, path
88
from os import sep, rename, remove
99
from os.path import (basename, dirname, join, relpath, abspath, commonprefix,
1010
splitext, exists)
11+
12+
# Be sure that the tools directory is in the search path
13+
ROOT = abspath(join(dirname(__file__), ".."))
14+
path.insert(0, ROOT)
15+
1116
import re
1217
import csv
1318
import json
@@ -18,9 +23,9 @@
1823
from jinja2 import FileSystemLoader, StrictUndefined
1924
from jinja2.environment import Environment
2025

21-
from .utils import (argparse_filestring_type, argparse_lowercase_hyphen_type,
22-
argparse_uppercase_type)
23-
from .settings import COMPARE_FIXED
26+
from tools.utils import (argparse_filestring_type, argparse_lowercase_hyphen_type,
27+
argparse_uppercase_type)
28+
from tools.settings import COMPARE_FIXED
2429

2530

2631
class _Parser(object):
@@ -93,7 +98,7 @@ class _GccParser(_Parser):
9398
_Parser.MISC_FLASH_SECTIONS + ('unknown', 'OUTPUT')
9499

95100
def check_new_section(self, line):
96-
""" Check whether a new section in a map file has been detected
101+
""" Check whether a new section in a map file has been detected
97102
98103
Positional arguments:
99104
line - the line to check for a new section
@@ -790,7 +795,7 @@ def compute_report(self):
790795
self.mem_report.append({
791796
"module": name,
792797
"size":{
793-
k: sizes.get(k, 0) for k in (self.print_sections +
798+
k: sizes.get(k, 0) for k in (self.print_sections +
794799
self.delta_sections)
795800
}
796801
})

0 commit comments

Comments
 (0)