743.1.11
by Joshua Harlow
Continue working on merging code. |
1 |
# vi: ts=4 expandtab
|
2 |
#
|
|
3 |
# Copyright (C) 2012 Canonical Ltd.
|
|
4 |
# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
|
|
5 |
# Copyright (C) 2012 Yahoo! Inc.
|
|
6 |
#
|
|
7 |
# Author: Scott Moser <scott.moser@canonical.com>
|
|
8 |
# Author: Juerg Haefliger <juerg.haefliger@hp.com>
|
|
9 |
# Author: Joshua Harlow <harlowja@yahoo-inc.com>
|
|
10 |
#
|
|
11 |
# This program is free software: you can redistribute it and/or modify
|
|
12 |
# it under the terms of the GNU General Public License version 3, as
|
|
13 |
# published by the Free Software Foundation.
|
|
14 |
#
|
|
15 |
# This program is distributed in the hope that it will be useful,
|
|
16 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 |
# GNU General Public License for more details.
|
|
19 |
#
|
|
20 |
# You should have received a copy of the GNU General Public License
|
|
21 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
22 |
||
23 |
import types |
|
24 |
||
1052.1.5
by Barry Warsaw
Largely merge lp:~harlowja/cloud-init/py2-3 albeit manually because it seemed |
25 |
import six |
26 |
||
27 |
||
28 |
if six.PY3: |
|
29 |
_NAME_TYPES = ( |
|
30 |
types.ModuleType, |
|
31 |
types.FunctionType, |
|
32 |
types.LambdaType, |
|
33 |
type, |
|
34 |
)
|
|
35 |
else: |
|
36 |
_NAME_TYPES = ( |
|
37 |
types.TypeType, |
|
38 |
types.ModuleType, |
|
39 |
types.FunctionType, |
|
40 |
types.LambdaType, |
|
41 |
types.ClassType, |
|
42 |
)
|
|
43 |
||
743.1.11
by Joshua Harlow
Continue working on merging code. |
44 |
|
45 |
def obj_name(obj): |
|
1052.1.5
by Barry Warsaw
Largely merge lp:~harlowja/cloud-init/py2-3 albeit manually because it seemed |
46 |
if isinstance(obj, _NAME_TYPES): |
47 |
return six.text_type(obj.__name__) |
|
48 |
else: |
|
49 |
if not hasattr(obj, '__class__'): |
|
50 |
return repr(obj) |
|
51 |
else: |
|
52 |
return obj_name(obj.__class__) |