All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] binman: Use pkg_resources to find resources
@ 2020-08-29 17:36 Simon Glass
  2020-08-29 17:36 ` [PATCH 2/2] tools: Drop unnecessary use of __file__ Simon Glass
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Glass @ 2020-08-29 17:36 UTC (permalink / raw)
  To: u-boot

At present we look for resources based on the path of the Python module
that wants them. Instead we should use Python's pkg_resources feature
which is designed for this purpose.

Update binman to use this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/control.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index 60e89d3776b..3b523266417 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -8,6 +8,8 @@
 from collections import OrderedDict
 import glob
 import os
+import pkg_resources
+
 import sys
 from patman import tools
 
@@ -58,8 +60,8 @@ def GetEntryModules(include_testing=True):
     Returns:
         Set of paths to entry class filenames
     """
-    our_path = os.path.dirname(os.path.realpath(__file__))
-    glob_list = glob.glob(os.path.join(our_path, 'etype/*.py'))
+    glob_list = pkg_resources.resource_listdir(__name__, 'etype')
+    glob_list = [fname for fname in glob_list if fname.endswith('.py')]
     return set([os.path.splitext(os.path.basename(item))[0]
                 for item in glob_list
                 if include_testing or '_testing' not in item])
-- 
2.28.0.402.g5ffc5be6b7-goog

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] tools: Drop unnecessary use of __file__
  2020-08-29 17:36 [PATCH 1/2] binman: Use pkg_resources to find resources Simon Glass
@ 2020-08-29 17:36 ` Simon Glass
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2020-08-29 17:36 UTC (permalink / raw)
  To: u-boot

There are few places where the path of the current modules is calculated
but not used. Drop them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/entry.py  | 2 --
 tools/buildman/test.py | 3 ---
 tools/rmboard.py       | 3 ---
 3 files changed, 8 deletions(-)

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 3434a3f8048..c17a98958bd 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -16,8 +16,6 @@ from patman import tout
 
 modules = {}
 
-our_path = os.path.dirname(os.path.realpath(__file__))
-
 
 # An argument which can be passed to entries on the command line, in lieu of
 # device-tree properties.
diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index 3eaba07559b..1a259d54ab0 100644
--- a/tools/buildman/test.py
+++ b/tools/buildman/test.py
@@ -9,9 +9,6 @@ import tempfile
 import time
 import unittest
 
-# Bring in the patman libraries
-our_path = os.path.dirname(os.path.realpath(__file__))
-
 from buildman import board
 from buildman import bsettings
 from buildman import builder
diff --git a/tools/rmboard.py b/tools/rmboard.py
index 06c3562ad81..de685638cf1 100755
--- a/tools/rmboard.py
+++ b/tools/rmboard.py
@@ -28,9 +28,6 @@ import os
 import re
 import sys
 
-# Bring in the patman libraries
-our_path = os.path.dirname(os.path.realpath(__file__))
-
 from patman import command
 
 def rm_kconfig_include(path):
-- 
2.28.0.402.g5ffc5be6b7-goog

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-29 17:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-29 17:36 [PATCH 1/2] binman: Use pkg_resources to find resources Simon Glass
2020-08-29 17:36 ` [PATCH 2/2] tools: Drop unnecessary use of __file__ Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.