[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/4] trace: [tracetool,trivial] Style changes
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH 2/4] trace: [tracetool,trivial] Style changes |
Date: |
Mon, 17 Feb 2014 20:36:30 +0100 |
User-agent: |
StGit/0.16 |
Signed-off-by: Lluís Vilanova <address@hidden>
---
scripts/tracetool/__init__.py | 25 +++++++++++++++----------
scripts/tracetool/backend/__init__.py | 2 +-
scripts/tracetool/format/__init__.py | 2 +-
scripts/tracetool/format/c.py | 4 ++--
scripts/tracetool/format/d.py | 4 ++--
scripts/tracetool/format/events_c.py | 4 ++--
scripts/tracetool/format/events_h.py | 4 ++--
scripts/tracetool/format/h.py | 2 +-
8 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 7f9161d..cca5072 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -144,7 +144,12 @@ class Event(object):
unknown_props = set(self.properties) - self._VALID_PROPS
if len(unknown_props) > 0:
- raise ValueError("Unknown properties: %s" % ",
".join(unknown_props))
+ raise ValueError("Unknown properties: %s" %
+ ", ".join(unknown_props))
+
+ def copy(other):
+ return Event(other.name, list(other.properties), other.fmt, other.args,
+ other)
@staticmethod
def build(line_str):
@@ -197,7 +202,7 @@ class TracetoolError (Exception):
pass
-def try_import(mod_name, attr_name = None, attr_default = None):
+def try_import(mod_name, attr_name=None, attr_default=None):
"""Try to import a module and get an attribute from it.
Parameters
@@ -224,7 +229,7 @@ def try_import(mod_name, attr_name = None, attr_default =
None):
def generate(fevents, format, backend,
- binary = None, probe_prefix = None):
+ binary=None, probe_prefix=None):
"""Generate the output for the given (format, backend) pair.
Parameters
@@ -246,18 +251,18 @@ def generate(fevents, format, backend,
format = str(format)
if len(format) is 0:
raise TracetoolError("format not set")
- mformat = format.replace("-", "_")
- if not tracetool.format.exists(mformat):
+ if not tracetool.format.exists(format):
raise TracetoolError("unknown format: %s" % format)
+ format = format.replace("-", "_")
backend = str(backend)
if len(backend) is 0:
raise TracetoolError("backend not set")
- mbackend = backend.replace("-", "_")
- if not tracetool.backend.exists(mbackend):
+ if not tracetool.backend.exists(backend):
raise TracetoolError("unknown backend: %s" % backend)
+ backend = backend.replace("-", "_")
- if not tracetool.backend.compatible(mbackend, mformat):
+ if not tracetool.backend.compatible(backend, format):
raise TracetoolError("backend '%s' not compatible with format '%s'" %
(backend, format))
@@ -270,7 +275,7 @@ def generate(fevents, format, backend,
if backend == "nop":
( e.properies.add("disable") for e in events )
- tracetool.format.generate_begin(mformat, events)
+ tracetool.format.generate_begin(format, events)
tracetool.backend.generate("nop", format,
[ e
for e in events
@@ -279,4 +284,4 @@ def generate(fevents, format, backend,
[ e
for e in events
if "disable" not in e.properties ])
- tracetool.format.generate_end(mformat, events)
+ tracetool.format.generate_end(format, events)
diff --git a/scripts/tracetool/backend/__init__.py
b/scripts/tracetool/backend/__init__.py
index f0314ee..88f94fd 100644
--- a/scripts/tracetool/backend/__init__.py
+++ b/scripts/tracetool/backend/__init__.py
@@ -59,7 +59,7 @@ def get_list(only_public = False):
for filename in os.listdir(tracetool.backend.__path__[0]):
if filename.endswith('.py') and filename != '__init__.py':
modnames.append(filename.rsplit('.', 1)[0])
- for modname in modnames:
+ for modname in sorted(modnames):
module = tracetool.try_import("tracetool.backend." + modname)
# just in case; should never fail unless non-module files are put there
diff --git a/scripts/tracetool/format/__init__.py
b/scripts/tracetool/format/__init__.py
index 3c2a0d8..577a224 100644
--- a/scripts/tracetool/format/__init__.py
+++ b/scripts/tracetool/format/__init__.py
@@ -53,7 +53,7 @@ def get_list():
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:
+ for modname in sorted(modnames):
module = tracetool.try_import("tracetool.format." + modname)
# just in case; should never fail unless non-module files are put there
diff --git a/scripts/tracetool/format/c.py b/scripts/tracetool/format/c.py
index 35555ae..930140b 100644
--- a/scripts/tracetool/format/c.py
+++ b/scripts/tracetool/format/c.py
@@ -2,11 +2,11 @@
# -*- coding: utf-8 -*-
"""
-Generate .c file.
+trace/generated-tracers.c
"""
__author__ = "Lluís Vilanova <address@hidden>"
-__copyright__ = "Copyright 2012, Lluís Vilanova <address@hidden>"
+__copyright__ = "Copyright 2012-2014, Lluís Vilanova <address@hidden>"
__license__ = "GPL version 2 or (at your option) any later version"
__maintainer__ = "Stefan Hajnoczi"
diff --git a/scripts/tracetool/format/d.py b/scripts/tracetool/format/d.py
index a2d5947..74ee0d3 100644
--- a/scripts/tracetool/format/d.py
+++ b/scripts/tracetool/format/d.py
@@ -2,11 +2,11 @@
# -*- coding: utf-8 -*-
"""
-Generate .d file (DTrace only).
+trace/generated-tracers.dtrace (DTrace only).
"""
__author__ = "Lluís Vilanova <address@hidden>"
-__copyright__ = "Copyright 2012, Lluís Vilanova <address@hidden>"
+__copyright__ = "Copyright 2012-2014, Lluís Vilanova <address@hidden>"
__license__ = "GPL version 2 or (at your option) any later version"
__maintainer__ = "Stefan Hajnoczi"
diff --git a/scripts/tracetool/format/events_c.py
b/scripts/tracetool/format/events_c.py
index d670ec8..ea668ee 100644
--- a/scripts/tracetool/format/events_c.py
+++ b/scripts/tracetool/format/events_c.py
@@ -2,11 +2,11 @@
# -*- coding: utf-8 -*-
"""
-Generate .c for event description.
+trace/generated-events.c
"""
__author__ = "Lluís Vilanova <address@hidden>"
-__copyright__ = "Copyright 2012, Lluís Vilanova <address@hidden>"
+__copyright__ = "Copyright 2012-2014, Lluís Vilanova <address@hidden>"
__license__ = "GPL version 2 or (at your option) any later version"
__maintainer__ = "Stefan Hajnoczi"
diff --git a/scripts/tracetool/format/events_h.py
b/scripts/tracetool/format/events_h.py
index d30ccea..f3febae 100644
--- a/scripts/tracetool/format/events_h.py
+++ b/scripts/tracetool/format/events_h.py
@@ -2,11 +2,11 @@
# -*- coding: utf-8 -*-
"""
-Generate .h for event description.
+trace/generated-events.h
"""
__author__ = "Lluís Vilanova <address@hidden>"
-__copyright__ = "Copyright 2012, Lluís Vilanova <address@hidden>"
+__copyright__ = "Copyright 2012-2014, Lluís Vilanova <address@hidden>"
__license__ = "GPL version 2 or (at your option) any later version"
__maintainer__ = "Stefan Hajnoczi"
diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py
index 9b0903d..85f011f 100644
--- a/scripts/tracetool/format/h.py
+++ b/scripts/tracetool/format/h.py
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
"""
-Generate .h file.
+trace/generated-tracers.h
"""
__author__ = "Lluís Vilanova <address@hidden>"
- [Qemu-devel] [PATCH 0/4] Tracetool cleanup, Lluís Vilanova, 2014/02/17
- [Qemu-devel] [PATCH 1/4] trace: [tracetool] Add method 'Event.api' to build event names, Lluís Vilanova, 2014/02/17
- [Qemu-devel] [PATCH 2/4] trace: [tracetool,trivial] Style changes,
Lluís Vilanova <=
- [Qemu-devel] [PATCH 3/4] trace: [tracetool] Identify formats directly used by QEMU, Lluís Vilanova, 2014/02/17
- [Qemu-devel] [PATCH 4/4] trace: [tracetool] Minimize the amount of per-backend code, Lluís Vilanova, 2014/02/17
- Re: [Qemu-devel] [PATCH 0/4] Tracetool cleanup, Stefan Hajnoczi, 2014/02/19