aboutsummaryrefslogtreecommitdiff
path: root/scripts/tracetool/format
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-04-30 12:00:23 +0100
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-05-01 20:15:28 +0100
commit9943e0ec38786125ce1bbaf82ba6c3cadb976ba6 (patch)
treeebf5136728aa32207af540a73b2dd21c8550ac11 /scripts/tracetool/format
parentb3ef0ade57ff29e33d3204ca2f48b1e36108116e (diff)
downloadqemu-9943e0ec38786125ce1bbaf82ba6c3cadb976ba6.zip
qemu-9943e0ec38786125ce1bbaf82ba6c3cadb976ba6.tar.gz
qemu-9943e0ec38786125ce1bbaf82ba6c3cadb976ba6.tar.bz2
tracetool: avoid pkgutil.iter_modules() Python 2.7 function
The pkgutil.iter_modules() function provides a way to enumerate child modules. Unfortunately it's missing in Python <2.7 so we must implement similar behavior ourselves. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Reviewed-by: LluĂ­s Vilanova <vilanova@ac.upc.edu>
Diffstat (limited to 'scripts/tracetool/format')
-rw-r--r--scripts/tracetool/format/__init__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/tracetool/format/__init__.py b/scripts/tracetool/format/__init__.py
index 0e4baf0..3c2a0d8 100644
--- a/scripts/tracetool/format/__init__.py
+++ b/scripts/tracetool/format/__init__.py
@@ -41,7 +41,7 @@ __maintainer__ = "Stefan Hajnoczi"
__email__ = "stefanha@linux.vnet.ibm.com"
-import pkgutil
+import os
import tracetool
@@ -49,7 +49,11 @@ import tracetool
def get_list():
"""Get a list of (name, description) pairs."""
res = []
- for _, modname, _ in pkgutil.iter_modules(tracetool.format.__path__):
+ modnames = []
+ for filename in os.listdir(tracetool.format.__path__[0]):
+ if filename.endswith('.py') and filename != '__init__.py':
+ modnames.append(filename.rsplit('.', 1)[0])
+ for modname in modnames:
module = tracetool.try_import("tracetool.format." + modname)
# just in case; should never fail unless non-module files are put there