How to use the pykwalify.compat.basestring function in pykwalify

To help you get started, we’ve selected a few pykwalify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Grokzen / pykwalify / pykwalify / types.py View on Github external
def is_string(obj):
    return isinstance(obj, basestring) or isinstance(obj, bytes)
github Grokzen / pykwalify / pykwalify / types.py View on Github external
def is_date(obj):
    """
    :param obj: Object that is to be validated
    :return: True/False if obj is valid date object
    """
    return isinstance(obj, basestring) or isinstance(obj, datetime.date)
github Grokzen / pykwalify / pykwalify / core.py View on Github external
# Timestamp integers can't be above the upper limit of
                # 32 bit integers
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Integer value of timestamp can't be above 2147483647",
                    path=path,
                    value=timestamp,
                    timestamp=str(timestamp),
                ))

        if isinstance(timestamp_value, (int, float)):
            _check_int_timestamp_boundaries(timestamp_value)
        elif isinstance(timestamp_value, datetime.datetime):
            # Datetime objects currently have nothing to validate.
            # In the future, more options will be added to datetime validation
            pass
        elif isinstance(timestamp_value, basestring):
            v = timestamp_value.strip()

            # parse("") will give a valid date but it should not be
            # considered a valid timestamp
            if v == "":
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Timestamp value is empty. Path: '{path}'",
                    path=path,
                    value=nativestr(timestamp_value),
                    timestamp=nativestr(timestamp_value)))
            else:
                # A string can contain a valid unit timestamp integer. Check if it is valid and validate it
                try:
                    int_v = int(v)
                    _check_int_timestamp_boundaries(int_v)
                except ValueError:
github Grokzen / pykwalify / pykwalify / types.py View on Github external
def is_string(obj):
    return isinstance(obj, basestring) or isinstance(obj, bytes)
github Grokzen / pykwalify / pykwalify / types.py View on Github external
def is_date(obj):
    """
    :param obj: Object that is to be validated
    :return: True/False if obj is valid date object
    """
    return isinstance(obj, basestring) or isinstance(obj, datetime.date)
github Grokzen / pykwalify / pykwalify / errors.py View on Github external
def fset(self, value):
            assert isinstance(value, basestring), "argument is not string"
            self._msg = value