예제 #1
0
 def _handle_binary_in_string(self, arg):
     try:
         if not is_bytes(arg):
             arg = arg.encode('ASCII')
     except UnicodeError:
         raise ValueError('Cannot represent %r as binary.' % arg)
     return xmlrpclib.Binary(arg)
예제 #2
0
 def _handle_binary_in_string(self, arg):
     try:
         if not is_bytes(arg):
             arg = arg.encode('ASCII')
     except UnicodeError:
         raise ValueError('Cannot represent %r as binary.' % arg)
     return xmlrpclib.Binary(arg)
예제 #3
0
 def _to_string(self, value):
     if is_unicode(value):
         return value
     if is_bytes(value):
         return value.decode('UTF-8')
     if is_tuple(value):
         return f"{value[0]}={value[1]}"
     raise DataError('Return value must be string.')
예제 #4
0
    def should_be_byte_string(self, item, msg=None):
        """Fails if the given ``item`` is not a byte string.

        Use `Should Be Unicode String` if you want to verify the ``item`` is a
        Unicode string, or `Should Be String` if both Unicode and byte strings
        are fine. See `Should Be String` for more details about Unicode strings
        and byte strings.

        The default error message can be overridden with the optional
        ``msg`` argument.
        """
        if not is_bytes(item):
            self._fail(msg, "'%s' is not a byte string.", item)
예제 #5
0
    def should_be_byte_string(self, item, msg=None):
        """Fails if the given ``item`` is not a byte string.

        Use `Should Be Unicode String` if you want to verify the ``item`` is a
        Unicode string, or `Should Be String` if both Unicode and byte strings
        are fine. See `Should Be String` for more details about Unicode strings
        and byte strings.

        The default error message can be overridden with the optional
        ``msg`` argument.
        """
        if not is_bytes(item):
            self._fail(msg, "'%s' is not a byte string.", item)
예제 #6
0
 def _string_contains_binary(self, arg):
     return (self.binary.search(arg) or
             is_bytes(arg) and self.non_ascii.search(arg))
예제 #7
0
 def _contains_binary(self, arg):
     return (self.binary.search(arg) or is_bytes(arg) and not IRONPYTHON
             and self.non_ascii.search(arg))
예제 #8
0
파일: Remote.py 프로젝트: Garjy/RIDE
 def _contains_binary(self, arg):
     return (self.binary.search(arg) or
             is_bytes(arg) and not IRONPYTHON and
             self.non_ascii.search(arg))
예제 #9
0
 def _to_string(self, value):
     if is_unicode(value):
         return value
     if is_bytes(value):
         return value.decode('UTF-8')
     raise DataError('Return value must be string.')
예제 #10
0
 def _string_contains_binary(self, arg):
     return (self.binary.search(arg)
             or is_bytes(arg) and self.non_ascii.search(arg))
예제 #11
0
 def _to_string(self, value):
     if is_unicode(value):
         return value
     if is_bytes(value):
         return value.decode('UTF-8')
     raise DataError('Return value must be string.')