def validate_string(cls, value): return ( SimpleModel.validate_string(cls, value) and (value is None or ( len(value) >= cls.Attributes.min_len and len(value) <= cls.Attributes.max_len and _re_match_with_span(cls.Attributes, value) )))
def is_default(cls): return ( SimpleModel.is_default(cls) and cls.Attributes.min_len == Unicode.Attributes.min_len and cls.Attributes.max_len == Unicode.Attributes.max_len and cls.Attributes.pattern == Unicode.Attributes.pattern )
def __new__(cls, *args, **kwargs): assert len(args) <= 2 if len(args) >= 1 and args[0] is not None: kwargs['total_digits'] = args[0] kwargs['fraction_digits'] = 0 if len(args) == 2 and args[1] is not None: kwargs['fraction_digits'] = args[1] assert args[0] > 0, "'total_digits' must be positive." assert args[1] <= args[0], "'total_digits' must be greater than" \ " or equal to 'fraction_digits'." \ " %r ! <= %r" % (args[1], args[0]) # + 1 for decimal separator # + 1 for negative sign msl = kwargs.get('max_str_len', None) if msl is None: kwargs['max_str_len'] = (cls.Attributes.total_digits + cls.Attributes.fraction_digits + 2) else: kwargs['max_str_len'] = msl retval = SimpleModel.__new__(cls, ** kwargs) return retval
def validate_string(cls, value): return SimpleModel.validate_string(cls, value) and ( value is None or ( len(value) <= (cls.Attributes.total_digits + cls.Attributes.fraction_digits + 1) # + 1 is for decimal separator ))
def is_default(cls): return ( SimpleModel.is_default(cls) and cls.Attributes.gt == Decimal.Attributes.gt and cls.Attributes.ge == Decimal.Attributes.ge and cls.Attributes.lt == Decimal.Attributes.lt and cls.Attributes.le == Decimal.Attributes.le )
def validate_native(cls, value): return SimpleModel.validate_native(cls, value) and ( value is None or ( value > cls.Attributes.gt and value >= cls.Attributes.ge and value < cls.Attributes.lt and value <= cls.Attributes.le ))
def is_default(cls): return ( SimpleModel.is_default(cls) and cls.Attributes.gt == Date.Attributes.gt and cls.Attributes.ge == Date.Attributes.ge and cls.Attributes.lt == Date.Attributes.lt and cls.Attributes.le == Date.Attributes.le and cls.Attributes.pattern == Date.Attributes.pattern )
def __new__(cls, dim=None, **kwargs): assert dim in (None,2,3) if dim is not None: kwargs['dim'] = dim kwargs['pattern'] = _get_point_pattern(dim) kwargs['type_name'] = 'point%dd' % dim return SimpleModel.__new__(cls, ** kwargs)
def validate_string(cls, value): return ( SimpleModel.validate_string(cls, value) and (value is None or ( len(value) >= cls.Attributes.min_len and len(value) <= cls.Attributes.max_len and (cls.Attributes.pattern is None or re.match(cls.Attributes.pattern, value) is not None) )))
def __new__(cls, *args, **kwargs): assert len(args) <= 1 if len(args) == 1: kwargs['max_len'] = args[0] retval = SimpleModel.__new__(cls, ** kwargs) return retval
def __new__(cls, dim=None, **kwargs): assert dim in (None, 2, 3) if dim is not None: kwargs['dim'] = dim kwargs['pattern'] = _get_multipoint_pattern(dim) kwargs['type_name'] = 'multipoint%dd' % dim retval = SimpleModel.__new__(cls, **kwargs) retval.__namespace__ = 'http://spyne.io/schema' return retval
def __new__(cls, dim=None, **kwargs): assert dim in (None,2,3) if dim is not None: kwargs['dim'] = dim kwargs['pattern'] = _get_multipolygon_pattern(dim) kwargs['type_name'] = 'multipolygon%dd' % dim retval = SimpleModel.__new__(cls, **kwargs) retval.__namespace__ = 'http://spyne.io/schema' return retval
def validate_native(cls, value): if isinstance(value, datetime.datetime) and value.tzinfo is None: value = value.replace(tzinfo=spyne.LOCAL_TZ) return SimpleModel.validate_native(cls, value) and (value is None or ( # min_dt is also a valid value if gt is intact. (cls.Attributes.gt is _min_dt or value > cls.Attributes.gt) and value >= cls.Attributes.ge # max_dt is also a valid value if lt is intact. and (cls.Attributes.lt is _max_dt or value < cls.Attributes.lt) and value <= cls.Attributes.le))
def is_default(cls): return ( SimpleModel.is_default(cls) and cls.Attributes.gt == Decimal.Attributes.gt and cls.Attributes.ge == Decimal.Attributes.ge and cls.Attributes.lt == Decimal.Attributes.lt and cls.Attributes.le == Decimal.Attributes.le and cls.Attributes.total_digits == Decimal.Attributes.total_digits and cls.Attributes.fraction_digits == Decimal.Attributes.fraction_digits )
def validate_native(cls, value): if isinstance(value, datetime.datetime) and value.tzinfo is None: value = value.replace(tzinfo=spyne.LOCAL_TZ) return SimpleModel.validate_native(cls, value) and ( value is None or ( value > cls.Attributes.gt and value >= cls.Attributes.ge and value < cls.Attributes.lt and value <= cls.Attributes.le ))
def validate_native(cls, value): if value is not None and isinstance(value, datetime.datetime): value = value.replace(tzinfo=pytz.utc) return SimpleModel.validate_native(cls, value) and ( value is None or ( value > cls.Attributes.gt and value >= cls.Attributes.ge and value < cls.Attributes.lt and value <= cls.Attributes.le ))
def is_default(cls): return ( SimpleModel.is_default(cls) and cls.Attributes.gt == Decimal.Attributes.gt and cls.Attributes.ge == Decimal.Attributes.ge and cls.Attributes.lt == Decimal.Attributes.lt and cls.Attributes.le == Decimal.Attributes.le and cls.Attributes.total_digits == \ Decimal.Attributes.total_digits and cls.Attributes.fraction_digits == \ Decimal.Attributes.fraction_digits )
def __new__(cls, dim=None, **kwargs): assert dim in (None, 2, 3) if dim is not None: kwargs["dim"] = dim kwargs["pattern"] = _get_multipolygon_pattern(dim) kwargs["type_name"] = "multipolygon%dd" % dim retval = SimpleModel.__new__(cls, **kwargs) retval.__namespace__ = "http://spyne.io/schema" retval.__extends__ = Unicode retval.__orig__ = Unicode return retval
def __new__(cls, dim=None, **kwargs): assert dim in (None,2,3) if dim is not None: kwargs['dim'] = dim kwargs['pattern'] = _get_linestring_pattern(dim) kwargs['type_name'] = 'line%dd' % dim retval = SimpleModel.__new__(cls, **kwargs) retval.__namespace__ = 'http://spyne.io/schema' retval.__extends__ = Unicode retval.__orig__ = Unicode return retval
def __new__(cls, dim=None, **kwargs): assert dim in (None, 2, 3) if dim is not None: kwargs['dim'] = dim kwargs['pattern'] = _get_multilinestring_pattern(dim) kwargs['type_name'] = 'multiLine%dd' % dim retval = SimpleModel.__new__(cls, **kwargs) retval.__namespace__ = 'http://spyne.io/schema' retval.__extends__ = Unicode retval.__orig__ = Unicode return retval
def __new__(cls, *args, **kwargs): assert len(args) <= 2 if len(args) >= 1 and args[0] is not None: kwargs['total_digits'] = args[0] kwargs['fraction_digits'] = 0 if len(args) == 2 and args[1] is not None: kwargs['fraction_digits'] = args[1] retval = SimpleModel.__new__(cls, **kwargs) return retval
def validate_native(cls, value): if isinstance(value, datetime.datetime) and value.tzinfo is None: value = value.replace(tzinfo=spyne.LOCAL_TZ) return SimpleModel.validate_native(cls, value) and ( value is None or ( # min_dt is also a valid value if gt is intact. (cls.Attributes.gt is None or value > cls.Attributes.gt) and value >= cls.Attributes.ge # max_dt is also a valid value if lt is intact. and (cls.Attributes.lt is None or value < cls.Attributes.lt) and value <= cls.Attributes.le ))
def __new__(cls, **kwargs): if 'encoding' in kwargs: v = kwargs['encoding'] if v in (None, 'base64'): kwargs['type_name'] = 'base64Binary' elif v == 'hex': kwargs['type_name'] = 'hexBinary' else: raise ValueError("'encoding' must be one of: %r" % \ (tuple(ByteArray._encoding.handlers.values()),)) return SimpleModel.__new__(cls, **kwargs)
def __new__(cls, *args, **kwargs): assert len(args) <= 2 if len(args) >= 1 and args[0] is not None: kwargs['total_digits'] = args[0] kwargs['fraction_digits'] = 0 if len(args) == 2 and args[1] is not None: kwargs['fraction_digits'] = args[1] assert args[0] <= args[1], "Total digits should be greater than" \ " or equal to fraction digits." \ " %r ! <= %r" % (args[0], args[1]) retval = SimpleModel.__new__(cls, ** kwargs) return retval
def __new__(cls, *args, **kwargs): assert len(args) <= 2 if len(args) >= 1 and args[0] is not None: kwargs['total_digits'] = args[0] kwargs['fraction_digits'] = 0 if len(args) == 2 and args[1] is not None: kwargs['fraction_digits'] = args[1] assert args[0] <= args[1], "Total digits should be greater than" \ " or equal to fraction digits." \ " %r ! <= %r" % (args[0], args[1]) retval = SimpleModel.__new__(cls, **kwargs) return retval
def __new__(cls, *args, **kwargs): assert len(args) <= 2 if len(args) >= 1 and args[0] is not None: kwargs['total_digits'] = args[0] kwargs['fraction_digits'] = 0 if len(args) == 2 and args[1] is not None: kwargs['fraction_digits'] = args[1] assert args[0] > 0, "'total_digits' must be positive." assert args[1] <= args[0], "'total_digits' must be greater than" \ " or equal to 'fraction_digits'." \ " %r ! <= %r" % (args[1], args[0]) retval = SimpleModel.__new__(cls, ** kwargs) return retval
def __new__(cls, *args, **kwargs): assert len(args) <= 2 if len(args) >= 1 and args[0] is not None: kwargs['total_digits'] = args[0] kwargs['fraction_digits'] = 0 if len(args) == 2 and args[1] is not None: kwargs['fraction_digits'] = args[1] assert args[0] > 0, "'total_digits' must be positive." assert args[1] <= args[0], "'total_digits' must be greater than" \ " or equal to 'fraction_digits'." \ " %r ! <= %r" % (args[1], args[0]) # + 1 for decimal separator # + 1 for negative sign kwargs['max_str_len'] = min( cls.Attributes.total_digits + cls.Attributes.fraction_digits + 2, kwargs.get('max_str_len', 0)) retval = SimpleModel.__new__(cls, **kwargs) return retval
def validate_native(cls, value): return SimpleModel.validate_native(cls, value) and ( value is None or (value > cls.Attributes.gt and value >= cls.Attributes.ge and value < cls.Attributes.lt and value <= cls.Attributes.le))
def validate_native(cls, value): return (SimpleModel.validate_native(cls, value) and (value is None or (_re_match_with_span(cls.Attributes, value))))
def validate_string(cls, value): return (SimpleModel.validate_string(cls, value) and (value is None or (len(value) >= cls.Attributes.min_len and len(value) <= cls.Attributes.max_len and _re_match_with_span(cls.Attributes, value))))
def is_default(cls): return (SimpleModel.is_default(cls) and cls.Attributes.min_len == Unicode.Attributes.min_len and cls.Attributes.max_len == Unicode.Attributes.max_len and cls.Attributes.pattern == Unicode.Attributes.pattern)
def validate_native(cls, value): return SimpleModel.validate_native(cls, value)
def validate_native(cls, value): return (SimpleModel.validate_native(cls, value) and (value is None or ( _re_match_with_span(cls.Attributes, value) )))
def validate_string(cls, value): return ( SimpleModel.validate_string(cls, value) and value in cls.__values__ )
def validate_string(cls, value): return SimpleModel.validate_string( cls, value) and (value is None or (len(value) <= cls.Attributes.max_str_len))
def validate_string(cls, value): return SimpleModel.validate_string(cls, value) and ( value is None or (len(value) <= cls.Attributes.max_str_len) )
def is_default(cls): return (SimpleModel.is_default(cls) and cls.Attributes.gt == Double.Attributes.gt and cls.Attributes.ge == Double.Attributes.ge and cls.Attributes.lt == Double.Attributes.lt and cls.Attributes.le == Double.Attributes.le)
def validate_string(cls, value): return SimpleModel.validate_string(cls, value) and value in cls.__values__