Update sdk/platform-tools to version 26.0.0.
[android_tools.git] / sdk / platform-tools / systrace / catapult / telemetry / telemetry / internal / util / classes.py
blob0f90a06895fd572c4437f6bc58f7f768ba0a6e9b
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import inspect
8 def IsDirectlyConstructable(cls):
9 """Returns True if instance of |cls| can be construct without arguments."""
10 assert inspect.isclass(cls)
11 if not hasattr(cls, '__init__'):
12 # Case |class A: pass|.
13 return True
14 if cls.__init__ is object.__init__:
15 # Case |class A(object): pass|.
16 return True
17 # Case |class (object):| with |__init__| other than |object.__init__|.
18 args, _, _, defaults = inspect.getargspec(cls.__init__)
19 if defaults is None:
20 defaults = ()
21 # Return true if |self| is only arg without a default.
22 return len(args) == len(defaults) + 1