Пример #1
0
 def __call__(self, elem):
     if not self.token.evaluate(XPathContext(root=elem)):
         msg = "expression is not true with test path %r."
         yield XMLSchemaValidationError(self,
                                        obj=elem,
                                        reason=msg % self.path)
Пример #2
0
def long_validator(x):
    if not (-2**127 <= x < 2**127):
        yield XMLSchemaValidationError(long_validator, x, "value must be -2^127 <= x < 2^127.")
Пример #3
0
def unsigned_byte_validator(x):
    if not (0 <= x < 2**8):
        yield XMLSchemaValidationError(unsigned_byte_validator, x, "value must be 0 <= x < 256.")
Пример #4
0
def short_validator(x):
    if not (-2**15 <= x < 2**15):
        yield XMLSchemaValidationError(short_validator, x, "value must be -2^16 <= x < 2^16.")
Пример #5
0
def int_validator(x):
    if not (-2**63 <= x < 2**63):
        yield XMLSchemaValidationError(int_validator, x, "value must be -2^63 <= x < 2^63.")
Пример #6
0
 def hex_length_validator(self, x):
     if len(x) != self.value * 2:
         yield XMLSchemaValidationError(
             self, x, "binary length has to be %r." % self.value)
Пример #7
0
def unsigned_int_validator(x):
    if not (0 <= x < 2**64):
        yield XMLSchemaValidationError(unsigned_int_validator, x, "value must be 0 <= x < 2^64.")
Пример #8
0
def hex_binary_validator(x):
    if x and (len(x) % 2 or HEX_BINARY_PATTERN.match(x) is None):
        yield XMLSchemaValidationError(hex_binary_validator, x, "not an hexadecimal number.")
Пример #9
0
def finite_number_validator(x):
    try:
        if isinf(x) or isnan(x):
            yield XMLSchemaValidationError(finite_number_validator, x, "value {!r} is not an xs:decimal".format(x))
    except TypeError:
        pass
Пример #10
0
def non_positive_int_validator(x):
    if x > 0:
        yield XMLSchemaValidationError(non_positive_int_validator, x, "value must be non positive.")
Пример #11
0
def non_negative_int_validator(x):
    if x < 0:
        yield XMLSchemaValidationError(non_negative_int_validator, x, "value must be non negative.")
Пример #12
0
def positive_int_validator(x):
    if x <= 0:
        yield XMLSchemaValidationError(positive_int_validator, x, "value must be positive.")
Пример #13
0
def negative_int_validator(x):
    if x >= 0:
        yield XMLSchemaValidationError(negative_int_validator, x, reason="value must be negative.")
Пример #14
0
def unsigned_long_validator(x):
    if not (0 <= x < 2**128):
        yield XMLSchemaValidationError(unsigned_long_validator, x, "value must be 0 <= x < 2^128.")
Пример #15
0
 def collapse_white_space_validator(self, x):
     if '\t' in x or '\n' in x or '  ' in x:
         yield XMLSchemaValidationError(self, x)
Пример #16
0
def qname_validator(x):
    if datatypes.QNAME_PATTERN.match(x) is None:
        yield XMLSchemaValidationError(qname_validator, x, "value {!r} is not an xs:QName".format(x))
Пример #17
0
 def length_validator(self, x):
     if len(x) != self.value:
         yield XMLSchemaValidationError(self, x,
                                        "length has to be %r." % self.value)
Пример #18
0
def byte_validator(x):
    if not (-2**7 <= x < 2**7):
        yield XMLSchemaValidationError(int_validator, x, "value must be -128 <= x < 128.")
Пример #19
0
 def base64_length_validator(self, x):
     x = x.replace(' ', '')
     if (len(x) // 4 * 3 - (x[-1] == '=') - (x[-2] == '=')) != self.value:
         yield XMLSchemaValidationError(
             self, x, "binary length has to be %r." % self.value)
Пример #20
0
def unsigned_short_validator(x):
    if not (0 <= x < 2**16):
        yield XMLSchemaValidationError(unsigned_short_validator, x, "value must be 0 <= x < 2^32.")