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

    if value is None:
        return ""

    if isinstance(value, bool):
        return u"true" if value else u"false"
    elif isinstance(value, (int, float, long)):
        if value == float('inf'):
            return u"Infinity"
        elif value == float('-inf'):
            return u"-Infinity"

        # Try to see if we can shave off some trailing significant figures.
        try:
            if int(value) == value:
                return unicode(int(value))
        except (ValueError, TypeError):
            pass
    return unicode(value)
Return the JS string equivalent for a literal value.
dataset/ETHPy150Open mozilla/app-validator/appvalidator/testcases/javascript/utils.py/get_as_str