VirtualBox

Changeset 69573 in vbox


Ignore:
Timestamp:
Nov 4, 2017 8:52:52 AM (7 years ago)
Author:
vboxsync
Message:

common/utils.py: Added getObjectTypeName method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/common/utils.py

    r69547 r69573  
    15971597
    15981598
     1599def getObjectTypeName(oObject):
     1600    """
     1601    Get the type name of the given object.
     1602    """
     1603    if oObject is None:
     1604        return 'None';
     1605
     1606    # Get the type object.
     1607    try:
     1608        oType = type(oObject);
     1609    except:
     1610        return 'type-throws-exception';
     1611
     1612    # Python 2.x only: Handle old-style object wrappers.
     1613    if sys.version_info[0] < 3:
     1614        try:
     1615            from types import InstanceType;
     1616            if oType == InstanceType:
     1617                oType = oObject.__class__;
     1618        except:
     1619            pass;
     1620
     1621    # Get the name.
     1622    try:
     1623        return oType.__name__;
     1624    except:
     1625        return '__type__-throws-exception';
     1626
     1627
    15991628#
    16001629# TestSuite stuff.
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette