binman: Move to absolute imports
At present binman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.
Move binman to use absolute imports. This enables removable of the path
adjusting in Entry also.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 1244d36..9f62322 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -9,9 +9,9 @@
import os
import sys
-import fdt_util
+from dtoc import fdt_util
import tools
-from tools import ToHex, ToHexSize
+from patman.tools import ToHex, ToHexSize
import tout
modules = {}
@@ -63,7 +63,7 @@
def __init__(self, section, etype, node, name_prefix=''):
# Put this here to allow entry-docs and help to work without libfdt
global state
- import state
+ from binman import state
self.section = section
self.etype = etype
@@ -108,15 +108,11 @@
# Import the module if we have not already done so.
if not module:
- old_path = sys.path
- sys.path.insert(0, os.path.join(our_path, 'etype'))
try:
- module = importlib.import_module(module_name)
+ module = importlib.import_module('binman.etype.' + module_name)
except ImportError as e:
raise ValueError("Unknown entry type '%s' in node '%s' (expected etype/%s.py, error '%s'" %
(etype, node_path, module_name, e))
- finally:
- sys.path = old_path
modules[module_name] = module
# Look up the expected class name
@@ -590,9 +586,7 @@
modules.remove('_testing')
missing = []
for name in modules:
- if name.startswith('__'):
- continue
- module = Entry.Lookup(name, name)
+ module = Entry.Lookup('WriteDocs', name)
docs = getattr(module, '__doc__')
if test_missing == name:
docs = None