aboutsummaryrefslogtreecommitdiff
path: root/catapult/common/py_trace_event/py_trace_event/trace_event_impl/meta_class.py
blob: 7aaa3faf62c7d0a1f989b88e12f1dfb3b77c1f96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import types

from py_trace_event.trace_event_impl import decorators


class TracedMetaClass(type):
  def __new__(cls, name, bases, attrs):
    for attr_name, attr_value in attrs.iteritems():
      if (not attr_name.startswith('_') and
          isinstance(attr_value, types.FunctionType)):
        attrs[attr_name] = decorators.traced(attr_value)

    return super(TracedMetaClass, cls).__new__(cls, name, bases, attrs)