コード例 #1
0
ファイル: file.py プロジェクト: crs4/pydoop
 def __init__(self, raw_hdfs_file, fs, mode, encoding=None, errors=None):
     self.mode = mode
     self.base_mode, is_text = common.parse_mode(self.mode)
     self.buff_size = raw_hdfs_file.buff_size
     if self.buff_size <= 0:
         self.buff_size = common.BUFSIZE
     if is_text:
         self.__encoding = encoding or self.__class__.ENCODING
         self.__errors = errors or self.__class__.ERRORS
         try:
             codecs.lookup(self.__encoding)
             codecs.lookup_error(self.__errors)
         except LookupError as e:
             raise ValueError(e)
     else:
         if encoding:
             raise ValueError(
                 "binary mode doesn't take an encoding argument")
         if errors:
             raise ValueError("binary mode doesn't take an errors argument")
         self.__encoding = self.__errors = None
     cls = io.BufferedReader if self.base_mode == "r" else io.BufferedWriter
     self.f = cls(raw_hdfs_file, buffer_size=self.buff_size)
     self.__fs = fs
     info = fs.get_path_info(self.f.raw.name)
     self.__name = info["name"]
     self.__size = info["size"]
     self.closed = False
コード例 #2
0
ファイル: frontend.py プロジェクト: jmchilton/galaxy-central
def validate_encoding_error_handler(setting, value, option_parser, config_parser=None, config_section=None):
    try:
        codecs.lookup_error(value)
    except AttributeError:  # prior to Python 2.3
        if value not in ("strict", "ignore", "replace", "xmlcharrefreplace"):
            raise (
                LookupError(
                    'unknown encoding error handler: "%s" (choices: '
                    '"strict", "ignore", "replace", or "xmlcharrefreplace")' % value
                ),
                None,
                sys.exc_info()[2],
            )
    except LookupError:
        raise (
            LookupError(
                'unknown encoding error handler: "%s" (choices: '
                '"strict", "ignore", "replace", "backslashreplace", '
                '"xmlcharrefreplace", and possibly others; see documentation for '
                "the Python ``codecs`` module)" % value
            ),
            None,
            sys.exc_info()[2],
        )
    return value
コード例 #3
0
def change_encoding(file, encoding=None, errors=ERRORS):
    encoding = encoding or file.encoding
    errors = errors or file.errors
    codecs.lookup_error(errors)
    newfile = io.TextIOWrapper(file.buffer, encoding, errors,
                               line_buffering=file.line_buffering)
    newfile.mode = file.mode
    newfile._changed_encoding = True
    return newfile
コード例 #4
0
 def test_lookup_error(self):
     #sanity
     self.assertRaises(LookupError, codecs.lookup_error, "blah garbage xyz")
     def garbage_error1(someError): pass
     codecs.register_error("blah garbage xyz", garbage_error1)
     self.assertEqual(codecs.lookup_error("blah garbage xyz"), garbage_error1)
     def garbage_error2(someError): pass
     codecs.register_error("some other", garbage_error2)
     self.assertEqual(codecs.lookup_error("some other"), garbage_error2)
コード例 #5
0
def register_surrogateescape():
    """
    Registers the surrogateescape error handler on Python 2 (only)
    """
    if utils.PY3:
        return
    try:
        codecs.lookup_error(FS_ERRORS)
    except LookupError:
        codecs.register_error(FS_ERRORS, surrogateescape_handler)
コード例 #6
0
ファイル: frontend.py プロジェクト: Naviacom/Configurations
def validate_encoding_error_handler(setting, value, option_parser,
                                    config_parser=None, config_section=None):
    try:
        codecs.lookup_error(value)
    except LookupError:
        raise LookupError(
            'unknown encoding error handler: "%s" (choices: '
            '"strict", "ignore", "replace", "backslashreplace", '
            '"xmlcharrefreplace", and possibly others; see documentation for '
            'the Python ``codecs`` module)' % value)
    return value
コード例 #7
0
ファイル: test_codeccallbacks.py プロジェクト: B-Rich/breve
 def test_lookup(self):
     self.assertEquals(codecs.strict_errors, codecs.lookup_error("strict"))
     self.assertEquals(codecs.ignore_errors, codecs.lookup_error("ignore"))
     self.assertEquals(codecs.strict_errors, codecs.lookup_error("strict"))
     self.assertEquals(
         codecs.xmlcharrefreplace_errors,
         codecs.lookup_error("xmlcharrefreplace")
     )
     self.assertEquals(
         codecs.backslashreplace_errors,
         codecs.lookup_error("backslashreplace")
     )
コード例 #8
0
ファイル: test_codeccallbacks.py プロジェクト: BillyboyD/main
 def test_lookup(self):
     if test_support.due_to_ironpython_bug("http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=148421"):
         return
     self.assertEquals(codecs.strict_errors, codecs.lookup_error("strict"))
     self.assertEquals(codecs.ignore_errors, codecs.lookup_error("ignore"))
     self.assertEquals(codecs.strict_errors, codecs.lookup_error("strict"))
     self.assertEquals(
         codecs.xmlcharrefreplace_errors,
         codecs.lookup_error("xmlcharrefreplace")
     )
     self.assertEquals(
         codecs.backslashreplace_errors,
         codecs.lookup_error("backslashreplace")
     )
コード例 #9
0
def open_file_read_unicode(fname, which_error_handler="replace-if-possible"):
  """Open and read the file named 'fname', returning a Unicode string.

  It will also try to gloss over any Unicode-decoding errors that may occur,
  such as:
    UnicodeDecodeError: 'utf8' codec can't decode byte 0x97 in position 867373: invalid start byte

  It will return the string read (as a Unicode string object), plus a boolean
  value of whether the string contains non-ASCII Unicode.  It will also return
  a list of objects describing any Unicode-decoding errors that occurred.

  (So IN SUMMARY, it returns a tuple of THREE ITEMS.  I HOPE THIS IS CLEAR.)
  """

  error_handler = codecs.lookup_error(which_error_handler)
  error_handler.reset()

  # Note that we open the file with the encoding "utf-8-sig", since this
  # encoding will remove the BOM (byte-order mark) if present.
  # See http://docs.python.org/library/codecs.html ; search for "-sig".
  f = codecs.open(fname, encoding="utf-8-sig", errors=which_error_handler)

  # 's' will be a Unicode string, which may or may not contain non-ASCII.
  s = f.read()

  return (s, contains_non_ascii_unicode(s), error_handler.errors)
コード例 #10
0
ファイル: latscii.py プロジェクト: nickzuck007/python-bits
def latscii_error( uerr ):
    key = ord(uerr.object[uerr.start:uerr.end])
    try:
        return unichr(decoding_map[key]), uerr.end
    except KeyError:
        handler = codecs.lookup_error('replace')
        return handler(uerr)
コード例 #11
0
ファイル: frontend.py プロジェクト: Cheeseness/monotreme
def validate_encoding_error_handler(name, value):
    try:
        codecs.lookup_error(value)
    except AttributeError:              # prior to Python 2.3
        if value not in ('strict', 'ignore', 'replace'):
            raise (LookupError(
                'unknown encoding error handler: "%s" (choices: '
                '"strict", "ignore", or "replace")' % value),
                   None, sys.exc_info()[2])
    except LookupError:
        raise (LookupError(
            'unknown encoding error handler: "%s" (choices: '
            '"strict", "ignore", "replace", "backslashreplace", '
            '"xmlcharrefreplace", and possibly others; see documentation for '
            'the Python ``codecs`` module)' % value),
               None, sys.exc_info()[2])
    return value
コード例 #12
0
ファイル: ansi_ident.py プロジェクト: alampada/py-upsert
 def quote_ident(self, str):
     encodable = str.encode("utf-8", "strict").decode("utf-8")
     nul_index = encodable.find("\x00")
     if nul_index >= 0:
         error = UnicodeEncodeError("NUL-terminated utf-8", encodable, nul_index, nul_index + 1, "NUL not allowed")
         error_handler = codecs.lookup_error(errors)
         replacement, _ = error_handler(error)
         encodable = encodable.replace("\x00", replacement)
     return '"' + encodable.replace('"', '""') + '"'
コード例 #13
0
 def encode(self, input, errors='strict'):
     error = codecs.lookup_error(errors)
     def repl(match):
         start, end = match.span()
         return encoding_map.get(match.group()) or \
                error(UnicodeEncodeError(encoding, input, start, end, 
                                         "undefined conversion emoji"))[0]
     output = google_emoji_re.sub(repl, input)
     return (base_codec.encode(output, errors)[0], len(input))
コード例 #14
0
ファイル: __init__.py プロジェクト: silnrsi/palaso-python
 def convert(conv, data, final, errors='strict'):
     try:
         res = conv.convert(data, finished=final, 
                            options=Option.DontUseReplacementChar)
         return (res,len(res))
     except UnicodeEncodeError as uerr:
         rep,rp = codecs.lookup_error(errors)(uerr)
         try:
             prefix = conv.convert(uerr.object[:uerr.start] + rep, finished=final, 
                                   options=Option.DontUseReplacementChar)
         except UnicodeEncodeError:
             raise UnicodeEncodeError(*(uerr.args[:4] + ('cannot convert replacement %r to target encoding' % rep,)))
         suffix = Codec.convert(conv, data[rp:], final, errors)
         return (prefix+suffix[0],rp+suffix[1])
     except UnicodeDecodeError as uerr:
         rep,rp = codecs.lookup_error(errors)(uerr)
         prefix = conv.convert(uerr.object[:uerr.start], finished=final, 
                               options=Option.DontUseReplacementChar)
         suffix = Codec.convert(conv, data[rp:], final, errors)
         return (prefix+rep+suffix[0],rp+suffix[1])
コード例 #15
0
ファイル: stl.py プロジェクト: kgwhitmer/smartthings
def quote_identifier(s, errors="strict"):
  encodable = s.encode("utf-8", errors).decode("utf-8")
  nul_index = encodable.find("\x00")

  if nul_index >= 0:
    error = UnicodeEncodeError("NUL-terminated utf-8", encodable, nul_index, nul_index + 1, "NUL not allowed")
    error_handler = codecs.lookup_error(errors)
    replacement, _ = error_handler(error)
    encodable = encodable.replace("\x00", replacement)

  return "\"" + encodable.replace("\"", "\"\"") + "\""
コード例 #16
0
    def _quote_identifier(self, s, errors="ignore"):
        encodable = s.encode("utf-8", errors).decode("utf-8")

        nul_index = encodable.find("\x00")

        if nul_index >= 0:
            error = UnicodeEncodeError("utf-8", encodable, nul_index, nul_index + 1, "NUL not allowed")
            error_handler = codecs.lookup_error(errors)
            replacement, _ = error_handler(error)
            encodable = encodable.replace("\x00", replacement)

        return u'"' + encodable.replace('"', '""') + u'"'
コード例 #17
0
ファイル: codecs.py プロジェクト: osandov/molino
def imap_utf7_decode(input, errors='strict'):
    error = codecs.lookup_error(errors)
    output = []
    shifted = 0
    b64 = False
    i = 0
    while i < len(input):
        b = input[i]
        if b64:
            if b == 0x2d:  # '-'
                if shifted == i:
                    output.append('&')
                else:
                    dec = bytes(input[shifted:i]) + b'=' * ((4 - (i - shifted)) % 4)
                    try:
                        utf16 = base64.b64decode(dec, altchars=b'+,', validate=True)
                        output.append(utf16.decode('utf-16-be'))
                    except (binascii.Error, UnicodeDecodeError) as e:
                        if isinstance(e, binascii.Error):
                            reason = 'invalid Base64'
                        else:
                            reason = 'invalid UTF-16BE'
                        exc = UnicodeDecodeError('imap-utf-7', input, shifted - 1, i + 1,
                                                 reason)
                        replace, i = error(exc)
                        shifted = i
                        output.append(replace)
                        b64 = False
                        continue
                shifted = i + 1
                b64 = False
        else:
            if b == 0x26:  # '&'
                output.append(codecs.decode(input[shifted:i], 'ascii'))
                shifted = i + 1
                b64 = True
            if b < 0x20 or b > 0x7e:
                output.append(codecs.decode(input[shifted:i], 'ascii'))
                exc = UnicodeDecodeError('imap-utf-7', input, i, i + 1,
                                         'character must be Base64 encoded')
                replace, i = error(exc)
                shifted = i
                output.append(replace)
                continue
        i += 1
    if b64:
        exc = UnicodeDecodeError('imap-utf-7', input, len(input), len(input),
                                 'input does not end in US-ASCII')
        replace, cont = error(exc)
        output.append(replace)
    else:
        output.append(codecs.decode(input[shifted:], 'ascii'))
    return ''.join(output), len(input)
コード例 #18
0
ファイル: compat.py プロジェクト: ajelenak-thg/h5py
def _fscodec():
    encoding = sys.getfilesystemencoding()
    if encoding == 'mbcs':
        errors = 'strict'
    else:
        try:
            from codecs import lookup_error
            lookup_error('surrogateescape')
        except LookupError:
            errors = 'strict'
        else:
            errors = 'surrogateescape'

    def fsencode(filename):
        """
        Encode filename to the filesystem encoding with 'surrogateescape' error
        handler, return bytes unchanged. On Windows, use 'strict' error handler if
        the file system encoding is 'mbcs' (which is the default encoding).
        """
        if isinstance(filename, six.binary_type):
            return filename
        elif isinstance(filename, six.text_type):
            return filename.encode(encoding, errors)
        else:
            raise TypeError("expect bytes or str, not %s" % type(filename).__name__)

    def fsdecode(filename):
        """
        Decode filename from the filesystem encoding with 'surrogateescape' error
        handler, return str unchanged. On Windows, use 'strict' error handler if
        the file system encoding is 'mbcs' (which is the default encoding).
        """
        if isinstance(filename, six.text_type):
            return filename
        elif isinstance(filename, six.binary_type):
            return filename.decode(encoding, errors)
        else:
            raise TypeError("expect bytes or str, not %s" % type(filename).__name__)

    return fsencode, fsdecode
コード例 #19
0
def ignore_unicode_errors(errors='ignore'):
    """Overwrite the ``strict`` codecs error handler temporarily.

    This is useful e.g. if the engine truncates a string, which results in a
    string that contains a splitted multi-byte character at the end of the
    string.

    :param str errors:
        Error handler that will be looked up via :func:`codecs.lookup_error`.
    :raise LookupError:
        Raised if the error handler was not found.

    Example:

    .. code:: python

        import memory

        # Allocate four bytes to create an erroneous string
        ptr = memory.alloc(4)

        # Write data to the memory that will usually result in a
        # UnicodeDecodeError
        ptr.set_uchar(ord('a'), 0)
        ptr.set_uchar(ord('b'), 1)
        ptr.set_uchar(226, 2) # Add the invalid byte
        ptr.set_uchar(0, 3) # Indicate the end of the string

        with ignore_unicode_errors():
            # Read the data as a string. Now, it will only print 'ab', because
            # the invalid byte has been removed/ignored.
            print(ptr.get_string_array())
    """
    old_handler = codecs.lookup_error('strict')
    codecs.register_error('strict', codecs.lookup_error(errors))
    try:
        yield
    finally:
        codecs.register_error('strict', old_handler)
コード例 #20
0
 def test_fake_error_class(self):
     handlers = [
         codecs.strict_errors,
         codecs.ignore_errors,
         codecs.replace_errors,
         codecs.backslashreplace_errors,
         codecs.xmlcharrefreplace_errors,
         codecs.lookup_error('surrogateescape'),
         codecs.lookup_error('surrogatepass'),
     ]
     for cls in UnicodeEncodeError, UnicodeDecodeError, UnicodeTranslateError:
         class FakeUnicodeError(str):
             __class__ = cls
         for handler in handlers:
             with self.subTest(handler=handler, error_class=cls):
                 self.assertRaises(TypeError, handler, FakeUnicodeError())
         class FakeUnicodeError(Exception):
             __class__ = cls
         for handler in handlers:
             with self.subTest(handler=handler, error_class=cls):
                 with self.assertRaises((TypeError, FakeUnicodeError)):
                     handler(FakeUnicodeError())
コード例 #21
0
	def _quote_id(self, s, errors=u"strict"):
		encodable = s.encode("utf-8", errors).decode(u"utf-8")

		nul_index = encodable.find(u"\x00")

		if nul_index >= 0:
			error = UnicodeEncodeError(u"NUL-terminated utf-8", encodable,
									   nul_index, nul_index + 1, u"NUL not allowed")
			error_handler = codecs.lookup_error(errors)
			replacement, _ = error_handler(error)
			encodable = encodable.replace(u"\x00", replacement)

		return u"\"" + encodable.replace(u"\"", u"\"\"") + u"\""
コード例 #22
0
ファイル: latscii.py プロジェクト: romaia/stoq
    def latscii_error(uerr):
        text = uerr.object[uerr.start:uerr.end]
        ret = ''

        for c in text:
            key = ord(c)
            try:
                ret += unichr(decoding_map[key])
            except KeyError:
                handler = codecs.lookup_error('replace')
                return handler(uerr)

        return ret, uerr.end
コード例 #23
0
ファイル: sqlite3.py プロジェクト: DavideyLee/salt
def _quote(s, errors='strict'):
    encodable = s.encode('utf-8', errors).decode('utf-8')

    nul_index = encodable.find('\x00')

    if nul_index >= 0:
        error = UnicodeEncodeError('NUL-terminated utf-8', encodable,
                                   nul_index, nul_index + 1, 'NUL not allowed')
        error_handler = codecs.lookup_error(errors)
        replacement, _ = error_handler(error)
        encodable = encodable.replace('\x00', replacement)

    return '"' + encodable.replace('"', '""') + '"'
コード例 #24
0
 def __init__(self, transmogrifier, name, options, previous):
     self.previous = previous
     
     if options.get('from'):
         from_ = options['from'].strip().lower()
         if from_ != 'unicode':
             if from_ == 'default':
                 from_ = _get_default_encoding(transmogrifier.context)
             
             # Test if the decoder is available
             codecs.getdecoder(from_)
             
             self.from_ = from_
     
     self.from_error_handler = options.get(
         'from-error-handler', self.from_error_handler).strip().lower()
     # Test if the error handler is available
     codecs.lookup_error(self.from_error_handler)
     
     if options.get('to'):
         to = options['to'].strip().lower()
         if to != 'unicode':
             if to == 'default':
                 to = _get_default_encoding(transmogrifier.context)
             
             # Test if the encoder is available
             codecs.getencoder(to)
             
             self.to = to
     
     self.to_error_handler = options.get(
         'to-error-handler', self.to_error_handler).strip().lower()
     # Test if the error handler is available
     codecs.lookup_error(self.to_error_handler)
     
     self.matcher = Matcher(*options['keys'].splitlines())
     self.condition = Condition(options.get('condition', 'python:True'),
                                transmogrifier, name, options)
コード例 #25
0
ファイル: exiftool.py プロジェクト: dequis/auromat
def _fscodec():
    encoding = sys.getfilesystemencoding()
    errors = "strict"
    if encoding != "mbcs":
        try:
            codecs.lookup_error("surrogateescape")
        except LookupError:
            pass
        else:
            errors = "surrogateescape"

    def fsencode(filename):
        """
        Encode filename to the filesystem encoding with 'surrogateescape' error
        handler, return bytes unchanged. On Windows, use 'strict' error handler if
        the file system encoding is 'mbcs' (which is the default encoding).
        """
        if isinstance(filename, bytes):
            return filename
        else:
            return filename.encode(encoding, errors)

    return fsencode
コード例 #26
0
ファイル: import_dump.py プロジェクト: traqk/stack-mirror
def quote_identifier(s, errors="strict"):
    # Quotes a SQLite identifier. Source: http://stackoverflow.com/a/6701665
    encodable = s.encode("utf-8", errors).decode("utf-8")
    
    nul_index = encodable.find("\x00")
    
    if nul_index >= 0:
        error = UnicodeEncodeError("NUL-terminated utf-8", encodable,
                                   nul_index, nul_index + 1, "NUL not allowed")
        error_handler = codecs.lookup_error(errors)
        replacement, _ = error_handler(error)
        encodable = encodable.replace("\x00", replacement)
    
    return "\"" + encodable.replace("\"", "\"\"") + "\""
コード例 #27
0
ファイル: test_codeccallbacks.py プロジェクト: B-Rich/breve
 def test_longstrings(self):
     # test long strings to check for memory overflow problems
     errors = [ "strict", "ignore", "replace", "xmlcharrefreplace", "backslashreplace"]
     # register the handlers under different names,
     # to prevent the codec from recognizing the name
     for err in errors:
         codecs.register_error("test." + err, codecs.lookup_error(err))
     l = 1000
     errors += [ "test." + err for err in errors ]
     for uni in [ s*l for s in (u"x", u"\u3042", u"a\xe4") ]:
         for enc in ("ascii", "latin-1", "iso-8859-1", "iso-8859-15", "utf-8", "utf-7", "utf-16"):
             for err in errors:
                 try:
                     uni.encode(enc, err)
                 except UnicodeError:
                     pass
コード例 #28
0
ファイル: SqLite.py プロジェクト: briankracoff/MoodMusic
 def quote_identifier(s, errors="replace"):
     '''
     SqLite does not provide an identifier sanitizer so we use this method
     '''
     encodable = s.encode("utf-8", errors).decode("utf-8")
 
     nul_index = encodable.find("\x00")
 
     if nul_index >= 0:
         error = UnicodeEncodeError("NUL-terminated utf-8", encodable,
                                    nul_index, nul_index + 1, "NUL not allowed")
         error_handler = codecs.lookup_error(errors)
         replacement, _ = error_handler(error)
         encodable = encodable.replace("\x00", replacement)
 
     return "\"" + encodable.replace("\"", "\"\"") + "\""
コード例 #29
0
 def test_badandgoodsurrogateescapeexceptions(self):
     surrogateescape_errors = codecs.lookup_error('surrogateescape')
     # "surrogateescape" complains about a non-exception passed in
     self.assertRaises(
        TypeError,
        surrogateescape_errors,
        42
     )
     # "surrogateescape" complains about the wrong exception types
     self.assertRaises(
        TypeError,
        surrogateescape_errors,
        UnicodeError("ouch")
     )
     # "surrogateescape" can not be used for translating
     self.assertRaises(
         TypeError,
         surrogateescape_errors,
         UnicodeTranslateError("\udc80", 0, 1, "ouch")
     )
     # Use the correct exception
     for s in ("a", "\udc7f", "\udd00"):
         with self.subTest(str=s):
             self.assertRaises(
                 UnicodeEncodeError,
                 surrogateescape_errors,
                 UnicodeEncodeError("ascii", s, 0, 1, "ouch")
             )
     self.assertEqual(
         surrogateescape_errors(
             UnicodeEncodeError("ascii", "a\udc80b", 1, 2, "ouch")),
         (b"\x80", 2)
     )
     self.assertRaises(
         UnicodeDecodeError,
         surrogateescape_errors,
         UnicodeDecodeError("ascii", bytearray(b"a"), 0, 1, "ouch")
     )
     self.assertEqual(
         surrogateescape_errors(
             UnicodeDecodeError("ascii", bytearray(b"a\x80b"), 1, 2, "ouch")),
         ("\udc80", 2)
     )
コード例 #30
0
ファイル: _java.py プロジェクト: Britefury/jython
    def decode(self, input, errors='strict', final=True):
        error_function = codecs.lookup_error(errors)
        input_buffer = ByteBuffer.wrap(array('b', input))
        decoder = Charset.forName(self.encoding).newDecoder()
        output_buffer = CharBuffer.allocate(min(max(int(len(input) / 2), 256), 1024))
        builder = StringBuilder(int(decoder.averageCharsPerByte() * len(input)))

        while True:
            result = decoder.decode(input_buffer, output_buffer, False)
            pos = output_buffer.position()
            output_buffer.rewind()
            builder.append(output_buffer.subSequence(0, pos))
            if result.isUnderflow():
                if final:
                    _process_incomplete_decode(self.encoding, input, error_function, input_buffer, builder)
                break
            _process_decode_errors(self.encoding, input, result, error_function, input_buffer, builder)

        return builder.toString(), input_buffer.position()
コード例 #31
0
 def deserialize_numpy(self, str, numpy):
   """
   unpack serialized message in str into this message instance using numpy for array types
   :param str: byte array of serialized message, ``str``
   :param numpy: numpy python module
   """
   codecs.lookup_error("rosmsg").msg_type = self._type
   try:
     if self.header is None:
       self.header = std_msgs.msg.Header()
     if self.elements is None:
       self.elements = None
     end = 0
     _x = self
     start = end
     end += 12
     (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.header.frame_id = str[start:end]
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     self.elements = []
     for i in range(0, length):
       val1 = spencer_tracking_msgs.msg.CompositeDetectedPerson()
       _x = val1
       start = end
       end += 32
       (_x.composite_detection_id, _x.mean_confidence, _x.max_confidence, _x.min_confidence,) = _get_struct_Q3d().unpack(str[start:end])
       _v25 = val1.pose
       _v26 = _v25.pose
       _v27 = _v26.position
       _x = _v27
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       _v28 = _v26.orientation
       _x = _v28
       start = end
       end += 32
       (_x.x, _x.y, _x.z, _x.w,) = _get_struct_4d().unpack(str[start:end])
       start = end
       end += 288
       _v25.covariance = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=36)
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       val1.original_detections = []
       for i in range(0, length):
         val2 = spencer_tracking_msgs.msg.DetectedPerson()
         _x = val2
         start = end
         end += 16
         (_x.detection_id, _x.confidence,) = _get_struct_Qd().unpack(str[start:end])
         _v29 = val2.pose
         _v30 = _v29.pose
         _v31 = _v30.position
         _x = _v31
         start = end
         end += 24
         (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
         _v32 = _v30.orientation
         _x = _v32
         start = end
         end += 32
         (_x.x, _x.y, _x.z, _x.w,) = _get_struct_4d().unpack(str[start:end])
         start = end
         end += 288
         _v29.covariance = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=36)
         start = end
         end += 4
         (length,) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
           val2.modality = str[start:end].decode('utf-8', 'rosmsg')
         else:
           val2.modality = str[start:end]
         val1.original_detections.append(val2)
       self.elements.append(val1)
     return self
   except struct.error as e:
     raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #32
0
 def deserialize(self, str):
     """
 unpack serialized message in str into this message instance
 :param str: byte array of serialized message, ``str``
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.header is None:
             self.header = std_msgs.msg.Header()
         if self.status is None:
             self.status = actionlib_msgs.msg.GoalStatus()
         if self.feedback is None:
             self.feedback = control_msgs.msg.SingleJointPositionFeedback()
         end = 0
         _x = self
         start = end
         end += 12
         (
             _x.header.seq,
             _x.header.stamp.secs,
             _x.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 8
         (
             _x.status.goal_id.stamp.secs,
             _x.status.goal_id.stamp.nsecs,
         ) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.status.goal_id.id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.status.goal_id.id = str[start:end]
         start = end
         end += 1
         (self.status.status, ) = _get_struct_B().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.status.text = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.status.text = str[start:end]
         _x = self
         start = end
         end += 12
         (
             _x.feedback.header.seq,
             _x.feedback.header.stamp.secs,
             _x.feedback.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.feedback.header.frame_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.feedback.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 24
         (
             _x.feedback.position,
             _x.feedback.velocity,
             _x.feedback.error,
         ) = _get_struct_3d().unpack(str[start:end])
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #33
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.plan is None:
             self.plan = rtabmap_ros.msg.Path()
         end = 0
         _x = self
         start = end
         end += 12
         (
             _x.plan.header.seq,
             _x.plan.header.stamp.secs,
             _x.plan.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.plan.header.frame_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.plan.header.frame_id = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         pattern = '<%si' % length
         start = end
         s = struct.Struct(pattern)
         end += s.size
         self.plan.nodeIds = numpy.frombuffer(str[start:end],
                                              dtype=numpy.int32,
                                              count=length)
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         self.plan.poses = []
         for i in range(0, length):
             val1 = geometry_msgs.msg.Pose()
             _v7 = val1.position
             _x = _v7
             start = end
             end += 24
             (
                 _x.x,
                 _x.y,
                 _x.z,
             ) = _get_struct_3d().unpack(str[start:end])
             _v8 = val1.orientation
             _x = _v8
             start = end
             end += 32
             (
                 _x.x,
                 _x.y,
                 _x.z,
                 _x.w,
             ) = _get_struct_4d().unpack(str[start:end])
             self.plan.poses.append(val1)
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #34
0
def provide_surrogateescape():
    r"""
    Provide the ``surrogateescape`` error handler for bytes-to-unicode
    decoding.

    The source code of the function has been copied from
    https://bitbucket.org/haypo/misc/src/d76f4ff5d27c746c883d40160c8b4fb0891e79f2/python/surrogateescape.py?at=default
    and then adjusted, optimized and commented.  Original code was created by
    Victor Stinner and released by him under the Python license and the BSD
    2-clause license.

    The ``surrogateescape`` error handler is provided out-of-the-box in
    Python 3 but not in Python 2.  It can be used to convert arbitrary
    binary data to Unicode in a practically non-destructive way.

    .. seealso::

       https://www.python.org/dev/peps/pep-0383.

    This implementation (for Python 2) covers only the decoding part of
    the handler, i.e. the :class:`str`-to-:class:`unicode` conversion.
    The encoding (:class:`unicode`-to-:class:`str`) part is not
    implemented.  Note, however, that once we transformed a binary data
    into a *surrogate-escaped* Unicode data we can (in Python 2) freely
    encode/decode it (:class:`unicode`-to/from-:class:`str`), not using
    ``surrogateescape`` anymore, e.g.:

    >>> # We assume that the function has already been called --
    >>> # as it is imported and called in N6SDK/n6sdk/__init__.py
    >>> b = 'ołówek \xee\xdd'          # utf-8 text + some non-utf-8 mess
    >>> b
    'o\xc5\x82\xc3\xb3wek \xee\xdd'
    >>> u = b.decode('utf-8', 'surrogateescape')
    >>> u
    u'o\u0142\xf3wek \udcee\udcdd'
    >>> b2 = u.encode('utf-8')
    >>> b2                             # now all stuff is utf-8 encoded
    'o\xc5\x82\xc3\xb3wek \xed\xb3\xae\xed\xb3\x9d'
    >>> u2 = b2.decode('utf-8')
    >>> u2 == u
    True

    >>> u.encode('latin2',             # doctest: +IGNORE_EXCEPTION_DETAIL
    ...          'surrogateescape')    # does not work for *encoding*
    Traceback (most recent call last):
      ...
    TypeError: don't know how to handle UnicodeEncodeError in error callback

    This function is idempotent (i.e., it can be called safely multiple
    times -- because if the handler is already registered the function
    does not try to register it again) though it is not thread-safe
    (typically it does not matter as the function is supposed to be
    called somewhere at the beginning of program execution).

    .. note::

       This function is called automatically on first import of
       :mod:`n6sdk` module or any of its submodules.

    .. warning::

       In Python 3 (if you were using a Python-3-based application or
       script to handle data produced with Python 2), the ``utf-8``
       codec (as well as other ``utf-...`` codecs) does not decode
       *surrogate-escaped* data encoded to bytes with the Python 2's
       ``utf-8`` codec unless the ``surrogatepass`` error handler is
       used for decoding (on the Python 3 side).

    """
    def surrogateescape(
            exc,
            # to avoid namespace dict lookups:
            isinstance=isinstance,
            UnicodeDecodeError=UnicodeDecodeError,
            ord=ord,
            unichr=unichr,
            unicode_join=u''.join):
        if isinstance(exc, UnicodeDecodeError):
            decoded = []
            append_to_decoded = decoded.append
            for ch in exc.object[exc.start:exc.end]:
                code = ord(ch)
                if 0x80 <= code <= 0xFF:
                    append_to_decoded(unichr(0xDC00 + code))
                elif code <= 0x7F:
                    append_to_decoded(unichr(code))
                else:
                    raise exc
            decoded = unicode_join(decoded)
            return (decoded, exc.end)
        else:
            raise TypeError(
                "don't know how to handle {} in error callback".format(
                    type(exc).__name__))

    import codecs
    try:
        codecs.lookup_error('surrogateescape')
    except LookupError:
        codecs.register_error('surrogateescape', surrogateescape)
コード例 #35
0
ファイル: __init__.py プロジェクト: wwjiang007/renpy
    open = builtins.open


def compat_open(*args, **kwargs):
    if (sys._getframe(1).f_code.co_flags & 0xa000) == 0xa000:
        return open(*args, **kwargs)
    else:
        return python_open(*args, **kwargs)


################################################################################
# Make strict use surrogateescape error handling.
if PY2:
    import codecs

    strict_error = codecs.lookup_error("strict")
    codecs.register_error("python_strict", strict_error)
    surrogateescape_error = codecs.lookup_error("surrogateescape")
    codecs.register_error("strict", surrogateescape_error)

import renpy
renpy.update_path()

################################################################################
# String (text and binary) types and functions.

basestring = future.utils.string_types  # @ReservedAssignment
pystr = str
str = future.utils.text_type  # @ReservedAssignment
unicode = future.utils.text_type  # @ReservedAssignment
コード例 #36
0
 def deserialize_numpy(self, str, numpy):
   """
   unpack serialized message in str into this message instance using numpy for array types
   :param str: byte array of serialized message, ``str``
   :param numpy: numpy python module
   """
   codecs.lookup_error("rosmsg").msg_type = self._type
   try:
     if self.header is None:
       self.header = std_msgs.msg.Header()
     if self.goal_id is None:
       self.goal_id = actionlib_msgs.msg.GoalID()
     if self.goal is None:
       self.goal = part_fetcher.msg.PartFetcherGoal()
     end = 0
     _x = self
     start = end
     end += 12
     (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 8
     (_x.goal_id.stamp.secs, _x.goal_id.stamp.nsecs,) = _get_struct_2I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.goal_id.id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.goal_id.id = str[start:end]
     _x = self
     start = end
     end += 16
     (_x.goal.object_id, _x.goal.object_frame.header.seq, _x.goal.object_frame.header.stamp.secs, _x.goal.object_frame.header.stamp.nsecs,) = _get_struct_i3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.goal.object_frame.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.goal.object_frame.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 68
     (_x.goal.object_frame.pose.position.x, _x.goal.object_frame.pose.position.y, _x.goal.object_frame.pose.position.z, _x.goal.object_frame.pose.orientation.x, _x.goal.object_frame.pose.orientation.y, _x.goal.object_frame.pose.orientation.z, _x.goal.object_frame.pose.orientation.w, _x.goal.desired_frame.header.seq, _x.goal.desired_frame.header.stamp.secs, _x.goal.desired_frame.header.stamp.nsecs,) = _get_struct_7d3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.goal.desired_frame.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.goal.desired_frame.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 56
     (_x.goal.desired_frame.pose.position.x, _x.goal.desired_frame.pose.position.y, _x.goal.desired_frame.pose.position.z, _x.goal.desired_frame.pose.orientation.x, _x.goal.desired_frame.pose.orientation.y, _x.goal.desired_frame.pose.orientation.z, _x.goal.desired_frame.pose.orientation.w,) = _get_struct_7d().unpack(str[start:end])
     return self
   except struct.error as e:
     raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #37
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.joint_trajectory is None:
             self.joint_trajectory = trajectory_msgs.msg.JointTrajectory()
         if self.model_pose is None:
             self.model_pose = geometry_msgs.msg.Pose()
         end = 0
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.model_name = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.model_name = str[start:end]
         _x = self
         start = end
         end += 12
         (
             _x.joint_trajectory.header.seq,
             _x.joint_trajectory.header.stamp.secs,
             _x.joint_trajectory.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.joint_trajectory.header.frame_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.joint_trajectory.header.frame_id = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         self.joint_trajectory.joint_names = []
         for i in range(0, length):
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             start = end
             end += length
             if python3:
                 val1 = str[start:end].decode('utf-8', 'rosmsg')
             else:
                 val1 = str[start:end]
             self.joint_trajectory.joint_names.append(val1)
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         self.joint_trajectory.points = []
         for i in range(0, length):
             val1 = trajectory_msgs.msg.JointTrajectoryPoint()
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             pattern = '<%sd' % length
             start = end
             s = struct.Struct(pattern)
             end += s.size
             val1.positions = numpy.frombuffer(str[start:end],
                                               dtype=numpy.float64,
                                               count=length)
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             pattern = '<%sd' % length
             start = end
             s = struct.Struct(pattern)
             end += s.size
             val1.velocities = numpy.frombuffer(str[start:end],
                                                dtype=numpy.float64,
                                                count=length)
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             pattern = '<%sd' % length
             start = end
             s = struct.Struct(pattern)
             end += s.size
             val1.accelerations = numpy.frombuffer(str[start:end],
                                                   dtype=numpy.float64,
                                                   count=length)
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             pattern = '<%sd' % length
             start = end
             s = struct.Struct(pattern)
             end += s.size
             val1.effort = numpy.frombuffer(str[start:end],
                                            dtype=numpy.float64,
                                            count=length)
             _v4 = val1.time_from_start
             _x = _v4
             start = end
             end += 8
             (
                 _x.secs,
                 _x.nsecs,
             ) = _get_struct_2i().unpack(str[start:end])
             self.joint_trajectory.points.append(val1)
         _x = self
         start = end
         end += 58
         (
             _x.model_pose.position.x,
             _x.model_pose.position.y,
             _x.model_pose.position.z,
             _x.model_pose.orientation.x,
             _x.model_pose.orientation.y,
             _x.model_pose.orientation.z,
             _x.model_pose.orientation.w,
             _x.set_model_pose,
             _x.disable_physics_updates,
         ) = _get_struct_7d2B().unpack(str[start:end])
         self.set_model_pose = bool(self.set_model_pose)
         self.disable_physics_updates = bool(self.disable_physics_updates)
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #38
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.action_goal is None:
             self.action_goal = stdr_msgs.msg.DeleteRobotActionGoal()
         if self.action_result is None:
             self.action_result = stdr_msgs.msg.DeleteRobotActionResult()
         if self.action_feedback is None:
             self.action_feedback = stdr_msgs.msg.DeleteRobotActionFeedback(
             )
         end = 0
         _x = self
         start = end
         end += 12
         (
             _x.action_goal.header.seq,
             _x.action_goal.header.stamp.secs,
             _x.action_goal.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_goal.header.frame_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_goal.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 8
         (
             _x.action_goal.goal_id.stamp.secs,
             _x.action_goal.goal_id.stamp.nsecs,
         ) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_goal.goal_id.id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_goal.goal_id.id = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_goal.goal.name = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_goal.goal.name = str[start:end]
         _x = self
         start = end
         end += 12
         (
             _x.action_result.header.seq,
             _x.action_result.header.stamp.secs,
             _x.action_result.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_result.header.frame_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_result.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 8
         (
             _x.action_result.status.goal_id.stamp.secs,
             _x.action_result.status.goal_id.stamp.nsecs,
         ) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_result.status.goal_id.id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_result.status.goal_id.id = str[start:end]
         start = end
         end += 1
         (self.action_result.status.status, ) = _get_struct_B().unpack(
             str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_result.status.text = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_result.status.text = str[start:end]
         _x = self
         start = end
         end += 13
         (
             _x.action_result.result.success,
             _x.action_feedback.header.seq,
             _x.action_feedback.header.stamp.secs,
             _x.action_feedback.header.stamp.nsecs,
         ) = _get_struct_B3I().unpack(str[start:end])
         self.action_result.result.success = bool(
             self.action_result.result.success)
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_feedback.header.frame_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_feedback.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 8
         (
             _x.action_feedback.status.goal_id.stamp.secs,
             _x.action_feedback.status.goal_id.stamp.nsecs,
         ) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_feedback.status.goal_id.id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_feedback.status.goal_id.id = str[start:end]
         start = end
         end += 1
         (self.action_feedback.status.status, ) = _get_struct_B().unpack(
             str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_feedback.status.text = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_feedback.status.text = str[start:end]
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #39
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         end = 0
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.port_name = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.port_name = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.package_path = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.package_path = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.module_name = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.module_name = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.class_name = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.class_name = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.controller_name = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.controller_name = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         self.dependencies = []
         for i in range(0, length):
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             start = end
             end += length
             if python3:
                 val1 = str[start:end].decode('utf-8', 'rosmsg')
             else:
                 val1 = str[start:end]
             self.dependencies.append(val1)
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #40
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     if python3:
         codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.map is None:
             self.map = nav_msgs.msg.OccupancyGrid()
         end = 0
         _x = self
         start = end
         end += 12
         (
             _x.map.header.seq,
             _x.map.header.stamp.secs,
             _x.map.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.map.header.frame_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.map.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 76
         (
             _x.map.info.map_load_time.secs,
             _x.map.info.map_load_time.nsecs,
             _x.map.info.resolution,
             _x.map.info.width,
             _x.map.info.height,
             _x.map.info.origin.position.x,
             _x.map.info.origin.position.y,
             _x.map.info.origin.position.z,
             _x.map.info.origin.orientation.x,
             _x.map.info.origin.orientation.y,
             _x.map.info.origin.orientation.z,
             _x.map.info.origin.orientation.w,
         ) = _get_struct_2If2I7d().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         pattern = '<%sb' % length
         start = end
         s = struct.Struct(pattern)
         end += s.size
         self.map.data = numpy.frombuffer(str[start:end],
                                          dtype=numpy.int8,
                                          count=length)
         start = end
         end += 1
         (self.result, ) = _get_struct_B().unpack(str[start:end])
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #41
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.header is None:
             self.header = std_msgs.msg.Header()
         if self.status is None:
             self.status = actionlib_msgs.msg.GoalStatus()
         if self.feedback is None:
             self.feedback = ros_essentials_cpp.msg.FibonacciFeedback()
         end = 0
         _x = self
         start = end
         end += 12
         (
             _x.header.seq,
             _x.header.stamp.secs,
             _x.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 8
         (
             _x.status.goal_id.stamp.secs,
             _x.status.goal_id.stamp.nsecs,
         ) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.status.goal_id.id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.status.goal_id.id = str[start:end]
         start = end
         end += 1
         (self.status.status, ) = _get_struct_B().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.status.text = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.status.text = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         pattern = '<%si' % length
         start = end
         end += struct.calcsize(pattern)
         self.feedback.sequence = numpy.frombuffer(str[start:end],
                                                   dtype=numpy.int32,
                                                   count=length)
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #42
0
 def deserialize(self, str):
   """
   unpack serialized message in str into this message instance
   :param str: byte array of serialized message, ``str``
   """
   codecs.lookup_error("rosmsg").msg_type = self._type
   try:
     if self.header is None:
       self.header = std_msgs.msg.Header()
     if self.elements is None:
       self.elements = None
     end = 0
     _x = self
     start = end
     end += 12
     (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.header.frame_id = str[start:end]
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     self.elements = []
     for i in range(0, length):
       val1 = spencer_tracking_msgs.msg.CompositeDetectedPerson()
       _x = val1
       start = end
       end += 32
       (_x.composite_detection_id, _x.mean_confidence, _x.max_confidence, _x.min_confidence,) = _get_struct_Q3d().unpack(str[start:end])
       _v9 = val1.pose
       _v10 = _v9.pose
       _v11 = _v10.position
       _x = _v11
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       _v12 = _v10.orientation
       _x = _v12
       start = end
       end += 32
       (_x.x, _x.y, _x.z, _x.w,) = _get_struct_4d().unpack(str[start:end])
       start = end
       end += 288
       _v9.covariance = _get_struct_36d().unpack(str[start:end])
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       val1.original_detections = []
       for i in range(0, length):
         val2 = spencer_tracking_msgs.msg.DetectedPerson()
         _x = val2
         start = end
         end += 16
         (_x.detection_id, _x.confidence,) = _get_struct_Qd().unpack(str[start:end])
         _v13 = val2.pose
         _v14 = _v13.pose
         _v15 = _v14.position
         _x = _v15
         start = end
         end += 24
         (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
         _v16 = _v14.orientation
         _x = _v16
         start = end
         end += 32
         (_x.x, _x.y, _x.z, _x.w,) = _get_struct_4d().unpack(str[start:end])
         start = end
         end += 288
         _v13.covariance = _get_struct_36d().unpack(str[start:end])
         start = end
         end += 4
         (length,) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
           val2.modality = str[start:end].decode('utf-8', 'rosmsg')
         else:
           val2.modality = str[start:end]
         val1.original_detections.append(val2)
       self.elements.append(val1)
     return self
   except struct.error as e:
     raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #43
0
ファイル: common.py プロジェクト: saujanyanagpal104/pandas
def get_handle(
    path_or_buf: FilePathOrBuffer,
    mode: str,
    encoding: str | None = None,
    compression: CompressionOptions = None,
    memory_map: bool = False,
    is_text: bool = True,
    errors: str | None = None,
    storage_options: StorageOptions = None,
) -> IOHandles:
    """
    Get file handle for given path/buffer and mode.

    Parameters
    ----------
    path_or_buf : str or file handle
        File path or object.
    mode : str
        Mode to open path_or_buf with.
    encoding : str or None
        Encoding to use.
    compression : str or dict, default None
        If string, specifies compression mode. If dict, value at key 'method'
        specifies compression mode. Compression mode must be one of {'infer',
        'gzip', 'bz2', 'zip', 'xz', None}. If compression mode is 'infer'
        and `filepath_or_buffer` is path-like, then detect compression from
        the following extensions: '.gz', '.bz2', '.zip', or '.xz' (otherwise
        no compression). If dict and compression mode is one of
        {'zip', 'gzip', 'bz2'}, or inferred as one of the above,
        other entries passed as additional compression options.

        .. versionchanged:: 1.0.0

           May now be a dict with key 'method' as compression mode
           and other keys as compression options if compression
           mode is 'zip'.

        .. versionchanged:: 1.1.0

           Passing compression options as keys in dict is now
           supported for compression modes 'gzip' and 'bz2' as well as 'zip'.

    memory_map : bool, default False
        See parsers._parser_params for more information.
    is_text : bool, default True
        Whether the type of the content passed to the file/buffer is string or
        bytes. This is not the same as `"b" not in mode`. If a string content is
        passed to a binary file/buffer, a wrapper is inserted.
    errors : str, default 'strict'
        Specifies how encoding and decoding errors are to be handled.
        See the errors argument for :func:`open` for a full list
        of options.
    storage_options: StorageOptions = None
        Passed to _get_filepath_or_buffer

    .. versionchanged:: 1.2.0

    Returns the dataclass IOHandles
    """
    # Windows does not default to utf-8. Set to utf-8 for a consistent behavior
    encoding = encoding or "utf-8"

    # read_csv does not know whether the buffer is opened in binary/text mode
    if _is_binary_mode(path_or_buf, mode) and "b" not in mode:
        mode += "b"

    # validate encoding and errors
    if isinstance(encoding, str):
        codecs.lookup(encoding)
    if isinstance(errors, str):
        codecs.lookup_error(errors)

    # open URLs
    ioargs = _get_filepath_or_buffer(
        path_or_buf,
        encoding=encoding,
        compression=compression,
        mode=mode,
        storage_options=storage_options,
    )

    handle = ioargs.filepath_or_buffer
    handles: list[Buffer]

    # memory mapping needs to be the first step
    handle, memory_map, handles = _maybe_memory_map(
        handle,
        memory_map,
        ioargs.encoding,
        ioargs.mode,
        errors,
        ioargs.compression["method"] not in _compression_to_extension,
    )

    is_path = isinstance(handle, str)
    compression_args = dict(ioargs.compression)
    compression = compression_args.pop("method")

    # Only for write methods
    if "r" not in mode and is_path:
        check_parent_directory(str(handle))

    if compression:
        # compression libraries do not like an explicit text-mode
        ioargs.mode = ioargs.mode.replace("t", "")

        # GZ Compression
        if compression == "gzip":
            if is_path:
                assert isinstance(handle, str)
                handle = gzip.GzipFile(
                    filename=handle,
                    mode=ioargs.mode,
                    **compression_args,
                )
            else:
                handle = gzip.GzipFile(
                    # error: Argument "fileobj" to "GzipFile" has incompatible type
                    # "Union[str, Union[IO[Any], RawIOBase, BufferedIOBase, TextIOBase,
                    # TextIOWrapper, mmap]]"; expected "Optional[IO[bytes]]"
                    fileobj=handle,  # type: ignore[arg-type]
                    mode=ioargs.mode,
                    **compression_args,
                )

        # BZ Compression
        elif compression == "bz2":
            handle = bz2.BZ2File(
                # Argument 1 to "BZ2File" has incompatible type "Union[str,
                # Union[IO[Any], RawIOBase, BufferedIOBase, TextIOBase, TextIOWrapper,
                # mmap]]"; expected "Union[Union[str, bytes, _PathLike[str],
                # _PathLike[bytes]], IO[bytes]]"
                handle,  # type: ignore[arg-type]
                mode=ioargs.mode,
                **compression_args,
            )

        # ZIP Compression
        elif compression == "zip":
            handle = _BytesZipFile(handle, ioargs.mode, **compression_args)
            if handle.mode == "r":
                handles.append(handle)
                zip_names = handle.namelist()
                if len(zip_names) == 1:
                    handle = handle.open(zip_names.pop())
                elif len(zip_names) == 0:
                    raise ValueError(
                        f"Zero files found in ZIP file {path_or_buf}")
                else:
                    raise ValueError("Multiple files found in ZIP file. "
                                     f"Only one file per ZIP: {zip_names}")

        # XZ Compression
        elif compression == "xz":
            handle = get_lzma_file(lzma)(handle, ioargs.mode)

        # Unrecognized Compression
        else:
            msg = f"Unrecognized compression type: {compression}"
            raise ValueError(msg)

        assert not isinstance(handle, str)
        handles.append(handle)

    elif isinstance(handle, str):
        # Check whether the filename is to be opened in binary mode.
        # Binary mode does not support 'encoding' and 'newline'.
        if ioargs.encoding and "b" not in ioargs.mode:
            # Encoding
            handle = open(
                handle,
                ioargs.mode,
                encoding=ioargs.encoding,
                errors=errors,
                newline="",
            )
        else:
            # Binary mode
            handle = open(handle, ioargs.mode)
        handles.append(handle)

    # Convert BytesIO or file objects passed with an encoding
    is_wrapped = False
    if not is_text and ioargs.mode == "rb" and isinstance(handle, TextIOBase):
        handle = BytesIOWrapper(
            handle,
            encoding=ioargs.encoding,
        )
        handles.append(handle)
        # the (text) handle is always provided by the caller
        # since get_handle would have opened it in binary mode
        is_wrapped = True
    elif is_text and (compression or _is_binary_mode(handle, ioargs.mode)):
        handle = TextIOWrapper(
            # error: Argument 1 to "TextIOWrapper" has incompatible type
            # "Union[IO[bytes], IO[Any], RawIOBase, BufferedIOBase, TextIOBase, mmap]";
            # expected "IO[bytes]"
            handle,  # type: ignore[arg-type]
            encoding=ioargs.encoding,
            errors=errors,
            newline="",
        )
        handles.append(handle)
        # only marked as wrapped when the caller provided a handle
        is_wrapped = not (isinstance(ioargs.filepath_or_buffer, str)
                          or ioargs.should_close)

    if "r" in ioargs.mode and not hasattr(handle, "read"):
        raise TypeError("Expected file path name or file-like object, "
                        f"got {type(ioargs.filepath_or_buffer)} type")

    handles.reverse()  # close the most recently added buffer first
    if ioargs.should_close:
        assert not isinstance(ioargs.filepath_or_buffer, str)
        handles.append(ioargs.filepath_or_buffer)

    assert not isinstance(handle, str)
    return IOHandles(
        handle=handle,
        created_handles=handles,
        is_wrapped=is_wrapped,
        is_mmap=memory_map,
        compression=ioargs.compression,
    )
コード例 #44
0
 def deserialize_numpy(self, str, numpy):
   """
   unpack serialized message in str into this message instance using numpy for array types
   :param str: byte array of serialized message, ``str``
   :param numpy: numpy python module
   """
   codecs.lookup_error("rosmsg").msg_type = self._type
   try:
     if self.action_goal is None:
       self.action_goal = raspimouse_ros.msg.MusicActionGoal()
     if self.action_result is None:
       self.action_result = raspimouse_ros.msg.MusicActionResult()
     if self.action_feedback is None:
       self.action_feedback = raspimouse_ros.msg.MusicActionFeedback()
     end = 0
     _x = self
     start = end
     end += 12
     (_x.action_goal.header.seq, _x.action_goal.header.stamp.secs, _x.action_goal.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_goal.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_goal.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 8
     (_x.action_goal.goal_id.stamp.secs, _x.action_goal.goal_id.stamp.nsecs,) = _get_struct_2I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_goal.goal_id.id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_goal.goal_id.id = str[start:end]
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     pattern = '<%sH'%length
     start = end
     s = struct.Struct(pattern)
     end += s.size
     self.action_goal.goal.freqs = numpy.frombuffer(str[start:end], dtype=numpy.uint16, count=length)
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     pattern = '<%sf'%length
     start = end
     s = struct.Struct(pattern)
     end += s.size
     self.action_goal.goal.durations = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length)
     _x = self
     start = end
     end += 12
     (_x.action_result.header.seq, _x.action_result.header.stamp.secs, _x.action_result.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_result.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_result.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 8
     (_x.action_result.status.goal_id.stamp.secs, _x.action_result.status.goal_id.stamp.nsecs,) = _get_struct_2I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_result.status.goal_id.id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_result.status.goal_id.id = str[start:end]
     start = end
     end += 1
     (self.action_result.status.status,) = _get_struct_B().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_result.status.text = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_result.status.text = str[start:end]
     _x = self
     start = end
     end += 13
     (_x.action_result.result.finished, _x.action_feedback.header.seq, _x.action_feedback.header.stamp.secs, _x.action_feedback.header.stamp.nsecs,) = _get_struct_B3I().unpack(str[start:end])
     self.action_result.result.finished = bool(self.action_result.result.finished)
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_feedback.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_feedback.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 8
     (_x.action_feedback.status.goal_id.stamp.secs, _x.action_feedback.status.goal_id.stamp.nsecs,) = _get_struct_2I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_feedback.status.goal_id.id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_feedback.status.goal_id.id = str[start:end]
     start = end
     end += 1
     (self.action_feedback.status.status,) = _get_struct_B().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_feedback.status.text = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_feedback.status.text = str[start:end]
     start = end
     end += 4
     (self.action_feedback.feedback.remaining_steps,) = _get_struct_I().unpack(str[start:end])
     return self
   except struct.error as e:
     raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #45
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.models is None:
             self.models = None
         if self.pose is None:
             self.pose = geometry_msgs.msg.Pose()
         end = 0
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         self.models = []
         for i in range(0, length):
             val1 = nist_gear.msg.Model()
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             start = end
             end += length
             if python3:
                 val1.type = str[start:end].decode('utf-8', 'rosmsg')
             else:
                 val1.type = str[start:end]
             _v10 = val1.pose
             _v11 = _v10.position
             _x = _v11
             start = end
             end += 24
             (
                 _x.x,
                 _x.y,
                 _x.z,
             ) = _get_struct_3d().unpack(str[start:end])
             _v12 = _v10.orientation
             _x = _v12
             start = end
             end += 32
             (
                 _x.x,
                 _x.y,
                 _x.z,
                 _x.w,
             ) = _get_struct_4d().unpack(str[start:end])
             self.models.append(val1)
         _x = self
         start = end
         end += 56
         (
             _x.pose.position.x,
             _x.pose.position.y,
             _x.pose.position.z,
             _x.pose.orientation.x,
             _x.pose.orientation.y,
             _x.pose.orientation.z,
             _x.pose.orientation.w,
         ) = _get_struct_7d().unpack(str[start:end])
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #46
0
ファイル: _AgentStates.py プロジェクト: charlesgyc/Guidedog
 def deserialize(self, str):
   """
   unpack serialized message in str into this message instance
   :param str: byte array of serialized message, ``str``
   """
   codecs.lookup_error("rosmsg").msg_type = self._type
   try:
     if self.header is None:
       self.header = std_msgs.msg.Header()
     if self.agent_states is None:
       self.agent_states = None
     end = 0
     _x = self
     start = end
     end += 12
     (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.header.frame_id = str[start:end]
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     self.agent_states = []
     for i in range(0, length):
       val1 = pedsim_msgs.msg.AgentState()
       _v17 = val1.header
       start = end
       end += 4
       (_v17.seq,) = _get_struct_I().unpack(str[start:end])
       _v18 = _v17.stamp
       _x = _v18
       start = end
       end += 8
       (_x.secs, _x.nsecs,) = _get_struct_2I().unpack(str[start:end])
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         _v17.frame_id = str[start:end].decode('utf-8', 'rosmsg')
       else:
         _v17.frame_id = str[start:end]
       _x = val1
       start = end
       end += 10
       (_x.id, _x.type,) = _get_struct_QH().unpack(str[start:end])
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1.social_state = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1.social_state = str[start:end]
       _v19 = val1.pose
       _v20 = _v19.position
       _x = _v20
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       _v21 = _v19.orientation
       _x = _v21
       start = end
       end += 32
       (_x.x, _x.y, _x.z, _x.w,) = _get_struct_4d().unpack(str[start:end])
       _v22 = val1.twist
       _v23 = _v22.linear
       _x = _v23
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       _v24 = _v22.angular
       _x = _v24
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       _v25 = val1.forces
       _v26 = _v25.desired_force
       _x = _v26
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       _v27 = _v25.obstacle_force
       _x = _v27
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       _v28 = _v25.social_force
       _x = _v28
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       _v29 = _v25.group_coherence_force
       _x = _v29
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       _v30 = _v25.group_gaze_force
       _x = _v30
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       _v31 = _v25.group_repulsion_force
       _x = _v31
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       _v32 = _v25.random_force
       _x = _v32
       start = end
       end += 24
       (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
       self.agent_states.append(val1)
     return self
   except struct.error as e:
     raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #47
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.header is None:
             self.header = std_msgs.msg.Header()
         if self.status is None:
             self.status = actionlib_msgs.msg.GoalStatus()
         if self.feedback is None:
             self.feedback = movo_arc_lib.msg.single_task_move_safeFeedback(
             )
         end = 0
         _x = self
         start = end
         end += 12
         (
             _x.header.seq,
             _x.header.stamp.secs,
             _x.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 8
         (
             _x.status.goal_id.stamp.secs,
             _x.status.goal_id.stamp.nsecs,
         ) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.status.goal_id.id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.status.goal_id.id = str[start:end]
         start = end
         end += 1
         (self.status.status, ) = _get_struct_B().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.status.text = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.status.text = str[start:end]
         start = end
         end += 1
         (self.feedback.NotImplemented, ) = _get_struct_B().unpack(
             str[start:end])
         self.feedback.NotImplemented = bool(self.feedback.NotImplemented)
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #48
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.header is None:
             self.header = imc_ros_msgs.msg.Header()
         if self.state is None:
             self.state = std_msgs.msg.UInt8()
         if self.plan_id is None:
             self.plan_id = std_msgs.msg.String()
         if self.plan_eta is None:
             self.plan_eta = std_msgs.msg.Int32()
         if self.plan_progress is None:
             self.plan_progress = std_msgs.msg.Float32()
         if self.man_id is None:
             self.man_id = std_msgs.msg.String()
         if self.man_type is None:
             self.man_type = std_msgs.msg.UInt16()
         if self.man_eta is None:
             self.man_eta = std_msgs.msg.Int32()
         if self.last_outcome is None:
             self.last_outcome = std_msgs.msg.UInt8()
         end = 0
         _x = self
         start = end
         end += 12
         (
             _x.header.rosheader.seq,
             _x.header.rosheader.stamp.secs,
             _x.header.rosheader.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.header.rosheader.frame_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.header.rosheader.frame_id = str[start:end]
         _x = self
         start = end
         end += 21
         (
             _x.header.sync.data,
             _x.header.mgid.data,
             _x.header.size.data,
             _x.header.timestamp.data,
             _x.header.src.data,
             _x.header.src_ent.data,
             _x.header.dst.data,
             _x.header.dst_ent.data,
             _x.state.data,
         ) = _get_struct_3HdHBH2B().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.plan_id.data = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.plan_id.data = str[start:end]
         _x = self
         start = end
         end += 8
         (
             _x.plan_eta.data,
             _x.plan_progress.data,
         ) = _get_struct_if().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.man_id.data = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.man_id.data = str[start:end]
         _x = self
         start = end
         end += 7
         (
             _x.man_type.data,
             _x.man_eta.data,
             _x.last_outcome.data,
         ) = _get_struct_HiB().unpack(str[start:end])
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #49
0
 def deserialize_numpy(self, str, numpy):
   """
   unpack serialized message in str into this message instance using numpy for array types
   :param str: byte array of serialized message, ``str``
   :param numpy: numpy python module
   """
   codecs.lookup_error("rosmsg").msg_type = self._type
   try:
     if self.action_goal is None:
       self.action_goal = part_fetcher.msg.PartFetcherActionGoal()
     if self.action_result is None:
       self.action_result = part_fetcher.msg.PartFetcherActionResult()
     if self.action_feedback is None:
       self.action_feedback = part_fetcher.msg.PartFetcherActionFeedback()
     end = 0
     _x = self
     start = end
     end += 12
     (_x.action_goal.header.seq, _x.action_goal.header.stamp.secs, _x.action_goal.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_goal.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_goal.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 8
     (_x.action_goal.goal_id.stamp.secs, _x.action_goal.goal_id.stamp.nsecs,) = _get_struct_2I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_goal.goal_id.id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_goal.goal_id.id = str[start:end]
     _x = self
     start = end
     end += 16
     (_x.action_goal.goal.object_id, _x.action_goal.goal.object_frame.header.seq, _x.action_goal.goal.object_frame.header.stamp.secs, _x.action_goal.goal.object_frame.header.stamp.nsecs,) = _get_struct_i3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_goal.goal.object_frame.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_goal.goal.object_frame.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 68
     (_x.action_goal.goal.object_frame.pose.position.x, _x.action_goal.goal.object_frame.pose.position.y, _x.action_goal.goal.object_frame.pose.position.z, _x.action_goal.goal.object_frame.pose.orientation.x, _x.action_goal.goal.object_frame.pose.orientation.y, _x.action_goal.goal.object_frame.pose.orientation.z, _x.action_goal.goal.object_frame.pose.orientation.w, _x.action_goal.goal.desired_frame.header.seq, _x.action_goal.goal.desired_frame.header.stamp.secs, _x.action_goal.goal.desired_frame.header.stamp.nsecs,) = _get_struct_7d3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_goal.goal.desired_frame.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_goal.goal.desired_frame.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 68
     (_x.action_goal.goal.desired_frame.pose.position.x, _x.action_goal.goal.desired_frame.pose.position.y, _x.action_goal.goal.desired_frame.pose.position.z, _x.action_goal.goal.desired_frame.pose.orientation.x, _x.action_goal.goal.desired_frame.pose.orientation.y, _x.action_goal.goal.desired_frame.pose.orientation.z, _x.action_goal.goal.desired_frame.pose.orientation.w, _x.action_result.header.seq, _x.action_result.header.stamp.secs, _x.action_result.header.stamp.nsecs,) = _get_struct_7d3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_result.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_result.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 8
     (_x.action_result.status.goal_id.stamp.secs, _x.action_result.status.goal_id.stamp.nsecs,) = _get_struct_2I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_result.status.goal_id.id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_result.status.goal_id.id = str[start:end]
     start = end
     end += 1
     (self.action_result.status.status,) = _get_struct_B().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_result.status.text = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_result.status.text = str[start:end]
     _x = self
     start = end
     end += 16
     (_x.action_result.result.rtn_code, _x.action_feedback.header.seq, _x.action_feedback.header.stamp.secs, _x.action_feedback.header.stamp.nsecs,) = _get_struct_i3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_feedback.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_feedback.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 8
     (_x.action_feedback.status.goal_id.stamp.secs, _x.action_feedback.status.goal_id.stamp.nsecs,) = _get_struct_2I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_feedback.status.goal_id.id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_feedback.status.goal_id.id = str[start:end]
     start = end
     end += 1
     (self.action_feedback.status.status,) = _get_struct_B().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_feedback.status.text = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_feedback.status.text = str[start:end]
     start = end
     end += 4
     (self.action_feedback.feedback.fdbk,) = _get_struct_i().unpack(str[start:end])
     return self
   except struct.error as e:
     raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #50
0
 def deserialize_numpy(self, str, numpy):
   """
   unpack serialized message in str into this message instance using numpy for array types
   :param str: byte array of serialized message, ``str``
   :param numpy: numpy python module
   """
   codecs.lookup_error("rosmsg").msg_type = self._type
   try:
     if self.publisher is None:
       self.publisher = None
     if self.subscriber is None:
       self.subscriber = None
     if self.services is None:
       self.services = None
     end = 0
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.masteruri = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.masteruri = str[start:end]
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     self.nodes = []
     for i in range(0, length):
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1 = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1 = str[start:end]
       self.nodes.append(val1)
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     self.publisher = []
     for i in range(0, length):
       val1 = fkie_multimaster_msgs.msg.SyncTopicInfo()
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1.topic = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1.topic = str[start:end]
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1.node = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1.node = str[start:end]
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1.nodeuri = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1.nodeuri = str[start:end]
       self.publisher.append(val1)
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     self.subscriber = []
     for i in range(0, length):
       val1 = fkie_multimaster_msgs.msg.SyncTopicInfo()
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1.topic = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1.topic = str[start:end]
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1.node = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1.node = str[start:end]
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1.nodeuri = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1.nodeuri = str[start:end]
       self.subscriber.append(val1)
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     self.services = []
     for i in range(0, length):
       val1 = fkie_multimaster_msgs.msg.SyncServiceInfo()
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1.service = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1.service = str[start:end]
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1.serviceuri = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1.serviceuri = str[start:end]
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1.node = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1.node = str[start:end]
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         val1.nodeuri = str[start:end].decode('utf-8', 'rosmsg')
       else:
         val1.nodeuri = str[start:end]
       self.services.append(val1)
     return self
   except struct.error as e:
     raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #51
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.action_goal is None:
             self.action_goal = pal_interaction_msgs.msg.ASRFileActionGoal()
         if self.action_result is None:
             self.action_result = pal_interaction_msgs.msg.ASRFileActionResult(
             )
         if self.action_feedback is None:
             self.action_feedback = pal_interaction_msgs.msg.ASRFileActionFeedback(
             )
         end = 0
         _x = self
         start = end
         end += 12
         (
             _x.action_goal.header.seq,
             _x.action_goal.header.stamp.secs,
             _x.action_goal.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_goal.header.frame_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_goal.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 8
         (
             _x.action_goal.goal_id.stamp.secs,
             _x.action_goal.goal_id.stamp.nsecs,
         ) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_goal.goal_id.id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_goal.goal_id.id = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_goal.goal.file = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_goal.goal.file = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_goal.goal.lang_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_goal.goal.lang_id = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_goal.goal.grammar = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_goal.goal.grammar = str[start:end]
         _x = self
         start = end
         end += 12
         (
             _x.action_result.header.seq,
             _x.action_result.header.stamp.secs,
             _x.action_result.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_result.header.frame_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_result.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 8
         (
             _x.action_result.status.goal_id.stamp.secs,
             _x.action_result.status.goal_id.stamp.nsecs,
         ) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_result.status.goal_id.id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_result.status.goal_id.id = str[start:end]
         start = end
         end += 1
         (self.action_result.status.status, ) = _get_struct_B().unpack(
             str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_result.status.text = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_result.status.text = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_result.result.file = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_result.result.file = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_result.result.msg = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_result.result.msg = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         self.action_result.result.recognised_utterances = []
         for i in range(0, length):
             val1 = pal_interaction_msgs.msg.asrresult()
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             start = end
             end += length
             if python3:
                 val1.text = str[start:end].decode('utf-8', 'rosmsg')
             else:
                 val1.text = str[start:end]
             start = end
             end += 1
             (val1.confidence, ) = _get_struct_b().unpack(str[start:end])
             _v7 = val1.start
             _x = _v7
             start = end
             end += 8
             (
                 _x.secs,
                 _x.nsecs,
             ) = _get_struct_2I().unpack(str[start:end])
             _v8 = val1.end
             _x = _v8
             start = end
             end += 8
             (
                 _x.secs,
                 _x.nsecs,
             ) = _get_struct_2I().unpack(str[start:end])
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             val1.tags = []
             for i in range(0, length):
                 val2 = pal_interaction_msgs.msg.actiontag()
                 start = end
                 end += 4
                 (length, ) = _struct_I.unpack(str[start:end])
                 start = end
                 end += length
                 if python3:
                     val2.key = str[start:end].decode('utf-8', 'rosmsg')
                 else:
                     val2.key = str[start:end]
                 start = end
                 end += 4
                 (length, ) = _struct_I.unpack(str[start:end])
                 start = end
                 end += length
                 if python3:
                     val2.value = str[start:end].decode('utf-8', 'rosmsg')
                 else:
                     val2.value = str[start:end]
                 val1.tags.append(val2)
             self.action_result.result.recognised_utterances.append(val1)
         _x = self
         start = end
         end += 12
         (
             _x.action_feedback.header.seq,
             _x.action_feedback.header.stamp.secs,
             _x.action_feedback.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_feedback.header.frame_id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_feedback.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 8
         (
             _x.action_feedback.status.goal_id.stamp.secs,
             _x.action_feedback.status.goal_id.stamp.nsecs,
         ) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_feedback.status.goal_id.id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_feedback.status.goal_id.id = str[start:end]
         start = end
         end += 1
         (self.action_feedback.status.status, ) = _get_struct_B().unpack(
             str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_feedback.status.text = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.action_feedback.status.text = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.action_feedback.feedback.recognised_utterance.text = str[
                 start:end].decode('utf-8', 'rosmsg')
         else:
             self.action_feedback.feedback.recognised_utterance.text = str[
                 start:end]
         _x = self
         start = end
         end += 17
         (
             _x.action_feedback.feedback.recognised_utterance.confidence,
             _x.action_feedback.feedback.recognised_utterance.start.secs,
             _x.action_feedback.feedback.recognised_utterance.start.nsecs,
             _x.action_feedback.feedback.recognised_utterance.end.secs,
             _x.action_feedback.feedback.recognised_utterance.end.nsecs,
         ) = _get_struct_b4I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         self.action_feedback.feedback.recognised_utterance.tags = []
         for i in range(0, length):
             val1 = pal_interaction_msgs.msg.actiontag()
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             start = end
             end += length
             if python3:
                 val1.key = str[start:end].decode('utf-8', 'rosmsg')
             else:
                 val1.key = str[start:end]
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             start = end
             end += length
             if python3:
                 val1.value = str[start:end].decode('utf-8', 'rosmsg')
             else:
                 val1.value = str[start:end]
             self.action_feedback.feedback.recognised_utterance.tags.append(
                 val1)
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #52
0
 def deserialize_numpy(self, str, numpy):
   """
   unpack serialized message in str into this message instance using numpy for array types
   :param str: byte array of serialized message, ``str``
   :param numpy: numpy python module
   """
   codecs.lookup_error("rosmsg").msg_type = self._type
   try:
     if self.action_goal is None:
       self.action_goal = pkg_ros_iot_bridge.msg.msgRosIotActionGoal()
     if self.action_result is None:
       self.action_result = pkg_ros_iot_bridge.msg.msgRosIotActionResult()
     if self.action_feedback is None:
       self.action_feedback = pkg_ros_iot_bridge.msg.msgRosIotActionFeedback()
     end = 0
     _x = self
     start = end
     end += 12
     (_x.action_goal.header.seq, _x.action_goal.header.stamp.secs, _x.action_goal.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_goal.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_goal.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 8
     (_x.action_goal.goal_id.stamp.secs, _x.action_goal.goal_id.stamp.nsecs,) = _get_struct_2I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_goal.goal_id.id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_goal.goal_id.id = str[start:end]
     _x = self
     start = end
     end += 14
     (_x.action_goal.goal.distance, _x.action_goal.goal.angle, _x.action_result.header.seq, _x.action_result.header.stamp.secs, _x.action_result.header.stamp.nsecs,) = _get_struct_2b3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_result.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_result.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 8
     (_x.action_result.status.goal_id.stamp.secs, _x.action_result.status.goal_id.stamp.nsecs,) = _get_struct_2I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_result.status.goal_id.id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_result.status.goal_id.id = str[start:end]
     start = end
     end += 1
     (self.action_result.status.status,) = _get_struct_B().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_result.status.text = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_result.status.text = str[start:end]
     _x = self
     start = end
     end += 15
     (_x.action_result.result.final_x, _x.action_result.result.final_y, _x.action_result.result.final_theta, _x.action_feedback.header.seq, _x.action_feedback.header.stamp.secs, _x.action_feedback.header.stamp.nsecs,) = _get_struct_3b3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_feedback.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_feedback.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 8
     (_x.action_feedback.status.goal_id.stamp.secs, _x.action_feedback.status.goal_id.stamp.nsecs,) = _get_struct_2I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_feedback.status.goal_id.id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_feedback.status.goal_id.id = str[start:end]
     start = end
     end += 1
     (self.action_feedback.status.status,) = _get_struct_B().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.action_feedback.status.text = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.action_feedback.status.text = str[start:end]
     _x = self
     start = end
     end += 3
     (_x.action_feedback.feedback.cur_x, _x.action_feedback.feedback.cur_y, _x.action_feedback.feedback.cur_theta,) = _get_struct_3b().unpack(str[start:end])
     return self
   except struct.error as e:
     raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #53
0
 def deserialize_numpy(self, str, numpy):
   """
   unpack serialized message in str into this message instance using numpy for array types
   :param str: byte array of serialized message, ``str``
   :param numpy: numpy python module
   """
   codecs.lookup_error("rosmsg").msg_type = self._type
   try:
     if self.header is None:
       self.header = std_msgs.msg.Header()
     if self.direction is None:
       self.direction = geometry_msgs.msg.Vector3()
     if self.normal is None:
       self.normal = geometry_msgs.msg.Vector3()
     if self.palmpos is None:
       self.palmpos = geometry_msgs.msg.Point()
     if self.ypr is None:
       self.ypr = geometry_msgs.msg.Vector3()
     if self.thumb_metacarpal is None:
       self.thumb_metacarpal = geometry_msgs.msg.Point()
     if self.thumb_proximal is None:
       self.thumb_proximal = geometry_msgs.msg.Point()
     if self.thumb_intermediate is None:
       self.thumb_intermediate = geometry_msgs.msg.Point()
     if self.thumb_distal is None:
       self.thumb_distal = geometry_msgs.msg.Point()
     if self.thumb_tip is None:
       self.thumb_tip = geometry_msgs.msg.Point()
     if self.index_metacarpal is None:
       self.index_metacarpal = geometry_msgs.msg.Point()
     if self.index_proximal is None:
       self.index_proximal = geometry_msgs.msg.Point()
     if self.index_intermediate is None:
       self.index_intermediate = geometry_msgs.msg.Point()
     if self.index_distal is None:
       self.index_distal = geometry_msgs.msg.Point()
     if self.index_tip is None:
       self.index_tip = geometry_msgs.msg.Point()
     if self.middle_metacarpal is None:
       self.middle_metacarpal = geometry_msgs.msg.Point()
     if self.middle_proximal is None:
       self.middle_proximal = geometry_msgs.msg.Point()
     if self.middle_intermediate is None:
       self.middle_intermediate = geometry_msgs.msg.Point()
     if self.middle_distal is None:
       self.middle_distal = geometry_msgs.msg.Point()
     if self.middle_tip is None:
       self.middle_tip = geometry_msgs.msg.Point()
     if self.ring_metacarpal is None:
       self.ring_metacarpal = geometry_msgs.msg.Point()
     if self.ring_proximal is None:
       self.ring_proximal = geometry_msgs.msg.Point()
     if self.ring_intermediate is None:
       self.ring_intermediate = geometry_msgs.msg.Point()
     if self.ring_distal is None:
       self.ring_distal = geometry_msgs.msg.Point()
     if self.ring_tip is None:
       self.ring_tip = geometry_msgs.msg.Point()
     if self.pinky_metacarpal is None:
       self.pinky_metacarpal = geometry_msgs.msg.Point()
     if self.pinky_proximal is None:
       self.pinky_proximal = geometry_msgs.msg.Point()
     if self.pinky_intermediate is None:
       self.pinky_intermediate = geometry_msgs.msg.Point()
     if self.pinky_distal is None:
       self.pinky_distal = geometry_msgs.msg.Point()
     if self.pinky_tip is None:
       self.pinky_tip = geometry_msgs.msg.Point()
     end = 0
     _x = self
     start = end
     end += 12
     (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     start = end
     end += length
     if python3:
       self.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
     else:
       self.header.frame_id = str[start:end]
     _x = self
     start = end
     end += 696
     (_x.direction.x, _x.direction.y, _x.direction.z, _x.normal.x, _x.normal.y, _x.normal.z, _x.palmpos.x, _x.palmpos.y, _x.palmpos.z, _x.ypr.x, _x.ypr.y, _x.ypr.z, _x.thumb_metacarpal.x, _x.thumb_metacarpal.y, _x.thumb_metacarpal.z, _x.thumb_proximal.x, _x.thumb_proximal.y, _x.thumb_proximal.z, _x.thumb_intermediate.x, _x.thumb_intermediate.y, _x.thumb_intermediate.z, _x.thumb_distal.x, _x.thumb_distal.y, _x.thumb_distal.z, _x.thumb_tip.x, _x.thumb_tip.y, _x.thumb_tip.z, _x.index_metacarpal.x, _x.index_metacarpal.y, _x.index_metacarpal.z, _x.index_proximal.x, _x.index_proximal.y, _x.index_proximal.z, _x.index_intermediate.x, _x.index_intermediate.y, _x.index_intermediate.z, _x.index_distal.x, _x.index_distal.y, _x.index_distal.z, _x.index_tip.x, _x.index_tip.y, _x.index_tip.z, _x.middle_metacarpal.x, _x.middle_metacarpal.y, _x.middle_metacarpal.z, _x.middle_proximal.x, _x.middle_proximal.y, _x.middle_proximal.z, _x.middle_intermediate.x, _x.middle_intermediate.y, _x.middle_intermediate.z, _x.middle_distal.x, _x.middle_distal.y, _x.middle_distal.z, _x.middle_tip.x, _x.middle_tip.y, _x.middle_tip.z, _x.ring_metacarpal.x, _x.ring_metacarpal.y, _x.ring_metacarpal.z, _x.ring_proximal.x, _x.ring_proximal.y, _x.ring_proximal.z, _x.ring_intermediate.x, _x.ring_intermediate.y, _x.ring_intermediate.z, _x.ring_distal.x, _x.ring_distal.y, _x.ring_distal.z, _x.ring_tip.x, _x.ring_tip.y, _x.ring_tip.z, _x.pinky_metacarpal.x, _x.pinky_metacarpal.y, _x.pinky_metacarpal.z, _x.pinky_proximal.x, _x.pinky_proximal.y, _x.pinky_proximal.z, _x.pinky_intermediate.x, _x.pinky_intermediate.y, _x.pinky_intermediate.z, _x.pinky_distal.x, _x.pinky_distal.y, _x.pinky_distal.z, _x.pinky_tip.x, _x.pinky_tip.y, _x.pinky_tip.z,) = _get_struct_87d().unpack(str[start:end])
     return self
   except struct.error as e:
     raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #54
0
ファイル: _CpuInfo.py プロジェクト: Mr-Vdv/IGNIS_Simulation
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.header is None:
             self.header = std_msgs.msg.Header()
         if self.heaviest_processes is None:
             self.heaviest_processes = None
         end = 0
         _x = self
         start = end
         end += 12
         (
             _x.header.seq,
             _x.header.stamp.secs,
             _x.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.header.frame_id = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         pattern = '<%sf' % length
         start = end
         s = struct.Struct(pattern)
         end += s.size
         self.cpu_percent = numpy.frombuffer(str[start:end],
                                             dtype=numpy.float32,
                                             count=length)
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         self.heaviest_processes = []
         for i in range(0, length):
             val1 = mav_system_msgs.msg.ProcessInfo()
             start = end
             end += 4
             (val1.pid, ) = _get_struct_I().unpack(str[start:end])
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             start = end
             end += length
             if python3:
                 val1.name = str[start:end].decode('utf-8', 'rosmsg')
             else:
                 val1.name = str[start:end]
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             start = end
             end += length
             if python3:
                 val1.username = str[start:end].decode('utf-8', 'rosmsg')
             else:
                 val1.username = str[start:end]
             start = end
             end += 4
             (val1.cpu_percent, ) = _get_struct_f().unpack(str[start:end])
             self.heaviest_processes.append(val1)
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #55
0
 def deserialize(self, str):
   """
   unpack serialized message in str into this message instance
   :param str: byte array of serialized message, ``str``
   """
   if python3:
     codecs.lookup_error("rosmsg").msg_type = self._type
   try:
     if self.lanes is None:
       self.lanes = None
     end = 0
     start = end
     end += 4
     (self.id,) = _get_struct_i().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     self.lanes = []
     for i in range(0, length):
       val1 = subscriber.msg.Lane()
       _v17 = val1.header
       start = end
       end += 4
       (_v17.seq,) = _get_struct_I().unpack(str[start:end])
       _v18 = _v17.stamp
       _x = _v18
       start = end
       end += 8
       (_x.secs, _x.nsecs,) = _get_struct_2I().unpack(str[start:end])
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         _v17.frame_id = str[start:end].decode('utf-8', 'rosmsg')
       else:
         _v17.frame_id = str[start:end]
       _x = val1
       start = end
       end += 8
       (_x.increment, _x.lane_id,) = _get_struct_2i().unpack(str[start:end])
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       val1.waypoints = []
       for i in range(0, length):
         val2 = subscriber.msg.Waypoint()
         _x = val2
         start = end
         end += 8
         (_x.gid, _x.lid,) = _get_struct_2i().unpack(str[start:end])
         _v19 = val2.pose
         _v20 = _v19.header
         start = end
         end += 4
         (_v20.seq,) = _get_struct_I().unpack(str[start:end])
         _v21 = _v20.stamp
         _x = _v21
         start = end
         end += 8
         (_x.secs, _x.nsecs,) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length,) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
           _v20.frame_id = str[start:end].decode('utf-8', 'rosmsg')
         else:
           _v20.frame_id = str[start:end]
         _v22 = _v19.pose
         _v23 = _v22.position
         _x = _v23
         start = end
         end += 24
         (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
         _v24 = _v22.orientation
         _x = _v24
         start = end
         end += 32
         (_x.x, _x.y, _x.z, _x.w,) = _get_struct_4d().unpack(str[start:end])
         _v25 = val2.twist
         _v26 = _v25.header
         start = end
         end += 4
         (_v26.seq,) = _get_struct_I().unpack(str[start:end])
         _v27 = _v26.stamp
         _x = _v27
         start = end
         end += 8
         (_x.secs, _x.nsecs,) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length,) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
           _v26.frame_id = str[start:end].decode('utf-8', 'rosmsg')
         else:
           _v26.frame_id = str[start:end]
         _v28 = _v25.twist
         _v29 = _v28.linear
         _x = _v29
         start = end
         end += 24
         (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
         _v30 = _v28.angular
         _x = _v30
         start = end
         end += 24
         (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
         _v31 = val2.dtlane
         _x = _v31
         start = end
         end += 64
         (_x.dist, _x.dir, _x.apara, _x.r, _x.slope, _x.cant, _x.lw, _x.rw,) = _get_struct_8d().unpack(str[start:end])
         start = end
         end += 4
         (val2.change_flag,) = _get_struct_i().unpack(str[start:end])
         _v32 = val2.wpstate
         _x = _v32
         start = end
         end += 9
         (_x.aid, _x.lanechange_state, _x.steering_state, _x.accel_state, _x.stop_state, _x.event_state,) = _get_struct_i5B().unpack(str[start:end])
         _x = val2
         start = end
         end += 28
         (_x.lane_id, _x.left_lane_id, _x.right_lane_id, _x.stop_line_id, _x.cost, _x.time_cost, _x.direction,) = _get_struct_4I2fI().unpack(str[start:end])
         val1.waypoints.append(val2)
       _x = val1
       start = end
       end += 17
       (_x.lane_index, _x.cost, _x.closest_object_distance, _x.closest_object_velocity, _x.is_blocked,) = _get_struct_I3fB().unpack(str[start:end])
       val1.is_blocked = bool(val1.is_blocked)
       self.lanes.append(val1)
     return self
   except struct.error as e:
     raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #56
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.header is None:
             self.header = std_msgs.msg.Header()
         if self.status is None:
             self.status = actionlib_msgs.msg.GoalStatus()
         if self.result is None:
             self.result = my_robot_tutorial.msg.Navigate2DResult()
         end = 0
         _x = self
         start = end
         end += 12
         (
             _x.header.seq,
             _x.header.stamp.secs,
             _x.header.stamp.nsecs,
         ) = _get_struct_3I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.header.frame_id = str[start:end]
         _x = self
         start = end
         end += 8
         (
             _x.status.goal_id.stamp.secs,
             _x.status.goal_id.stamp.nsecs,
         ) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.status.goal_id.id = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.status.goal_id.id = str[start:end]
         start = end
         end += 1
         (self.status.status, ) = _get_struct_B().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.status.text = str[start:end].decode('utf-8', 'rosmsg')
         else:
             self.status.text = str[start:end]
         start = end
         end += 4
         (self.result.elapsed_time, ) = _get_struct_f().unpack(
             str[start:end])
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #57
0
 def deserialize_numpy(self, str, numpy):
   """
   unpack serialized message in str into this message instance using numpy for array types
   :param str: byte array of serialized message, ``str``
   :param numpy: numpy python module
   """
   if python3:
     codecs.lookup_error("rosmsg").msg_type = self._type
   try:
     if self.lanes is None:
       self.lanes = None
     end = 0
     start = end
     end += 4
     (self.id,) = _get_struct_i().unpack(str[start:end])
     start = end
     end += 4
     (length,) = _struct_I.unpack(str[start:end])
     self.lanes = []
     for i in range(0, length):
       val1 = subscriber.msg.Lane()
       _v49 = val1.header
       start = end
       end += 4
       (_v49.seq,) = _get_struct_I().unpack(str[start:end])
       _v50 = _v49.stamp
       _x = _v50
       start = end
       end += 8
       (_x.secs, _x.nsecs,) = _get_struct_2I().unpack(str[start:end])
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       start = end
       end += length
       if python3:
         _v49.frame_id = str[start:end].decode('utf-8', 'rosmsg')
       else:
         _v49.frame_id = str[start:end]
       _x = val1
       start = end
       end += 8
       (_x.increment, _x.lane_id,) = _get_struct_2i().unpack(str[start:end])
       start = end
       end += 4
       (length,) = _struct_I.unpack(str[start:end])
       val1.waypoints = []
       for i in range(0, length):
         val2 = subscriber.msg.Waypoint()
         _x = val2
         start = end
         end += 8
         (_x.gid, _x.lid,) = _get_struct_2i().unpack(str[start:end])
         _v51 = val2.pose
         _v52 = _v51.header
         start = end
         end += 4
         (_v52.seq,) = _get_struct_I().unpack(str[start:end])
         _v53 = _v52.stamp
         _x = _v53
         start = end
         end += 8
         (_x.secs, _x.nsecs,) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length,) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
           _v52.frame_id = str[start:end].decode('utf-8', 'rosmsg')
         else:
           _v52.frame_id = str[start:end]
         _v54 = _v51.pose
         _v55 = _v54.position
         _x = _v55
         start = end
         end += 24
         (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
         _v56 = _v54.orientation
         _x = _v56
         start = end
         end += 32
         (_x.x, _x.y, _x.z, _x.w,) = _get_struct_4d().unpack(str[start:end])
         _v57 = val2.twist
         _v58 = _v57.header
         start = end
         end += 4
         (_v58.seq,) = _get_struct_I().unpack(str[start:end])
         _v59 = _v58.stamp
         _x = _v59
         start = end
         end += 8
         (_x.secs, _x.nsecs,) = _get_struct_2I().unpack(str[start:end])
         start = end
         end += 4
         (length,) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
           _v58.frame_id = str[start:end].decode('utf-8', 'rosmsg')
         else:
           _v58.frame_id = str[start:end]
         _v60 = _v57.twist
         _v61 = _v60.linear
         _x = _v61
         start = end
         end += 24
         (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
         _v62 = _v60.angular
         _x = _v62
         start = end
         end += 24
         (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
         _v63 = val2.dtlane
         _x = _v63
         start = end
         end += 64
         (_x.dist, _x.dir, _x.apara, _x.r, _x.slope, _x.cant, _x.lw, _x.rw,) = _get_struct_8d().unpack(str[start:end])
         start = end
         end += 4
         (val2.change_flag,) = _get_struct_i().unpack(str[start:end])
         _v64 = val2.wpstate
         _x = _v64
         start = end
         end += 9
         (_x.aid, _x.lanechange_state, _x.steering_state, _x.accel_state, _x.stop_state, _x.event_state,) = _get_struct_i5B().unpack(str[start:end])
         _x = val2
         start = end
         end += 28
         (_x.lane_id, _x.left_lane_id, _x.right_lane_id, _x.stop_line_id, _x.cost, _x.time_cost, _x.direction,) = _get_struct_4I2fI().unpack(str[start:end])
         val1.waypoints.append(val2)
       _x = val1
       start = end
       end += 17
       (_x.lane_index, _x.cost, _x.closest_object_distance, _x.closest_object_velocity, _x.is_blocked,) = _get_struct_I3fB().unpack(str[start:end])
       val1.is_blocked = bool(val1.is_blocked)
       self.lanes.append(val1)
     return self
   except struct.error as e:
     raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #58
0
 def deserialize_numpy(self, str, numpy):
     """
 unpack serialized message in str into this message instance using numpy for array types
 :param str: byte array of serialized message, ``str``
 :param numpy: numpy python module
 """
     codecs.lookup_error("rosmsg").msg_type = self._type
     try:
         if self.poisonStamp is None:
             self.poisonStamp = brics_actuator.msg.Poison()
         if self.torques is None:
             self.torques = None
         end = 0
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.poisonStamp.originator = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.poisonStamp.originator = str[start:end]
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         start = end
         end += length
         if python3:
             self.poisonStamp.description = str[start:end].decode(
                 'utf-8', 'rosmsg')
         else:
             self.poisonStamp.description = str[start:end]
         start = end
         end += 4
         (self.poisonStamp.qos, ) = _get_struct_f().unpack(str[start:end])
         start = end
         end += 4
         (length, ) = _struct_I.unpack(str[start:end])
         self.torques = []
         for i in range(0, length):
             val1 = brics_actuator.msg.JointValue()
             _v4 = val1.timeStamp
             _x = _v4
             start = end
             end += 8
             (
                 _x.secs,
                 _x.nsecs,
             ) = _get_struct_2I().unpack(str[start:end])
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             start = end
             end += length
             if python3:
                 val1.joint_uri = str[start:end].decode('utf-8', 'rosmsg')
             else:
                 val1.joint_uri = str[start:end]
             start = end
             end += 4
             (length, ) = _struct_I.unpack(str[start:end])
             start = end
             end += length
             if python3:
                 val1.unit = str[start:end].decode('utf-8', 'rosmsg')
             else:
                 val1.unit = str[start:end]
             start = end
             end += 8
             (val1.value, ) = _get_struct_d().unpack(str[start:end])
             self.torques.append(val1)
         return self
     except struct.error as e:
         raise genpy.DeserializationError(e)  # most likely buffer underfill
コード例 #59
0
ファイル: test_codeccallbacks.py プロジェクト: rrader/cpython
 def test_badandgoodsurrogatepassexceptions(self):
     surrogatepass_errors = codecs.lookup_error('surrogatepass')
     # "surrogatepass" complains about a non-exception passed in
     self.assertRaises(
        TypeError,
        surrogatepass_errors,
        42
     )
     # "surrogatepass" complains about the wrong exception types
     self.assertRaises(
        TypeError,
        surrogatepass_errors,
        UnicodeError("ouch")
     )
     # "surrogatepass" can not be used for translating
     self.assertRaises(
         TypeError,
         surrogatepass_errors,
         UnicodeTranslateError("\ud800", 0, 1, "ouch")
     )
     # Use the correct exception
     for enc in ("utf-8", "utf-16le", "utf-16be", "utf-32le", "utf-32be"):
         with self.subTest(encoding=enc):
             self.assertRaises(
                 UnicodeEncodeError,
                 surrogatepass_errors,
                 UnicodeEncodeError(enc, "a", 0, 1, "ouch")
             )
             self.assertRaises(
                 UnicodeDecodeError,
                 surrogatepass_errors,
                 UnicodeDecodeError(enc, "a".encode(enc), 0, 1, "ouch")
             )
     for s in ("\ud800", "\udfff", "\ud800\udfff"):
         with self.subTest(str=s):
             self.assertRaises(
                 UnicodeEncodeError,
                 surrogatepass_errors,
                 UnicodeEncodeError("ascii", s, 0, len(s), "ouch")
             )
     tests = [
         ("utf-8", "\ud800", b'\xed\xa0\x80', 3),
         ("utf-16le", "\ud800", b'\x00\xd8', 2),
         ("utf-16be", "\ud800", b'\xd8\x00', 2),
         ("utf-32le", "\ud800", b'\x00\xd8\x00\x00', 4),
         ("utf-32be", "\ud800", b'\x00\x00\xd8\x00', 4),
         ("utf-8", "\udfff", b'\xed\xbf\xbf', 3),
         ("utf-16le", "\udfff", b'\xff\xdf', 2),
         ("utf-16be", "\udfff", b'\xdf\xff', 2),
         ("utf-32le", "\udfff", b'\xff\xdf\x00\x00', 4),
         ("utf-32be", "\udfff", b'\x00\x00\xdf\xff', 4),
         ("utf-8", "\ud800\udfff", b'\xed\xa0\x80\xed\xbf\xbf', 3),
         ("utf-16le", "\ud800\udfff", b'\x00\xd8\xff\xdf', 2),
         ("utf-16be", "\ud800\udfff", b'\xd8\x00\xdf\xff', 2),
         ("utf-32le", "\ud800\udfff", b'\x00\xd8\x00\x00\xff\xdf\x00\x00', 4),
         ("utf-32be", "\ud800\udfff", b'\x00\x00\xd8\x00\x00\x00\xdf\xff', 4),
     ]
     for enc, s, b, n in tests:
         with self.subTest(encoding=enc, str=s, bytes=b):
             self.assertEqual(
                 surrogatepass_errors(
                     UnicodeEncodeError(enc, "a" + s + "b",
                                        1, 1 + len(s), "ouch")),
                 (b, 1 + len(s))
             )
             self.assertEqual(
                 surrogatepass_errors(
                     UnicodeDecodeError(enc, bytearray(b"a" + b[:n] + b"b"),
                                        1, 1 + n, "ouch")),
                 (s[:1], 1 + n)
             )
コード例 #60
0
 def get(self, request, *args, **kwargs):
     # Results can contain a wide array of non-ascii or binary characters, escape them
     codecs.register_error("strict", codecs.lookup_error("surrogateescape"))
     result = self.get_object()
     serializer = serializers.DetailedResultSerializer(result)
     return Response({"result": serializer.data})