summaryrefslogtreecommitdiff
path: root/cloudinit/type_utils.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2013-03-06 19:24:05 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2013-03-06 19:24:05 -0800
commitfc6aa5aa54ee35ff0a3eff823bae0d3cf9b34bc1 (patch)
treebaf2534ea20b011e2b9d68ffdd5385ecba2dc31f /cloudinit/type_utils.py
parent2653a9172e375484b4d0a88c3de56334136fa134 (diff)
downloadvyos-cloud-init-fc6aa5aa54ee35ff0a3eff823bae0d3cf9b34bc1.tar.gz
vyos-cloud-init-fc6aa5aa54ee35ff0a3eff823bae0d3cf9b34bc1.zip
Continue working on merging code.
Diffstat (limited to 'cloudinit/type_utils.py')
-rw-r--r--cloudinit/type_utils.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/cloudinit/type_utils.py b/cloudinit/type_utils.py
new file mode 100644
index 00000000..2decbfc5
--- /dev/null
+++ b/cloudinit/type_utils.py
@@ -0,0 +1,34 @@
+# vi: ts=4 expandtab
+#
+# Copyright (C) 2012 Canonical Ltd.
+# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
+# Copyright (C) 2012 Yahoo! Inc.
+#
+# Author: Scott Moser <scott.moser@canonical.com>
+# Author: Juerg Haefliger <juerg.haefliger@hp.com>
+# Author: Joshua Harlow <harlowja@yahoo-inc.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3, as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# pylint: disable=C0302
+
+import types
+
+
+def obj_name(obj):
+ if isinstance(obj, (types.TypeType,
+ types.ModuleType,
+ types.FunctionType,
+ types.LambdaType)):
+ return str(obj.__name__)
+ return obj_name(obj.__class__)