def get_as_num(value):
    if hasattr(value, 'get_literal_value'):
        value = value.get_literal_value()

    if value is None:
        return 0

    try:
        if isinstance(value, types.StringTypes):
            if value.startswith("0x"):
                return int(value, 16)
            else:
                return float(value)
        elif isinstance(value, (int, float, long)):
            return value
        else:
            return int(value)
    except (ValueError, TypeError):
        return 0
Return the JS numeric equivalent for a value.
dataset/ETHPy150Open mozilla/app-validator/appvalidator/testcases/javascript/utils.py/get_as_num