summaryrefslogtreecommitdiffstats
path: root/deluge/transfer.py
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2016-11-03 21:26:46 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2016-11-03 21:45:45 +0000
commit3a2ff0c188b0e8da893b733cccb1e164b54f2471 (patch)
tree2997d64b20e6e280016792cd4a04bfd20ff89992 /deluge/transfer.py
parentd4a8a38586251575a17c50735a10ddfba30fdc31 (diff)
downloaddeluge-3a2ff0c188b0e8da893b733cccb1e164b54f2471.tar.gz
deluge-3a2ff0c188b0e8da893b733cccb1e164b54f2471.tar.bz2
deluge-3a2ff0c188b0e8da893b733cccb1e164b54f2471.zip
[Lint] Convert all python double quotes to single quotes
* A rather disruptive change but for a few reasons such as easier to read, easier type, keep consistent and javascript code uses single quotes. * There are a few exceptions for the automated process: * Any double quotes in comments * Triple double quotes for docstrings * Strings containing single quotes are left e.g. "they're" * To deal with merge conflicts from feature branches it is best to follow these steps for each commit: * Create a patch: `git format-patch -1 <sha1>` * Edit the patch and replace double quotes with single except those in comments or strings containing an unescaped apostrophe. * Check the patch `git apply --check <patchfile>` and fix any remaining issues if it outputs an error. * Apply the patch `git am < <patchfile>`
Diffstat (limited to 'deluge/transfer.py')
-rw-r--r--deluge/transfer.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/deluge/transfer.py b/deluge/transfer.py
index 15f88b088..67cae7e54 100644
--- a/deluge/transfer.py
+++ b/deluge/transfer.py
@@ -31,7 +31,7 @@ class DelugeTransferProtocol(Protocol, object):
"""
def __init__(self):
- self._buffer = ""
+ self._buffer = ''
self._message_length = 0
self._bytes_received = 0
self._bytes_sent = 0
@@ -50,8 +50,8 @@ class DelugeTransferProtocol(Protocol, object):
compressed = zlib.compress(rencode.dumps(data))
size_data = len(compressed)
# Store length as a signed integer (using 4 bytes). "!" denotes network byte order.
- payload_len = struct.pack("!i", size_data)
- header = "D" + payload_len
+ payload_len = struct.pack('!i', size_data)
+ header = 'D' + payload_len
self._bytes_sent += len(header) + len(compressed)
self.transport.write(header)
self.transport.write(compressed)
@@ -94,18 +94,18 @@ class DelugeTransferProtocol(Protocol, object):
header = self._buffer[:MESSAGE_HEADER_SIZE]
payload_len = header[1:MESSAGE_HEADER_SIZE]
if header[0] != 'D':
- raise Exception("Invalid header format. First byte is %d" % ord(header[0]))
+ raise Exception('Invalid header format. First byte is %d' % ord(header[0]))
# Extract the length stored as a signed integer (using 4 bytes)
- self._message_length = struct.unpack("!i", payload_len)[0]
+ self._message_length = struct.unpack('!i', payload_len)[0]
if self._message_length < 0:
- raise Exception("Message length is negative: %d" % self._message_length)
+ raise Exception('Message length is negative: %d' % self._message_length)
# Remove the header from the buffer
self._buffer = self._buffer[MESSAGE_HEADER_SIZE:]
except Exception as ex:
- log.warn("Error occurred when parsing message header: %s.", ex)
- log.warn("This version of Deluge cannot communicate with the sender of this data.")
+ log.warn('Error occurred when parsing message header: %s.', ex)
+ log.warn('This version of Deluge cannot communicate with the sender of this data.')
self._message_length = 0
- self._buffer = ""
+ self._buffer = ''
def _handle_complete_message(self, data):
"""
@@ -117,7 +117,7 @@ class DelugeTransferProtocol(Protocol, object):
try:
self.message_received(rencode.loads(zlib.decompress(data), decode_utf8=True))
except Exception as ex:
- log.warn("Failed to decompress (%d bytes) and load serialized data with rencode: %s", len(data), ex)
+ log.warn('Failed to decompress (%d bytes) and load serialized data with rencode: %s', len(data), ex)
def get_bytes_recv(self):
"""