patman: Move to absolute imports
At present patman 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 patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index d47ea43..795b519 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -3,12 +3,14 @@
#
import collections
-import command
-import gitutil
import os
import re
import sys
-import terminal
+
+from patman import command
+from patman import gitutil
+from patman import terminal
+from patman import tools
def FindCheckPatch():
top_level = gitutil.GetTopLevel()
diff --git a/tools/patman/command.py b/tools/patman/command.py
index 5fbd2c4..e67ac15 100644
--- a/tools/patman/command.py
+++ b/tools/patman/command.py
@@ -3,8 +3,9 @@
#
import os
-import cros_subprocess
-import tools
+
+from patman import cros_subprocess
+from patman import tools
"""Shell command ease-ups for Python."""
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 748e225..b7e2825 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -14,10 +14,10 @@
from io import StringIO
-import gitutil
-import patchstream
-import settings
-import tools
+from patman import gitutil
+from patman import patchstream
+from patman import settings
+from patman import tools
@contextlib.contextmanager
diff --git a/tools/patman/get_maintainer.py b/tools/patman/get_maintainer.py
index 0ffb55a..473f0fe 100644
--- a/tools/patman/get_maintainer.py
+++ b/tools/patman/get_maintainer.py
@@ -2,10 +2,11 @@
# Copyright (c) 2012 The Chromium OS Authors.
#
-import command
-import gitutil
import os
+from patman import command
+from patman import gitutil
+
def FindGetMaintainer():
"""Look for the get_maintainer.pl script.
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index a2a225c..770a051 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -2,17 +2,17 @@
# Copyright (c) 2011 The Chromium OS Authors.
#
-import command
import re
import os
-import series
import subprocess
import sys
-import terminal
-import checkpatch
-import settings
-import tools
+from patman import checkpatch
+from patman import command
+from patman import series
+from patman import settings
+from patman import terminal
+from patman import tools
# True to use --no-decorate - we check this in Setup()
use_no_decorate = True
diff --git a/tools/patman/main.py b/tools/patman/main.py
index b642c2e..f59367f 100755
--- a/tools/patman/main.py
+++ b/tools/patman/main.py
@@ -18,14 +18,14 @@
sys.path.append(os.path.join(our_path, '..'))
# Our modules
-import checkpatch
-import command
-import gitutil
-import patchstream
-import project
-import settings
-import terminal
-import test
+from patman import checkpatch
+from patman import command
+from patman import gitutil
+from patman import patchstream
+from patman import project
+from patman import settings
+from patman import terminal
+from patman import test
parser = OptionParser()
@@ -86,7 +86,7 @@
# Run our meagre tests
elif options.test:
import doctest
- import func_test
+ from patman import func_test
sys.argv = [sys.argv[0]]
result = unittest.TestResult()
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index df3eb74..4052975 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -9,10 +9,10 @@
import shutil
import tempfile
-import command
-import commit
-import gitutil
-from series import Series
+from patman import command
+from patman import commit
+from patman import gitutil
+from patman.series import Series
# Tags that we detect and remove
re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Review URL:'
diff --git a/tools/patman/project.py b/tools/patman/project.py
index 1d9cfc0..2dfc303 100644
--- a/tools/patman/project.py
+++ b/tools/patman/project.py
@@ -4,7 +4,7 @@
import os.path
-import gitutil
+from patman import gitutil
def DetectProject():
"""Autodetect the name of the current project.
diff --git a/tools/patman/series.py b/tools/patman/series.py
index 3869696..e5e28ce 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -5,11 +5,11 @@
import itertools
import os
-import get_maintainer
-import gitutil
-import settings
-import terminal
-import tools
+from patman import get_maintainer
+from patman import gitutil
+from patman import settings
+from patman import terminal
+from patman import tools
# Series-xxx tags that we understand
valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name',
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 21e8fc4..ca74fc6 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -10,9 +10,9 @@
import os
import re
-import command
-import gitutil
-import tools
+from patman import command
+from patman import gitutil
+from patman import tools
"""Default settings per-project.
diff --git a/tools/patman/test.py b/tools/patman/test.py
index 889e186..e7f709e 100644
--- a/tools/patman/test.py
+++ b/tools/patman/test.py
@@ -8,11 +8,11 @@
import tempfile
import unittest
-import checkpatch
-import gitutil
-import patchstream
-import series
-import commit
+from patman import checkpatch
+from patman import gitutil
+from patman import patchstream
+from patman import series
+from patman import commit
class TestPatch(unittest.TestCase):
diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py
index bb5a298..4d28d9f 100644
--- a/tools/patman/test_util.py
+++ b/tools/patman/test_util.py
@@ -10,7 +10,8 @@
import sys
import unittest
-import command
+from patman import command
+from patman import test_util
from io import StringIO
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index 7b21a12..b50370d 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -3,7 +3,6 @@
# Copyright (c) 2016 Google, Inc
#
-import command
import glob
import os
import shutil
@@ -11,7 +10,8 @@
import sys
import tempfile
-import tout
+from patman import command
+from patman import tout
# Output directly (generally this is temporary)
outdir = None
diff --git a/tools/patman/tout.py b/tools/patman/tout.py
index ee3c519..c7e3272 100644
--- a/tools/patman/tout.py
+++ b/tools/patman/tout.py
@@ -6,7 +6,7 @@
import sys
-import terminal
+from patman import terminal
# Output verbosity levels that we support
ERROR, WARNING, NOTICE, INFO, DETAIL, DEBUG = range(6)