示例#1
0
 def _may_compress(self, dtype, dformat, wire_data):
     if len(wire_data)>self.max_clipboard_packet_size:
         log.warn("Warning: clipboard contents are too big and have not been sent")
         log.warn(" %s compressed bytes dropped (maximum is %s)", len(wire_data), self.max_clipboard_packet_size)
         return  None
     if type(wire_data)==str and len(wire_data)>=MIN_CLIPBOARD_COMPRESSION_SIZE:
         return Compressible("clipboard: %s / %s" % (dtype, dformat), wire_data)
     return wire_data
示例#2
0
 def _may_compress(self, dtype, dformat, wire_data):
     if len(wire_data)>self.max_clipboard_packet_size:
         log.warn("Warning: clipboard contents are too big and have not been sent")
         log.warn(" %s compressed bytes dropped (maximum is %s)", len(wire_data), self.max_clipboard_packet_size)
         return None
     l = len(wire_data)
     if isinstance(wire_data, (str, bytes)) and l>=MIN_CLIPBOARD_COMPRESS_SIZE:
         if isinstance(wire_data, str):
             #compression requires bytes:
             #but this would require the receiving end to use net_utf8()
             wire_data = wire_data.encode("utf8")
             log("encoded %i characters to %i utf8 bytes", l, len(wire_data))
         return Compressible("clipboard: %s / %s" % (dtype, dformat), wire_data)
     return wire_data