diff options
author | lovetox <philipp@hoerist.com> | 2022-06-17 17:53:13 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2022-06-17 17:53:13 +0300 |
commit | fac52588b606cfd578b08b6e90ca77a54fda64b5 (patch) | |
tree | 3978c8de12c04972a676fe747769e1d951d2595e | |
parent | 246e509049b365076f55547d8f8b090ff03594c5 (diff) |
chore: Fix codestyle errors
-rw-r--r-- | gajim/common/jingle_ft.py | 86 | ||||
-rw-r--r-- | gajim/common/logging_helpers.py | 32 | ||||
-rw-r--r-- | gajim/gtk/chat_list.py | 2 | ||||
-rw-r--r-- | gajim/gtk/controls/base.py | 2 | ||||
-rw-r--r-- | gajim/gtk/features.py | 7 | ||||
-rw-r--r-- | gajim/gtk/types.py | 3 | ||||
-rw-r--r-- | setup.cfg | 9 |
7 files changed, 71 insertions, 70 deletions
diff --git a/gajim/common/jingle_ft.py b/gajim/common/jingle_ft.py index efd2f4b29..0c3861803 100644 --- a/gajim/common/jingle_ft.py +++ b/gajim/common/jingle_ft.py @@ -131,23 +131,23 @@ class JingleFileTransfer(JingleContent): self.nominated_cand = {} self.state = State.NOT_STARTED self.states = { - State.INITIALIZED : StateInitialized(self), - State.CAND_SENT : StateCandSent(self), - State.CAND_RECEIVED : StateCandReceived(self), - State.TRANSFERRING : StateTransfering(self), - State.TRANSPORT_REPLACE : StateTransportReplace(self), - State.CAND_SENT_AND_RECEIVED : StateCandSentAndRecv(self) + State.INITIALIZED: StateInitialized(self), + State.CAND_SENT: StateCandSent(self), + State.CAND_RECEIVED: StateCandReceived(self), + State.TRANSFERRING: StateTransfering(self), + State.TRANSPORT_REPLACE: StateTransportReplace(self), + State.CAND_SENT_AND_RECEIVED: StateCandSentAndRecv(self) } cert_name = (configpaths.get('MY_CERT') / jingle_xtls.SELF_SIGNED_CERTIFICATE) - if not (cert_name.with_suffix('.cert').exists() - and cert_name.with_suffix('.pkey').exists()): + if not (cert_name.with_suffix('.cert').exists() and + cert_name.with_suffix('.pkey').exists()): jingle_xtls.make_certs(cert_name, 'gajim') def __state_changed(self, nextstate: State, - args: Optional[dict[str, Any]] =None + args: Optional[dict[str, Any]] = None ) -> None: # Executes the next state action and sets the next state current_state = self.state @@ -284,18 +284,21 @@ class JingleFileTransfer(JingleContent): def __send_hash(self) -> None: # Send hash in a session info checksum = nbxmpp.Node(tag='checksum', - payload=[nbxmpp.Node(tag='file', - payload=[self._compute_hash()])]) + payload=[ + nbxmpp.Node(tag='file', + payload=[self._compute_hash()]) + ]) checksum.setNamespace(Namespace.JINGLE_FILE_TRANSFER_5) self.session.__session_info(checksum) pjid = app.get_jid_without_resource(self.session.peerjid) - file_info = {'name' : self.file_props.name, - 'file-name' : self.file_props.file_name, - 'hash' : self.file_props.hash_, - 'size' : self.file_props.size, - 'date' : self.file_props.date, - 'peerjid' : pjid - } + file_info = { + 'name': self.file_props.name, + 'file-name': self.file_props.file_name, + 'hash': self.file_props.hash_, + 'size': self.file_props.size, + 'date': self.file_props.date, + 'peerjid': pjid + } self.session.connection.get_module('Jingle').set_file_info(file_info) def _compute_hash(self) -> Optional[nbxmpp.Hashes2]: @@ -311,7 +314,7 @@ class JingleFileTransfer(JingleContent): hash_ = h.calculateHash(self.file_props.algo, file_) file_.close() # DEBUG - #hash_ = '1294809248109223' + # hash_ = '1294809248109223' if not hash_: # Hash algorithm not supported return @@ -332,7 +335,7 @@ class JingleFileTransfer(JingleContent): log.info("__on_session_accept") con = self.session.connection security = content.getTag('security') - if not security: # responder can not verify our fingerprint + if not security: # responder can not verify our fingerprint self.use_security = False else: fingerprint = security.getTag('fingerprint') @@ -392,11 +395,11 @@ class JingleFileTransfer(JingleContent): log.info("__on_session_terminate") def __on_session_info(self, - stanza: nbxmpp.Node, - content: nbxmpp.Node, - error: Optional[nbxmpp.Node], - action: str - ) -> None: + stanza: nbxmpp.Node, + content: nbxmpp.Node, + error: Optional[nbxmpp.Node], + action: str + ) -> None: pass def __on_transport_accept(self, @@ -452,7 +455,7 @@ class JingleFileTransfer(JingleContent): self.__state_changed(State.TRANSFERRING) raise nbxmpp.NodeProcessed else: - args = {'candError' : True} + args = {'candError': True} self.__state_changed(State.CAND_RECEIVED, args) return if cand_used: @@ -463,13 +466,13 @@ class JingleFileTransfer(JingleContent): streamhost_used = cand break if streamhost_used is None or streamhost_used['type'] == 'proxy': - if app.socks5queue.listener and \ - not app.socks5queue.listener.connections: + if (app.socks5queue.listener and + not app.socks5queue.listener.connections): app.socks5queue.listener.disconnect() if content.getTag('transport').getTag('activated'): self.state = State.TRANSFERRING app.socks5queue.send_file(self.file_props, - self.session.connection.name, 'client') + self.session.connection.name, 'client') return args = {'content': content, 'sendCand': False} @@ -490,8 +493,8 @@ class JingleFileTransfer(JingleContent): if self.state in (State.NOT_STARTED, State.CAND_RECEIVED): self.__state_changed(State.INITIALIZED) elif self.state == State.CAND_SENT_AND_RECEIVED: - if not self.nominated_cand['our-cand'] and \ - not self.nominated_cand['peer-cand']: + if (not self.nominated_cand['our-cand'] and + not self.nominated_cand['peer-cand']): if not self.weinitiate: return self.__state_changed(State.TRANSPORT_REPLACE) @@ -519,15 +522,15 @@ class JingleFileTransfer(JingleContent): log.info('send_candidate_used') if streamhost is None: return - args = {'streamhost' : streamhost, - 'sendCand' : True} + args = {'streamhost': streamhost, + 'sendCand': True} self.nominated_cand['our-cand'] = streamhost self.__send_candidate(args) def _on_connect_error(self, sid: str) -> None: log.info('connect error, sid=%s', sid) - args = {'candError' : True, - 'sendCand' : True} + args = {'candError': True, + 'sendCand': True} self.__send_candidate(args) def __send_candidate(self, args: dict[str, Any]) -> None: @@ -550,11 +553,13 @@ class JingleFileTransfer(JingleContent): fingerprint = None if self.use_security: fingerprint = 'server' - listener = app.socks5queue.start_listener(port, sha_str, - self._store_socks5_sid, - self.file_props, - fingerprint=fingerprint, - typ='sender' if self.weinitiate else 'receiver') + listener = app.socks5queue.start_listener( + port, + sha_str, + self._store_socks5_sid, + self.file_props, + fingerprint=fingerprint, + typ='sender' if self.weinitiate else 'receiver') if not listener: # send error message, notify the user return @@ -583,4 +588,5 @@ class JingleFileTransfer(JingleContent): def get_content(desc) -> JingleFileTransfer: return JingleFileTransfer + contents[Namespace.JINGLE_FILE_TRANSFER_5] = get_content diff --git a/gajim/common/logging_helpers.py b/gajim/common/logging_helpers.py index 463c33980..3d0d87cc2 100644 --- a/gajim/common/logging_helpers.py +++ b/gajim/common/logging_helpers.py @@ -82,23 +82,23 @@ def parseAndSetLogLevels(arg: str) -> None: class colors: - NONE = chr(27) + "[0m" - BLACk = chr(27) + "[30m" - RED = chr(27) + "[31m" - GREEN = chr(27) + "[32m" - BROWN = chr(27) + "[33m" - BLUE = chr(27) + "[34m" - MAGENTA = chr(27) + "[35m" - CYAN = chr(27) + "[36m" - LIGHT_GRAY = chr(27) + "[37m" - DARK_GRAY = chr(27) + "[30;1m" - BRIGHT_RED = chr(27) + "[31;1m" + NONE = chr(27) + "[0m" + BLACK = chr(27) + "[30m" + RED = chr(27) + "[31m" + GREEN = chr(27) + "[32m" + BROWN = chr(27) + "[33m" + BLUE = chr(27) + "[34m" + MAGENTA = chr(27) + "[35m" + CYAN = chr(27) + "[36m" + LIGHT_GRAY = chr(27) + "[37m" + DARK_GRAY = chr(27) + "[30;1m" + BRIGHT_RED = chr(27) + "[31;1m" BRIGHT_GREEN = chr(27) + "[32;1m" - YELLOW = chr(27) + "[33;1m" - BRIGHT_BLUE = chr(27) + "[34;1m" - PURPLE = chr(27) + "[35;1m" - BRIGHT_CYAN = chr(27) + "[36;1m" - WHITE = chr(27) + "[37;1m" + YELLOW = chr(27) + "[33;1m" + BRIGHT_BLUE = chr(27) + "[34;1m" + PURPLE = chr(27) + "[35;1m" + BRIGHT_CYAN = chr(27) + "[36;1m" + WHITE = chr(27) + "[37;1m" def colorize(text: str, color: str) -> str: diff --git a/gajim/gtk/chat_list.py b/gajim/gtk/chat_list.py index faabb56fc..e7459f9f3 100644 --- a/gajim/gtk/chat_list.py +++ b/gajim/gtk/chat_list.py @@ -596,7 +596,7 @@ class ChatRow(Gtk.ListBoxRow): if self.contact.is_groupchat and not self.contact.can_notify(): self._ui.unread_label.get_style_context().add_class( - 'unread-counter-silent') + 'unread-counter-silent') # Get last chat message from archive line = app.storage.archive.get_last_conversation_line(account, jid) diff --git a/gajim/gtk/controls/base.py b/gajim/gtk/controls/base.py index 2f8d69a32..6231392f1 100644 --- a/gajim/gtk/controls/base.py +++ b/gajim/gtk/controls/base.py @@ -1146,7 +1146,7 @@ class BaseControl(ChatCommandProcessor, CommandTools, EventHelper): displaymarking: Optional[Displaymarking] = None, msg_log_id: Optional[int] = None, message_id: Optional[str] = None, - stanza_id: Optional[str] =None, + stanza_id: Optional[str] = None, additional_data: Optional[AdditionalDataDict] = None ) -> None: diff --git a/gajim/gtk/features.py b/gajim/gtk/features.py index 5620dd21c..de8be1c6a 100644 --- a/gajim/gtk/features.py +++ b/gajim/gtk/features.py @@ -118,13 +118,6 @@ class Features(Gtk.ApplicationWindow): _('Requires: libxss'), _('No additional requirements'), auto_status_enabled), -# Feature(_('Location detection'), -# app.is_installed('GEOCLUE'), -# _('Enables Gajim to be location-aware, if the user decides ' -# 'to publish the device’s location'), -# _('Requires: geoclue'), -# _('Feature is not available under Windows'), -# None), Feature(_('Notification Sounds'), notification_sounds_available, _('Enables Gajim to play sounds for various notifications'), diff --git a/gajim/gtk/types.py b/gajim/gtk/types.py index 85ee4d6c8..0af3d2178 100644 --- a/gajim/gtk/types.py +++ b/gajim/gtk/types.py @@ -38,8 +38,7 @@ if TYPE_CHECKING: from .conversation.rows.scroll_hint import ScrollHintRow - -ControlT = Union [ +ControlT = Union[ 'BaseControl', 'ChatControl', 'PrivateChatControl', @@ -6,14 +6,17 @@ exclude = dist, debian_build, test, - typings + typings, gajim/command_system, - gajim/common/config.py - gajim/common/optparser.py + gajim/common/config.py, + gajim/common/optparser.py, + gajim/common/socks5.py, + gajim/gui, max-complexity = 15 builtins=_ max-line-length = 80 statistics = True +count = True [metadata] name = gajim |