根据传入的数据结构生成最终用于推送的文件字节字符串( :func:`bytes` )，
        MoEar会将其持久化并用于之后的推送任务

        :param dict data: 待打包的数据结构
        :return: 返回生成的书籍打包输出字节
        :rtype: bytes
170564
def generate(self, data, *args, **kwargs):
        
        with tempfile.TemporaryDirectory() as tmpdirname:
            self.options.setdefault('package_build_dir', tmpdirname)
            crawler = CrawlerScript(self.options)
            crawler.crawl(data, self.spider, *args, **kwargs)

            output_file = os.path.join(
                self.options['package_build_dir'], 'source', 'moear.mobi')
            with open(output_file, 'rb') as fh:
                content = fh.read()

        return content
611384
def prep_stream_data(data):
    
    if isinstance(data, (six.string_types, six.binary_type)):
        stream = io.BytesIO(to_bytes(data))
    else:
        stream = data

    return InsistentReaderBytesIO(stream)
606964
def setData(self, data):
        
        try:
            bytestream = pickle.dumps(data)
            super(MimeData, self).setData(self._mimeType, bytestream)
        except TypeError:
            raise TypeError(self.tr("can not pickle added data"))
        except:
            raise
669035
def bytes_from_decode_data(s):
    
    if isinstance(s, (str, unicode)):
        try:
            return s.encode('ascii')
        except UnicodeEncodeError:
            raise NotValidParamError(
                'String argument should contain only ASCII characters')
    if isinstance(s, bytes_types):
        return s
    try:
        return memoryview(s).tobytes()
    except TypeError:
        raise suppress_context(
            TypeError(
                'Argument should be a bytes-like object or ASCII string, not '
                '{!r}'.format(s.__class__.__name__)))
77389
def GetDataAsObject(self):
    
    if not self._data:
      return None

    if self._data_type in self._STRING_VALUE_TYPES:
      try:
        return self._data.decode('utf-16-le')

      # AttributeError is raised when self._data has no decode method.
      except AttributeError as exception:
        raise errors.WinRegistryValueError((
            'Unsupported data type: {0!s} of value: {1!s} with error: '
            '{2!s}').format(type(self._data), self._name, exception))

      except UnicodeError as exception:
        raise errors.WinRegistryValueError(
            'Unable to decode data of value: {0!s} with error: {1!s}'.format(
                self._name, exception))

    elif (self._data_type == definitions.REG_DWORD and
          self._data_size == 4):
      return self._INT32_LITTLE_ENDIAN.MapByteStream(self._data)

    elif (self._data_type == definitions.REG_DWORD_BIG_ENDIAN and
          self._data_size == 4):
      return self._INT32_BIG_ENDIAN.MapByteStream(self._data)

    elif (self._data_type == definitions.REG_QWORD and
          self._data_size == 8):
      return self._INT64_LITTLE_ENDIAN.MapByteStream(self._data)

    elif self._data_type == definitions.REG_MULTI_SZ:
      try:
        utf16_string = self._data.decode('utf-16-le')
        # TODO: evaluate the use of filter here is appropriate behavior.
        return list(filter(None, utf16_string.split('\x00')))

      # AttributeError is raised when self._data has no decode method.
      except AttributeError as exception:
        raise errors.WinRegistryValueError((
            'Unsupported data type: {0!s} of value: {1!s} with error: '
            '{2!s}').format(type(self._data), self._name, exception))

      except UnicodeError as exception:
        raise errors.WinRegistryValueError(
            'Unable to read data from value: {0!s} with error: {1!s}'.format(
                self._name, exception))

    return self._data
818701
function encodeData (data) {
    // json encode data
    data = jsonStableStringify(data)
    // compress if compression in use
    if (this.compression) {
        data = snappy.compressSync(data).toString('base64')
    }
    // return encoded data
    return data
}
838264
def rewrap_bytes(data):
    '''
    '''
    return b'\n'.join(
        data[index:index+70] for index in range(0, len(data), 70)
    )
1022085
def to_api_data(self):
        
        data = {'@odata.type': self._gk(
            '{}_attachment_type'.format(self.attachment_type)),
            self._cc('name'): self.name}

        if self.attachment_type == 'file':
            data[self._cc('contentBytes')] = self.content
        else:
            data[self._cc('item')] = self.content

        return data
1291061
def be_array_from_bytes(fmt, data):
    
    arr = array.array(str(fmt), data)
    return fix_byteorder(arr)
144958
def encode(self, data, size):
        
        return return_fresh_string(lib.zarmour_encode(self._as_parameter_, data, size))
1213682
def unpack(cls, data):
        
        header, data = APPHeader.unpack(data)

        if len(data) < header.payload_length:
            raise ProtocolViolation("Payload too small")
        payload = data[:header.payload_length]
        body = cls()
        body._header = header
        body._payload = payload
        return body, data[header.payload_length:]
755413
def buffer(self, data):
        '''
        
        '''
        if not hasattr(self, '_sock'):
            return None

        # data will always be a byte array
        if len(self._buffer):
            self._buffer.extend(data)
        else:
            self._buffer = bytearray(data)
239573
def as_data(self):
        """"""
        use_file_if_no_data = not self._data and self._file
        if use_file_if_no_data:
            with open(self._file) as f:
                if self._base64_file_content:
                    self._data = bytes.decode(
                        base64.standard_b64encode(str.encode(f.read())))
                else:
                    self._data = f.read()
        return self._data
640465
def encode(data):
    
    res = ""
    for i in range(0,len(data), 3):
        if (i+2==len(data)):
            res += _encode3bytes(ord(data[i]), ord(data[i+1]), 0)
        elif (i+1==len(data)):
            res += _encode3bytes(ord(data[i]), 0, 0)
        else:
            res += _encode3bytes(ord(data[i]), ord(data[i+1]), ord(data[i+2]))
    return res
558496
def _decode(data):
    
    if not isinstance(data, bytes_types):
        data = six.b(str(data))
    return base64.b64decode(data.decode("utf-8"))
375625
def FromTrimmedData(data, index):
        
        header = Header()

        ms = StreamManager.GetStream(data)

        reader = BinaryReader(ms)
        header.DeserializeUnsigned(reader)
        reader.ReadByte()

        witness = Witness()
        witness.Deserialize(reader)
        header.Script = witness

        StreamManager.ReleaseStream(ms)

        return header
58123
def unread_data(self, data: bytes) -> None:
        
        warnings.warn("unread_data() is deprecated "
                      "and will be removed in future releases (#3260)",
                      DeprecationWarning,
                      stacklevel=2)
        if not data:
            return

        if self._buffer_offset:
            self._buffer[0] = self._buffer[0][self._buffer_offset:]
            self._buffer_offset = 0
        self._size += len(data)
        self._cursor -= len(data)
        self._buffer.appendleft(data)
        self._eof_counter = 0