From e43a0c994319bd0de6e4379a543c75282e5bbc2d Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Sat, 29 Dec 2018 16:20:54 +0100 Subject: [PATCH] gdb: make the code PEP-8 compliant --- libs/gst/helpers/gst_gdb.py | 66 ++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/libs/gst/helpers/gst_gdb.py b/libs/gst/helpers/gst_gdb.py index fc3b48e..126680b 100644 --- a/libs/gst/helpers/gst_gdb.py +++ b/libs/gst/helpers/gst_gdb.py @@ -7,8 +7,9 @@ from glib_gobject_helper import g_type_to_name, g_type_name_from_instance if sys.version_info[0] >= 3: long = int -def is_gst_type (val, klass): - def _is_gst_type (type): + +def is_gst_type(val, klass): + def _is_gst_type(type): if str(type) == klass: return True @@ -19,61 +20,63 @@ def is_gst_type (val, klass): return False fields = type.fields() - if len (fields) < 1: + if len(fields) < 1: return False first_field = fields[0] - return _is_gst_type (first_field.type) - + return _is_gst_type(first_field.type) type = val.type if type.code != gdb.TYPE_CODE_PTR: return False type = type.target() - return _is_gst_type (type) + return _is_gst_type(type) + class GstMiniObjectPrettyPrinter: "Prints a GstMiniObject instance pointer" - def __init__ (self, val): + def __init__(self, val): self.val = val - def to_string (self): + def to_string(self): try: - inst = self.val.cast (gdb.lookup_type("GstMiniObject").pointer()) + inst = self.val.cast(gdb.lookup_type("GstMiniObject").pointer()) gtype = inst["type"] - name = g_type_to_name (gtype) + name = g_type_to_name(gtype) return "0x%x [%s]" % (long(self.val), name) except RuntimeError: - return "0x%x" % long(self.val) + return "0x%x" % long(self.val) + class GstObjectPrettyPrinter: "Prints a GstObject instance" - def __init__ (self, val): + def __init__(self, val): self.val = val - def to_string (self): + def to_string(self): try: - name = g_type_name_from_instance (self.val) + name = g_type_name_from_instance(self.val) if not name: name = str(self.val.type.target()) if long(self.val) != 0: - inst = self.val.cast (gdb.lookup_type("GstObject").pointer()) + inst = self.val.cast(gdb.lookup_type("GstObject").pointer()) inst_name = inst["name"].string() if inst_name: name += "|" + inst_name - return ("0x%x [%s]") % (long(self.val), name) + return ("0x%x [%s]") % (long(self.val), name) except RuntimeError: - return "0x%x" % long(self.val) + return "0x%x" % long(self.val) + class GstClockTimePrinter: "Prints a GstClockTime / GstClockTimeDiff" - def __init__ (self, val): + def __init__(self, val): self.val = val - def to_string (self): + def to_string(self): GST_SECOND = 1000000000 GST_CLOCK_TIME_NONE = 2**64-1 GST_CLOCK_STIME_NONE = -2**63 @@ -92,23 +95,26 @@ class GstClockTimePrinter: if invalid: return str(n) + " [99:99:99.999999999]" - return str(n) + " [%s%u:%02u:%02u.%09u]" % ( prefix, - n / (GST_SECOND * 60 * 60), + return str(n) + " [%s%u:%02u:%02u.%09u]" % ( + prefix, + n / (GST_SECOND * 60 * 60), (n / (GST_SECOND * 60)) % 60, (n / GST_SECOND) % 60, - n % GST_SECOND ) + n % GST_SECOND) + -def gst_pretty_printer_lookup (val): - if is_gst_type (val, "GstMiniObject"): - return GstMiniObjectPrettyPrinter (val) - if is_gst_type (val, "GstObject"): - return GstObjectPrettyPrinter (val) +def gst_pretty_printer_lookup(val): + if is_gst_type(val, "GstMiniObject"): + return GstMiniObjectPrettyPrinter(val) + if is_gst_type(val, "GstObject"): + return GstObjectPrettyPrinter(val) if str(val.type) == "GstClockTime" or str(val.type) == "GstClockTimeDiff": - return GstClockTimePrinter (val) + return GstClockTimePrinter(val) return None -def register (obj): - if obj == None: + +def register(obj): + if obj is None: obj = gdb # Make sure this is always used befor the glib lookup function. -- 2.7.4