Commit c82a4634 authored by Philipp Hörist's avatar Philipp Hörist

Fix pylint errors

- line-too-long
parent 2609572a
Pipeline #5419 passed with stages
in 38 seconds
......@@ -430,7 +430,8 @@ class Client(Observable):
else:
self._set_error(StreamError.CONNECTION_FAILED,
'connection-failed',
'Unable to connect to last successful address: %s' % str(self._current_address))
(f'Unable to connect to last '
'successful address: {self._current_address}'))
self.notify('connection-failed')
def _disconnect_with_error(self, error_domain, error, text=None):
......@@ -475,11 +476,13 @@ class Client(Observable):
return self._dispatcher.get_module(name)
def _on_bad_certificate(self, connection, _signal_name):
self._peer_certificate, self._peer_certificate_errors = connection.peer_certificate
self._peer_certificate, self._peer_certificate_errors = \
connection.peer_certificate
self._set_error(StreamError.BAD_CERTIFICATE, 'bad certificate')
def _on_certificate_set(self, connection, _signal_name):
self._peer_certificate, self._peer_certificate_errors = connection.peer_certificate
self._peer_certificate, self._peer_certificate_errors = \
connection.peer_certificate
def accept_certificate(self):
self._log.info('Certificate accepted')
......
......@@ -274,8 +274,9 @@ class StanzaDispatcher(Observable):
if not typ and not ns:
typ = 'default'
self._log.debug('Register handler %s for "%s" type->%s ns->%s(%s) priority->%s',
handler, name, typ, ns, xmlns, priority)
self._log.debug(
'Register handler %s for "%s" type->%s ns->%s(%s) priority->%s',
handler, name, typ, ns, xmlns, priority)
if xmlns not in self._handlers:
self._register_namespace(xmlns)
......@@ -315,11 +316,13 @@ class StanzaDispatcher(Observable):
try:
self._handlers[xmlns][name][specific].remove(handler_dict)
except ValueError:
self._log.warning('Unregister failed: %s for "%s" type->%s ns->%s(%s)',
handler, name, typ, ns, xmlns)
self._log.warning(
'Unregister failed: %s for "%s" type->%s ns->%s(%s)',
handler, name, typ, ns, xmlns)
else:
self._log.debug('Unregister handler %s for "%s" type->%s ns->%s(%s)',
handler, name, typ, ns, xmlns)
self._log.debug(
'Unregister handler %s for "%s" type->%s ns->%s(%s)',
handler, name, typ, ns, xmlns)
def _default_handler(self, stanza):
"""
......
......@@ -46,7 +46,7 @@ if HAVE_GLIB:
GLib.IOCondition.PRI | GLib.IOCondition.HUP
FLAG_CLOSE = GLib.IOCondition.HUP
PENDING_READ = GLib.IOCondition.IN # There is data to read.
PENDING_WRITE = GLib.IOCondition.OUT # Data CAN be written without blocking.
PENDING_WRITE = GLib.IOCondition.OUT # Data CAN be written without blocking
IS_CLOSED = GLib.IOCondition.HUP # Hung up (connection broken)
else:
FLAG_WRITE = 20 # write only 10100
......@@ -222,7 +222,8 @@ class IdleQueue:
"""
# (timeout, boolean)
# Boolean is True if timeout is specified in seconds, False means miliseconds
# Boolean is True if timeout is specified in seconds,
# False means miliseconds
PROCESS_TIMEOUT = (100, False)
def __init__(self):
......@@ -438,8 +439,9 @@ class SelectIdleQueue(IdleQueue):
def checkQueue(self):
"""
Iterates through all known file descriptors and uses os.stat to check if they're valid.
Greatly improves performance if the caller hands us and expects notification on an invalid file handle.
Iterates through all known file descriptors and uses os.stat to
check if they're valid. Greatly improves performance if the caller
hands us and expects notification on an invalid file handle.
"""
bad_fds=[]
union={}
......@@ -480,8 +482,8 @@ class SelectIdleQueue(IdleQueue):
def _remove_idle(self, fd):
"""
This method is called when we unplug a new idle object. Remove descriptor
from read/write/error lists
This method is called when we unplug a new idle object.
Remove descriptor from read/write/error lists
"""
if fd in self.read_fds:
del(self.read_fds[fd])
......@@ -525,7 +527,8 @@ class GlibIdleQueue(IdleQueue):
"""
# (timeout, boolean)
# Boolean is True if timeout is specified in seconds, False means miliseconds
# Boolean is True if timeout is specified in seconds,
# False means miliseconds
PROCESS_TIMEOUT = (2, True)
def _init_idle(self):
......@@ -536,8 +539,8 @@ class GlibIdleQueue(IdleQueue):
def _add_idle(self, fd, flags):
"""
This method is called when we plug a new idle object. Start listening for
events from fd
This method is called when we plug a new idle object.
Start listening for events from fd
"""
res = GLib.io_add_watch(fd, GLib.PRIORITY_LOW, flags,
self._process_events)
......
......@@ -108,8 +108,8 @@ def extend_form(node):
class DataField(ExtendedNode):
"""
Keeps data about one field - var, field type, labels, instructions... Base
class for different kinds of fields. Use create_field() function to construct one
of these
class for different kinds of fields. Use create_field() function to
construct one of these
"""
def __init__(self, typ=None, var=None, value=None, label=None, desc=None,
......
......@@ -70,11 +70,13 @@ class HTTPUpload(BaseModule):
for header in slot.getTag('put').getTags('header'):
name = header.getAttr('name')
if name not in ALLOWED_HEADERS:
return raise_error(self._log.warning, stanza, 'stanza-malformed',
return raise_error(self._log.warning, stanza,
'stanza-malformed',
'Not allowed header found: %s' % name)
data = header.getData()
if '\n' in data:
return raise_error(self._log.warning, stanza, 'stanza-malformed',
return raise_error(self._log.warning, stanza,
'stanza-malformed',
'NNewline in header data found')
headers[name] = data
......
......@@ -149,7 +149,9 @@ class IBB(BaseModule):
@call_on_response('_default_response')
def send_data(self, jid, sid, seq, data):
iq = Iq('set', to=jid)
ibb_data = iq.addChild('data', {'sid': sid, 'seq': seq}, namespace=NS_IBB)
ibb_data = iq.addChild('data',
{'sid': sid, 'seq': seq},
namespace=NS_IBB)
ibb_data.setData(b64encode(data))
return iq
......
......@@ -142,7 +142,8 @@ class Muclumbus(BaseModule):
is_open = item.getTag('is-open') is not None
try:
anonymity_mode = AnonymityMode(item.getTagData('anonymity-mode'))
anonymity_mode = AnonymityMode(
item.getTagData('anonymity-mode'))
except ValueError:
anonymity_mode = AnonymityMode.UNKNOWN
results.append(MuclumbusItem(jid=jid,
......
......@@ -336,7 +336,8 @@ class OMEMO(BaseModule):
result = {}
signed_prekey_node = bundle.getTag('signedPreKeyPublic')
try:
result['spk'] = {'key': b64decode(signed_prekey_node.getData(), bytes)}
result['spk'] = {'key': b64decode(signed_prekey_node.getData(),
bytes)}
except Exception as error:
raise StanzaMalformed('Failed to decode '
'signedPreKeyPublic: %s' % error)
......@@ -349,7 +350,8 @@ class OMEMO(BaseModule):
signed_signature_node = bundle.getTag('signedPreKeySignature')
try:
result['spk_signature'] = b64decode(signed_signature_node.getData(), bytes)
result['spk_signature'] = b64decode(signed_signature_node.getData(),
bytes)
except Exception as error:
raise StanzaMalformed('Failed to decode '
'signedPreKeySignature: %s' % error)
......@@ -375,7 +377,8 @@ class OMEMO(BaseModule):
try:
key = b64decode(prekey.getData(), bytes)
except Exception as error:
raise StanzaMalformed('Failed to decode preKeyPublic: %s' % error)
raise StanzaMalformed(
'Failed to decode preKeyPublic: %s' % error)
result['otpks'].append({'key': key, 'id': id_})
......
......@@ -66,8 +66,8 @@ class PlugIn:
def PlugOut(self, *args, **kwargs):
"""
Unregister our _exported_methods from owner and detach from it.
If defined by a subclass, call self.plugout() after unplugging to execute
hook code
If defined by a subclass, call self.plugout() after unplugging to
execute hook code
"""
log.info('Plugging %s __OUT__ of %s.', self, self._owner)
for method in self._exported_methods:
......
......@@ -109,8 +109,9 @@ class Smacks:
self._location = stanza.getAttr('location')
self.enabled = True
self._log.info('Received enabled, location: %s, resume supported: %s, '
'session-id: %s', self._location, resume, self._session_id)
self._log.info(
'Received enabled, location: %s, resume supported: %s, '
'session-id: %s', self._location, resume, self._session_id)
def count_incoming(self, name):
if not self.enabled:
......@@ -248,15 +249,17 @@ class Smacks:
diff = self._out_h - count_server
queue_size = len(queue)
if diff < 0:
self._log.error('Mismatch detected, our h: %d, server h: %d, queue: %d',
self._out_h, count_server, queue_size)
self._log.error(
'Mismatch detected, our h: %d, server h: %d, queue: %d',
self._out_h, count_server, queue_size)
# Don't accumulate all messages in this case
# (they would otherwise all be resent on the next reconnect)
queue = []
elif queue_size < diff:
self._log.error('Mismatch detected, our h: %d, server h: %d, queue: %d',
self._out_h, count_server, queue_size)
self._log.error(
'Mismatch detected, our h: %d, server h: %d, queue: %d',
self._out_h, count_server, queue_size)
else:
self._log.debug('Validate ack, our h: %d, server h: %d, queue: %d',
self._out_h, count_server, queue_size)
......
......@@ -42,7 +42,8 @@ def _distance_line_from_origin(line):
def _length_of_ray_until_intersect(theta, line):
return line['intercept'] / (math.sin(theta) - line['slope'] * math.cos(theta))
return line['intercept'] / (math.sin(theta) -
line['slope'] * math.cos(theta))
def _get_bounds(l):
......@@ -64,7 +65,8 @@ def _get_bounds(l):
t = _g1
_g1 = _g1 + 1
top1 = (284517 * m1 - 94839 * m3) * sub2
top2 = (838422 * m3 + 769860 * m2 + 731718 * m1) * l * sub2 - (769860 * t) * l
top2 = ((838422 * m3 + 769860 * m2 + 731718 * m1) *
l * sub2 - (769860 * t) * l)
bottom = (632260 * m3 - 126452 * m2) * sub2 + 126452 * t
result.append({'slope': top1 / bottom, 'intercept': top2 / bottom})
return result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment