diff --git a/src/sakia/app.py b/src/sakia/app.py index d73f1bcb741c68ff5bbfff42674ffd4b4378ea81..f046032e292b0deaad43734737afdf1bd55b6452 100644 --- a/src/sakia/app.py +++ b/src/sakia/app.py @@ -5,7 +5,15 @@ import socket import sakia.i18n_rc import async_timeout import aiohttp -from PyQt5.QtCore import QObject, pyqtSignal, QTranslator, QCoreApplication, QLocale, Qt, QFile +from PyQt5.QtCore import ( + QObject, + pyqtSignal, + QTranslator, + QCoreApplication, + QLocale, + Qt, + QFile, +) from . import __version__ from .options import SakiaOptions from sakia.data.connectors import BmaConnector diff --git a/src/sakia/data/connectors/bma.py b/src/sakia/data/connectors/bma.py index 53963fcc9ed699ba4b69a27e9dae3f10670ac512..67fe8ae1f6e0a89bdb55aae0e4c3223824273431 100644 --- a/src/sakia/data/connectors/bma.py +++ b/src/sakia/data/connectors/bma.py @@ -217,12 +217,11 @@ class BmaConnector: ) ) # create client - _client = client.Client(endpoint, session, proxy=self._user_parameters.proxy()) + _client = client.Client( + endpoint, session, proxy=self._user_parameters.proxy() + ) futures.append( - self._verified_request( - node, - _client(request, **req_args) - ) + self._verified_request(node, _client(request, **req_args)) ) if random_offline_node: node = random_offline_node[0] @@ -236,12 +235,11 @@ class BmaConnector: ) ) # create client - _client = client.Client(endpoint, session, proxy=self._user_parameters.proxy()) + _client = client.Client( + endpoint, session, proxy=self._user_parameters.proxy() + ) futures.append( - self._verified_request( - node, - _client(request, **req_args) - ) + self._verified_request(node, _client(request, **req_args)) ) except StopIteration: # When no more node is available, we go out of the while loop @@ -360,10 +358,10 @@ class BmaConnector: async with aiohttp.ClientSession() as session: for endpoint in endpoints: self._logger.debug("Trying to connect to: " + str(endpoint)) - _client = client.Client(endpoint, proxy=self._user_parameters.proxy()) - reply = asyncio.ensure_future( - _client(request, **req_args) + _client = client.Client( + endpoint, proxy=self._user_parameters.proxy() ) + reply = asyncio.ensure_future(_client(request, **req_args)) replies.append(reply) result = await asyncio.gather(*replies, return_exceptions=True) diff --git a/src/sakia/data/connectors/node.py b/src/sakia/data/connectors/node.py index 12a587d196c57593c3a44672a7e09fcbec82843a..35aaed6920df827f8220b9469ad4770951322b17 100644 --- a/src/sakia/data/connectors/node.py +++ b/src/sakia/data/connectors/node.py @@ -206,7 +206,9 @@ class NodeConnector(QObject): for endpoint in [e for e in self.node.endpoints if isinstance(e, BMAEndpoint)]: if not self._connected["block"]: try: - client = Client(endpoint, self.session, self._user_parameters.proxy()) + client = Client( + endpoint, self.session, self._user_parameters.proxy() + ) # Create Web Socket connection on block path (async method) ws = await client(bma.ws.block) # Type: WSConnection @@ -267,7 +269,9 @@ class NodeConnector(QObject): for endpoint in [e for e in self.node.endpoints if isinstance(e, BMAEndpoint)]: if not self._connected["peer"]: try: - client = Client(endpoint, self.session, self._user_parameters.proxy()) + client = Client( + endpoint, self.session, self._user_parameters.proxy() + ) # Create Web Socket connection on peer path (async method) ws = await client(bma.ws.peer) # Type: WSConnection @@ -406,12 +410,19 @@ class NodeConnector(QObject): for endpoint in [e for e in self.node.endpoints if isinstance(e, BMAEndpoint)]: try: heads_data = await self.safe_request( - endpoint, bma.network.ws2p_heads, proxy=self._user_parameters.proxy() + endpoint, + bma.network.ws2p_heads, + proxy=self._user_parameters.proxy(), ) if not heads_data: continue self.handle_success() - self._logger.debug('Connection to BMA succeeded (%s,%s,%s)', endpoint.server, endpoint.port, endpoint.API) + self._logger.debug( + "Connection to BMA succeeded (%s,%s,%s)", + endpoint.server, + endpoint.port, + endpoint.API, + ) return heads_data # Break endpoints loop except errors.DuniterError as e: self._logger.debug("Error in peers reply: {0}".format(str(e))) @@ -430,7 +441,9 @@ class NodeConnector(QObject): self.failure.emit(weight) -def get_bma_endpoint_from_server_address(address: str, port: int, secured: bool) -> Union[BMAEndpoint, SecuredBMAEndpoint]: +def get_bma_endpoint_from_server_address( + address: str, port: int, secured: bool +) -> Union[BMAEndpoint, SecuredBMAEndpoint]: """ Return a BMA Endpoint from server address parameters diff --git a/src/sakia/data/entities/connection.py b/src/sakia/data/entities/connection.py index 13be8ff8bc9c125ca09307b7d5748a0ef1bdaac4..263cbca78db871c3654429931001483e1d110717 100644 --- a/src/sakia/data/entities/connection.py +++ b/src/sakia/data/entities/connection.py @@ -14,9 +14,9 @@ class Connection: currency = attr.ib(converter=str) pubkey = attr.ib(converter=str) uid = attr.ib(converter=str, default="", cmp=False, hash=False) - scrypt_N = attr.ib(converter=int, default=SCRYPT_PARAMS['N'], cmp=False, hash=False) - scrypt_r = attr.ib(converter=int, default=SCRYPT_PARAMS['r'], cmp=False, hash=False) - scrypt_p = attr.ib(converter=int, default=SCRYPT_PARAMS['p'], cmp=False, hash=False) + scrypt_N = attr.ib(converter=int, default=SCRYPT_PARAMS["N"], cmp=False, hash=False) + scrypt_r = attr.ib(converter=int, default=SCRYPT_PARAMS["r"], cmp=False, hash=False) + scrypt_p = attr.ib(converter=int, default=SCRYPT_PARAMS["p"], cmp=False, hash=False) blockstamp = attr.ib( converter=block_uid, default=BlockUID.empty(), cmp=False, hash=False ) diff --git a/src/sakia/data/processors/blockchain.py b/src/sakia/data/processors/blockchain.py index eded32aaee3b8a2fe12e95331bd2c6575974f23a..6cebe17242ded634d78d7a5733ea249064531069 100644 --- a/src/sakia/data/processors/blockchain.py +++ b/src/sakia/data/processors/blockchain.py @@ -283,7 +283,9 @@ class BlockchainProcessor: blockchain.parameters.xpercent = parameters["xpercent"] blockchain.parameters.ms_validity = parameters["msValidity"] blockchain.parameters.step_max = parameters["stepMax"] - blockchain.parameters.median_time_blocks = parameters["medianTimeBlocks"] + blockchain.parameters.median_time_blocks = parameters[ + "medianTimeBlocks" + ] blockchain.parameters.avg_gen_time = parameters["avgGenTime"] blockchain.parameters.dt_diff_eval = parameters["dtDiffEval"] blockchain.parameters.percent_rot = parameters["percentRot"] @@ -329,7 +331,9 @@ class BlockchainProcessor: (blockchain.median_time - blockchain.parameters.ud_reeval_time_0) / blockchain.parameters.dt_reeval ) - self._logger.debug("nb_previous_reevaluations = {}".format(nb_previous_reevaluations)) + self._logger.debug( + "nb_previous_reevaluations = {}".format(nb_previous_reevaluations) + ) last_reeval_offset = blockchain.median_time - ( blockchain.parameters.ud_reeval_time_0 @@ -338,21 +342,35 @@ class BlockchainProcessor: self._logger.debug("last_reeval_offset = {}".format(last_reeval_offset)) # todo: improve this method or use a future API method returning reevaluation block numbers... - previous_dt_reeval_block_index = int(((nb_previous_reevaluations-1) * - (blockchain.parameters.dt_reeval/blockchain.parameters.dt)) + - (blockchain.parameters.dt_reeval/2/blockchain.parameters.dt)) + previous_dt_reeval_block_index = int( + ( + (nb_previous_reevaluations - 1) + * (blockchain.parameters.dt_reeval / blockchain.parameters.dt) + ) + + (blockchain.parameters.dt_reeval / 2 / blockchain.parameters.dt) + ) - self._logger.debug(" previous previous_dt_reeval_block_index = {}".format(previous_dt_reeval_block_index)) + self._logger.debug( + " previous previous_dt_reeval_block_index = {}".format( + previous_dt_reeval_block_index + ) + ) try: last_ud_reeval_block_number = blocks_with_ud[-1] except IndexError: last_ud_reeval_block_number = 0 - self._logger.debug("last_ud_reeval_block_number = {}".format(last_ud_reeval_block_number)) + self._logger.debug( + "last_ud_reeval_block_number = {}".format( + last_ud_reeval_block_number + ) + ) if last_ud_reeval_block_number: - self._logger.debug("Requesting last block with dividend reevaluation...") + self._logger.debug( + "Requesting last block with dividend reevaluation..." + ) block_with_ud = await self._bma_connector.get( currency, bma.blockchain.block, @@ -369,11 +387,17 @@ class BlockchainProcessor: self._logger.debug("Requesting previous block with dividend") try: - previous_ud_reeval_block_number = blocks_with_ud[previous_dt_reeval_block_index] + previous_ud_reeval_block_number = blocks_with_ud[ + previous_dt_reeval_block_index + ] except IndexError: previous_ud_reeval_block_number = min(blocks_with_ud) - self._logger.debug("previous_ud_reeval_block_number = {}".format(previous_ud_reeval_block_number)) + self._logger.debug( + "previous_ud_reeval_block_number = {}".format( + previous_ud_reeval_block_number + ) + ) self._logger.debug("Refresh previous UD reevaluation info in DB") diff --git a/src/sakia/data/processors/identities.py b/src/sakia/data/processors/identities.py index 381f32e64e7d9e07fb1cabd74717a21c3c7f1c4b..7416ce9b9cb66fc79322dbc081c3b993d124ef4b 100644 --- a/src/sakia/data/processors/identities.py +++ b/src/sakia/data/processors/identities.py @@ -111,7 +111,7 @@ class IdentitiesProcessor: currency=identity.currency, uid=identity.uid, pubkey=identity.pubkey, - blockstamp=BlockUID.empty() + blockstamp=BlockUID.empty(), ) # Same identity with empty blockstamp (incomplete) should not appears as duplicate # Beware that identities in block 0 have empty blockstamps ! @@ -216,7 +216,10 @@ class IdentitiesProcessor: identity.outdistanced = identity_data["outdistanced"] self.insert_or_update_identity(identity) except errors.DuniterError as e: - if e.ucode == errors.NO_MEMBER_MATCHING_PUB_OR_UID or e.message == 'MEMBER_NOT_FOUND': + if ( + e.ucode == errors.NO_MEMBER_MATCHING_PUB_OR_UID + or e.message == "MEMBER_NOT_FOUND" + ): identity.written = False self.insert_or_update_identity(identity) else: diff --git a/src/sakia/data/repositories/identities.py b/src/sakia/data/repositories/identities.py index aa192f4b7119f456504c53ae1df5a825efb3d28d..dc68bf74681535a9a7b3f413795a500c98a2b1d3 100644 --- a/src/sakia/data/repositories/identities.py +++ b/src/sakia/data/repositories/identities.py @@ -29,7 +29,7 @@ class IdentitiesRepo: currency=identity.currency, uid=identity.uid, pubkey=identity.pubkey, - blockstamp=BlockUID.empty() + blockstamp=BlockUID.empty(), ) # if same identity with empty blockstamp... if same_with_empty_blockstamp: diff --git a/src/sakia/gui/dialogs/connection_cfg/controller.py b/src/sakia/gui/dialogs/connection_cfg/controller.py index ebfbb033303d08efcae06a841716d09507ce5167..620bcf441160650f650e6460818cd306f852af97 100644 --- a/src/sakia/gui/dialogs/connection_cfg/controller.py +++ b/src/sakia/gui/dialogs/connection_cfg/controller.py @@ -100,7 +100,9 @@ class ConnectionConfigController(QObject): self.view.set_nodes_model(model) self.view.button_previous.setEnabled(False) - self.view.button_next.setText(QCoreApplication.translate("ConnectionConfigController", "Ok")) + self.view.button_next.setText( + QCoreApplication.translate("ConnectionConfigController", "Ok") + ) def init_name_page(self): """ @@ -135,9 +137,10 @@ class ConnectionConfigController(QObject): ) as e: self._logger.debug(str(e)) self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", + QCoreApplication.translate( + "ConnectionConfigController", "Could not connect. Check hostname, IP address or port: <br/>" - + str(e) + + str(e), ) ) self.step_node = asyncio.Future() @@ -164,14 +167,18 @@ class ConnectionConfigController(QObject): connection_identity = await self.step_key elif self.mode == ConnectionConfigController.CONNECT: self._logger.debug("Connect mode") - self.view.button_next.setText(QCoreApplication.translate("ConnectionConfigController", "Next")) + self.view.button_next.setText( + QCoreApplication.translate("ConnectionConfigController", "Next") + ) self.view.groupbox_pubkey.hide() self.view.button_next.clicked.connect(self.check_connect) self.view.stacked_pages.setCurrentWidget(self.view.page_connection) connection_identity = await self.step_key elif self.mode == ConnectionConfigController.WALLET: self._logger.debug("Wallet mode") - self.view.button_next.setText(QCoreApplication.translate("ConnectionConfigController", "Next")) + self.view.button_next.setText( + QCoreApplication.translate("ConnectionConfigController", "Next") + ) self.view.button_next.clicked.connect(self.check_wallet) self.view.edit_uid.hide() self.view.label_action.hide() @@ -180,11 +187,18 @@ class ConnectionConfigController(QObject): connection_identity = await self.step_key elif self.mode == ConnectionConfigController.PUBKEY: self._logger.debug("Pubkey mode") - self.view.button_next.setText(QCoreApplication.translate("ConnectionConfigController", "Next")) + self.view.button_next.setText( + QCoreApplication.translate("ConnectionConfigController", "Next") + ) self.view.button_next.clicked.connect(self.check_pubkey) - if not self.view.label_action.text().endswith(QCoreApplication.translate("ConnectionConfigController", " (Optional)")): + if not self.view.label_action.text().endswith( + QCoreApplication.translate("ConnectionConfigController", " (Optional)") + ): self.view.label_action.setText( - self.view.label_action.text() + QCoreApplication.translate("ConnectionConfigController", " (Optional)") + self.view.label_action.text() + + QCoreApplication.translate( + "ConnectionConfigController", " (Optional)" + ) ) self.view.groupbox_key.hide() self.view.stacked_pages.setCurrentWidget(self.view.page_connection) @@ -194,7 +208,11 @@ class ConnectionConfigController(QObject): self.view.set_progress_steps(6) try: if self.mode == ConnectionConfigController.REGISTER: - self.view.display_info(QCoreApplication.translate("ConnectionConfigController", "Broadcasting identity...")) + self.view.display_info( + QCoreApplication.translate( + "ConnectionConfigController", "Broadcasting identity..." + ) + ) self.view.stream_log("Broadcasting identity...") result = await self.model.publish_selfcert(connection_identity) if result[0]: @@ -279,45 +297,73 @@ class ConnectionConfigController(QObject): def check_key(self): if self.mode == ConnectionConfigController.PUBKEY: if len(self.view.edit_pubkey.text()) < 42: - self.view.label_info.setText(QCoreApplication.translate("ConnectionConfigController", "Forbidden: pubkey is too short")) + self.view.label_info.setText( + QCoreApplication.translate( + "ConnectionConfigController", "Forbidden: pubkey is too short" + ) + ) return False if len(self.view.edit_pubkey.text()) > 45: - self.view.label_info.setText(QCoreApplication.translate("ConnectionConfigController", "Forbidden: pubkey is too long")) + self.view.label_info.setText( + QCoreApplication.translate( + "ConnectionConfigController", "Forbidden: pubkey is too long" + ) + ) return False else: if self.view.edit_password.text() != self.view.edit_password_repeat.text(): - self.view.label_info.setText(QCoreApplication.translate("ConnectionConfigController", "Error: passwords are different")) + self.view.label_info.setText( + QCoreApplication.translate( + "ConnectionConfigController", "Error: passwords are different" + ) + ) return False if self.view.edit_salt.text() != self.view.edit_salt_bis.text(): self.view.label_info.setText( - QCoreApplication.translate("ConnectionConfigController", "Error: salts are different") + QCoreApplication.translate( + "ConnectionConfigController", "Error: salts are different" + ) ) return False if detect_non_printable(self.view.edit_salt.text()): self.view.label_info.setText( - QCoreApplication.translate("ConnectionConfigController", "Forbidden: invalid characters in salt") + QCoreApplication.translate( + "ConnectionConfigController", + "Forbidden: invalid characters in salt", + ) ) return False if detect_non_printable(self.view.edit_password.text()): self.view.label_info.setText( - QCoreApplication.translate("ConnectionConfigController", "Forbidden: invalid characters in password") + QCoreApplication.translate( + "ConnectionConfigController", + "Forbidden: invalid characters in password", + ) ) return False if self.model.app.parameters.expert_mode: - self.view.label_info.setText(QCoreApplication.translate("ConnectionConfigController", "")) + self.view.label_info.setText( + QCoreApplication.translate("ConnectionConfigController", "") + ) return True if len(self.view.edit_salt.text()) < 6: - self.view.label_info.setText(QCoreApplication.translate("ConnectionConfigController", "Forbidden: salt is too short")) + self.view.label_info.setText( + QCoreApplication.translate( + "ConnectionConfigController", "Forbidden: salt is too short" + ) + ) return False if len(self.view.edit_password.text()) < 6: self.view.label_info.setText( - QCoreApplication.translate("ConnectionConfigController", "Forbidden: password is too short") + QCoreApplication.translate( + "ConnectionConfigController", "Forbidden: password is too short" + ) ) return False @@ -329,10 +375,15 @@ class ConnectionConfigController(QObject): # Testable way of using a QFileDialog selected_files = await QAsyncFileDialog.get_save_filename( self.view, - QCoreApplication.translate("ConnectionConfigController", "Save a revocation document"), - "revocation-{uid}-{pubkey}-{currency}.txt".format(uid=identity.uid, pubkey=identity.pubkey[:8], - currency=identity.currency), - QCoreApplication.translate("ConnectionConfigController", "All text files (*.txt)"), + QCoreApplication.translate( + "ConnectionConfigController", "Save a revocation document" + ), + "revocation-{uid}-{pubkey}-{currency}.txt".format( + uid=identity.uid, pubkey=identity.pubkey[:8], currency=identity.currency + ), + QCoreApplication.translate( + "ConnectionConfigController", "All text files (*.txt)" + ), ) if selected_files: path = selected_files[0] @@ -343,11 +394,14 @@ class ConnectionConfigController(QObject): dialog = QMessageBox( QMessageBox.Information, - QCoreApplication.translate("ConnectionConfigController", "Revocation file"), - QCoreApplication.translate("ConnectionConfigController", + QCoreApplication.translate( + "ConnectionConfigController", "Revocation file" + ), + QCoreApplication.translate( + "ConnectionConfigController", """<div>Your revocation document has been saved.</div> <div><b>Please keep it in a safe place.</b></div> -The publication of this document will revoke your identity on the network.</p>""" +The publication of this document will revoke your identity on the network.</p>""", ), QMessageBox.Ok, ) @@ -358,7 +412,9 @@ The publication of this document will revoke your identity on the network.</p>"" @asyncify async def check_pubkey(self, checked=False): self._logger.debug("Is valid ? ") - self.view.display_info(QCoreApplication.translate("ConnectionConfigController", "connecting...")) + self.view.display_info( + QCoreApplication.translate("ConnectionConfigController", "connecting...") + ) self.view.button_next.setDisabled(True) try: self.model.set_pubkey(self.view.edit_pubkey.text(), self.view.scrypt_params) @@ -371,15 +427,19 @@ The publication of this document will revoke your identity on the network.</p>"" if self.view.edit_uid.text(): if registered[0] is False and registered[2] is None: self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", "Could not find your identity on the network.") + QCoreApplication.translate( + "ConnectionConfigController", + "Could not find your identity on the network.", + ) ) elif registered[0] is False and registered[2]: self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", + QCoreApplication.translate( + "ConnectionConfigController", """Your pubkey or UID is different on the network. Yours: {0}, the network: {1}""".format( registered[1], registered[2] - ) + ), ) ) else: @@ -395,18 +455,26 @@ Yours: {0}, the network: {1}""".format( self.step_key.set_result(None) else: self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", "An account already exists using this key.") + QCoreApplication.translate( + "ConnectionConfigController", + "An account already exists using this key.", + ) ) except NoPeerAvailable: self.config_dialog.label_error.setText( - QCoreApplication.translate("ConnectionConfigController", "Could not connect. Check node peering entry") + QCoreApplication.translate( + "ConnectionConfigController", + "Could not connect. Check node peering entry", + ) ) @asyncify async def check_wallet(self, checked=False): self._logger.debug("Is valid ? ") - self.view.display_info(QCoreApplication.translate("ConnectionConfigController", "connecting...")) + self.view.display_info( + QCoreApplication.translate("ConnectionConfigController", "connecting...") + ) try: salt = self.view.edit_salt.text() password = self.view.edit_password.text() @@ -421,11 +489,12 @@ Yours: {0}, the network: {1}""".format( self.step_key.set_result(None) elif registered[2]: self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", + QCoreApplication.translate( + "ConnectionConfigController", """Your pubkey is associated to an identity. Yours: {0}, the network: {1}""".format( registered[1], registered[2] - ) + ), ) ) except DuniterError as e: @@ -434,18 +503,26 @@ Yours: {0}, the network: {1}""".format( self.view.display_info(str(e)) else: self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", "An account already exists using this key.") + QCoreApplication.translate( + "ConnectionConfigController", + "An account already exists using this key.", + ) ) except NoPeerAvailable: self.config_dialog.label_error.setText( - QCoreApplication.translate("ConnectionConfigController", "Could not connect. Check node peering entry") + QCoreApplication.translate( + "ConnectionConfigController", + "Could not connect. Check node peering entry", + ) ) @asyncify async def check_connect(self, checked=False): self._logger.debug("Is valid ? ") - self.view.display_info(QCoreApplication.translate("ConnectionConfigController", "connecting...")) + self.view.display_info( + QCoreApplication.translate("ConnectionConfigController", "connecting...") + ) try: salt = self.view.edit_salt.text() password = self.view.edit_password.text() @@ -458,15 +535,19 @@ Yours: {0}, the network: {1}""".format( self.view.button_register.setEnabled(True) if registered[0] is False and registered[2] is None: self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", "Could not find your identity on the network.") + QCoreApplication.translate( + "ConnectionConfigController", + "Could not find your identity on the network.", + ) ) elif registered[0] is False and registered[2]: self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", + QCoreApplication.translate( + "ConnectionConfigController", """Your pubkey or UID is different on the network. Yours: {0}, the network: {1}""".format( registered[1], registered[2] - ) + ), ) ) else: @@ -477,18 +558,26 @@ Yours: {0}, the network: {1}""".format( self.view.display_info(str(e)) else: self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", "An account already exists using this key.") + QCoreApplication.translate( + "ConnectionConfigController", + "An account already exists using this key.", + ) ) except NoPeerAvailable: self.config_dialog.label_error.setText( - QCoreApplication.translate("ConnectionConfigController", "Could not connect. Check node peering entry") + QCoreApplication.translate( + "ConnectionConfigController", + "Could not connect. Check node peering entry", + ) ) @asyncify async def check_register(self, checked=False): self._logger.debug("Is valid ? ") - self.view.display_info(QCoreApplication.translate("ConnectionConfigController", "connecting...")) + self.view.display_info( + QCoreApplication.translate("ConnectionConfigController", "connecting...") + ) try: salt = self.view.edit_salt.text() password = self.view.edit_password.text() @@ -507,11 +596,12 @@ Yours: {0}, the network: {1}""".format( ) elif registered[0] is False and registered[2]: self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", + QCoreApplication.translate( + "ConnectionConfigController", """Your pubkey or UID was already found on the network. Yours: {0}, the network: {1}""".format( registered[1], registered[2] - ) + ), ) ) else: @@ -524,11 +614,17 @@ Yours: {0}, the network: {1}""".format( self.view.display_info(str(e)) else: self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", "An account already exists using this key.") + QCoreApplication.translate( + "ConnectionConfigController", + "An account already exists using this key.", + ) ) except NoPeerAvailable: self.view.display_info( - QCoreApplication.translate("ConnectionConfigController", "Could not connect. Check node peering entry") + QCoreApplication.translate( + "ConnectionConfigController", + "Could not connect. Check node peering entry", + ) ) @asyncify diff --git a/src/sakia/gui/dialogs/connection_cfg/view.py b/src/sakia/gui/dialogs/connection_cfg/view.py index f4de8820cd228a0e2eb94340566b73ab9326bbb4..4cf47f889889a2ab55293d5e5bb20231d3c7f8d2 100644 --- a/src/sakia/gui/dialogs/connection_cfg/view.py +++ b/src/sakia/gui/dialogs/connection_cfg/view.py @@ -120,19 +120,31 @@ class ConnectionConfigView(QDialog, Ui_ConnectionConfigurationDialog): async def show_success(self, notification): if notification: toast.display( - QCoreApplication.translate("ConnectionConfigView", "UID broadcast"), QCoreApplication.translate("ConnectionConfigView", "Identity broadcasted to the network") + QCoreApplication.translate("ConnectionConfigView", "UID broadcast"), + QCoreApplication.translate( + "ConnectionConfigView", "Identity broadcasted to the network" + ), ) else: await QAsyncMessageBox.information( self, QCoreApplication.translate("ConnectionConfigView", "UID broadcast"), - QCoreApplication.translate("ConnectionConfigView", "Identity broadcasted to the network"), + QCoreApplication.translate( + "ConnectionConfigView", "Identity broadcasted to the network" + ), ) def show_error(self, notification, error_txt): if notification: - toast.display(QCoreApplication.translate("ConnectionConfigView", "UID broadcast"), error_txt) - self.label_info.setText(QCoreApplication.translate("ConnectionConfigView", "Error") + " " + error_txt) + toast.display( + QCoreApplication.translate("ConnectionConfigView", "UID broadcast"), + error_txt, + ) + self.label_info.setText( + QCoreApplication.translate("ConnectionConfigView", "Error") + + " " + + error_txt + ) def set_nodes_model(self, model): self.tree_peers.setModel(model) @@ -142,9 +154,9 @@ class ConnectionConfigView(QDialog, Ui_ConnectionConfigurationDialog): Hide unecessary buttons and display correct title """ self.setWindowTitle( - QCoreApplication.translate("ConnectionConfigView", "New account on {0} network").format( - ROOT_SERVERS[currency]["display"] - ) + QCoreApplication.translate( + "ConnectionConfigView", "New account on {0} network" + ).format(ROOT_SERVERS[currency]["display"]) ) def action_show_pubkey(self): @@ -191,7 +203,10 @@ class ConnectionConfigView(QDialog, Ui_ConnectionConfigurationDialog): QDateTime.fromTime_t(remaining).toUTC().toString("hh:mm:ss") ) self.progress_bar.setFormat( - QCoreApplication.translate("ConnectionConfigView", "{0} remaining...".format(displayed_remaining_time)) + QCoreApplication.translate( + "ConnectionConfigView", + "{0} remaining...".format(displayed_remaining_time), + ) ) self.progress_bar.setValue(next_value) self.timer.restart() @@ -213,16 +228,17 @@ class ConnectionConfigView(QDialog, Ui_ConnectionConfigurationDialog): days, hours, minutes, seconds = timestamp_to_dhms( blockchain_parameters.idty_window ) - expiration_time_str = QCoreApplication.translate("ConnectionConfigView", "{days} days, {hours}h and {min}min").format( - days=days, hours=hours, min=minutes - ) + expiration_time_str = QCoreApplication.translate( + "ConnectionConfigView", "{days} days, {hours}h and {min}min" + ).format(days=days, hours=hours, min=minutes) dialog = QDialog(self) about_dialog = Ui_CongratulationPopup() about_dialog.setupUi(dialog) dialog.setWindowTitle("Identity registration") about_dialog.label.setText( - QCoreApplication.translate("ConnectionConfigView", + QCoreApplication.translate( + "ConnectionConfigView", """ <p><b>Congratulations!</b><br> <br> @@ -239,7 +255,7 @@ the process will have to be restarted from scratch.</p> """.format( certs=blockchain_parameters.sig_qty, expiration_time_str=expiration_time_str, - ) + ), ) ) diff --git a/src/sakia/gui/dialogs/contact/table_model.py b/src/sakia/gui/dialogs/contact/table_model.py index 2f2d24821e2d34eb6e4bdb1accaeb36d08e42e54..f3b974cbb731d5a064397d038eff172f61b6213f 100644 --- a/src/sakia/gui/dialogs/contact/table_model.py +++ b/src/sakia/gui/dialogs/contact/table_model.py @@ -5,7 +5,7 @@ from PyQt5.QtCore import ( QSortFilterProxyModel, QModelIndex, QCoreApplication, - QT_TRANSLATE_NOOP + QT_TRANSLATE_NOOP, ) from sakia.data.processors import ContactsProcessor @@ -72,7 +72,7 @@ class ContactsTableModel(QAbstractTableModel): # mark strings as translatable string columns_headers = ( QT_TRANSLATE_NOOP("ContactsTableModel", "Name"), - QT_TRANSLATE_NOOP("ContactsTableModel", "Public key") + QT_TRANSLATE_NOOP("ContactsTableModel", "Public key"), ) def __init__(self, parent, app): @@ -141,7 +141,9 @@ class ContactsTableModel(QAbstractTableModel): def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: - return QCoreApplication.translate("ContactsTableModel", ContactsTableModel.columns_headers[section]) + return QCoreApplication.translate( + "ContactsTableModel", ContactsTableModel.columns_headers[section] + ) def data(self, index, role): row = index.row() diff --git a/src/sakia/gui/dialogs/plugins_manager/controller.py b/src/sakia/gui/dialogs/plugins_manager/controller.py index 53bf26eb62e7d29de377f3f5843dab0fbd2a085e..4c2dae17563392138b6aeb03b3fb7ccec77b5bf9 100644 --- a/src/sakia/gui/dialogs/plugins_manager/controller.py +++ b/src/sakia/gui/dialogs/plugins_manager/controller.py @@ -58,7 +58,12 @@ class PluginsManagerController(QObject): def install_plugin(self): filename = QFileDialog.getOpenFileName( - self.view, QCoreApplication.translate("PluginsManagerController", "Open File"), "", QCoreApplication.translate("PluginsManagerController", "Sakia module (*.zip)") + self.view, + QCoreApplication.translate("PluginsManagerController", "Open File"), + "", + QCoreApplication.translate( + "PluginsManagerController", "Sakia module (*.zip)" + ), ) if filename[0]: self.model.install_plugin(filename[0]) diff --git a/src/sakia/gui/dialogs/plugins_manager/table_model.py b/src/sakia/gui/dialogs/plugins_manager/table_model.py index f5e73d17aa5b85ac3cbd65f71652fefc521f0530..b488f9c76c5fc8157f5fdf99cb92f8e39a4a94ff 100644 --- a/src/sakia/gui/dialogs/plugins_manager/table_model.py +++ b/src/sakia/gui/dialogs/plugins_manager/table_model.py @@ -5,7 +5,8 @@ from PyQt5.QtCore import ( QSortFilterProxyModel, QModelIndex, QT_TRANSLATE_NOOP, - QCoreApplication) + QCoreApplication, +) from sakia.data.entities import Plugin @@ -118,7 +119,9 @@ class PluginsTableModel(QAbstractTableModel): def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: - return QCoreApplication.translate("PluginsTableModel", PluginsTableModel.columns_headers[section]) + return QCoreApplication.translate( + "PluginsTableModel", PluginsTableModel.columns_headers[section] + ) def data(self, index, role): row = index.row() diff --git a/src/sakia/gui/dialogs/plugins_manager/view.py b/src/sakia/gui/dialogs/plugins_manager/view.py index acf7fac7b06978ee53115dcb937ae80c4ae6d387..59854e1b95c45a82be560a2736e2a8e879c73135 100644 --- a/src/sakia/gui/dialogs/plugins_manager/view.py +++ b/src/sakia/gui/dialogs/plugins_manager/view.py @@ -43,5 +43,7 @@ class PluginsManagerView(QDialog, Ui_PluginDialog): QMessageBox.critical( self, QCoreApplication.translate("PluginsManagerView", "Plugin import"), - QCoreApplication.translate("PluginsManagerView", "Could not import plugin: {0}".format(error_txt)), + QCoreApplication.translate( + "PluginsManagerView", "Could not import plugin: {0}".format(error_txt) + ), ) diff --git a/src/sakia/gui/dialogs/revocation/view.py b/src/sakia/gui/dialogs/revocation/view.py index c13116cc82b171e2b704950d921be8b0fc309f18..28a165abab665a4fc2e449f3b9f9b0c19b2b9f92 100644 --- a/src/sakia/gui/dialogs/revocation/view.py +++ b/src/sakia/gui/dialogs/revocation/view.py @@ -46,16 +46,18 @@ class RevocationView(QDialog, Ui_RevocationDialog): def refresh_target(self): if self.radio_currency.isChecked(): - target = QCoreApplication.translate("RevocationView", + target = QCoreApplication.translate( + "RevocationView", "All nodes of currency {name}".format( name=self.combo_currency.currentText() - ) + ), ) elif self.radio_address.isChecked(): - target = QCoreApplication.translate("RevocationView", + target = QCoreApplication.translate( + "RevocationView", "Address {address}:{port}".format( address=self.edit_address.text(), port=self.spinbox_port.value() - ) + ), ) else: target = "" @@ -70,7 +72,8 @@ class RevocationView(QDialog, Ui_RevocationDialog): def refresh_revocation_label(self, revoked_identity): if revoked_identity: - text = QCoreApplication.translate("RevocationView", + text = QCoreApplication.translate( + "RevocationView", """ <div>Identity revoked: {uid} (public key: {pubkey}...)</div> <div>Identity signed on block: {timestamp}</div> @@ -78,22 +81,24 @@ class RevocationView(QDialog, Ui_RevocationDialog): uid=revoked_identity.uid, pubkey=revoked_identity.pubkey[:12], timestamp=revoked_identity.timestamp, - ) + ), ) self.label_revocation_content.setText(text) if self.radio_currency.isChecked(): - target = QCoreApplication.translate("RevocationView", + target = QCoreApplication.translate( + "RevocationView", "All nodes of currency {name}".format( name=self.combo_currency.currentText() - ) + ), ) elif self.radio_address.isChecked(): - target = QCoreApplication.translate("RevocationView", + target = QCoreApplication.translate( + "RevocationView", "Address {address}:{port}".format( address=self.edit_address.text(), port=self.spinbox_port.value() - ) + ), ) else: target = "" @@ -128,17 +133,22 @@ class RevocationView(QDialog, Ui_RevocationDialog): QMessageBox.critical( self, QCoreApplication.translate("RevocationView", "Error loading document"), - QCoreApplication.translate("RevocationView", "Loaded document is not a revocation document"), + QCoreApplication.translate( + "RevocationView", "Loaded document is not a revocation document" + ), buttons=QMessageBox.Ok, ) async def revocation_broadcast_error(self, error): await QAsyncMessageBox.critical( - self, QCoreApplication.translate("RevocationView", "Error broadcasting document"), error + self, + QCoreApplication.translate("RevocationView", "Error broadcasting document"), + error, ) def show_revoked_selfcert(self, selfcert): - text = QCoreApplication.translate("RevocationView", + text = QCoreApplication.translate( + "RevocationView", """ <div>Identity revoked: {uid} (public key: {pubkey}...)</div> <div>Identity signed on block: {timestamp}</div> @@ -146,7 +156,7 @@ class RevocationView(QDialog, Ui_RevocationDialog): uid=selfcert.uid, pubkey=selfcert.pubkey[:12], timestamp=selfcert.timestamp, - ) + ), ) self.label_revocation_content.setText(text) @@ -160,7 +170,8 @@ class RevocationView(QDialog, Ui_RevocationDialog): answer = QMessageBox.warning( self, QCoreApplication.translate("RevocationView", "Revocation"), - QCoreApplication.translate("RevocationView", + QCoreApplication.translate( + "RevocationView", """<h4>The publication of this document will revoke your identity on the network.</h4> <li> <li> <b>This identity won't be able to join the WoT anymore.</b> </li> @@ -168,7 +179,7 @@ class RevocationView(QDialog, Ui_RevocationDialog): <li> <b>This identity won't be able to certify identities anymore.</b> </li> </li> Please think twice before publishing this document. - """ + """, ), QMessageBox.Ok | QMessageBox.Cancel, ) @@ -179,6 +190,8 @@ class RevocationView(QDialog, Ui_RevocationDialog): await QAsyncMessageBox.information( self, QCoreApplication.translate("RevocationView", "Revocation broadcast"), - QCoreApplication.translate("RevocationView", "The document was successfully broadcasted."), + QCoreApplication.translate( + "RevocationView", "The document was successfully broadcasted." + ), ) super().accept() diff --git a/src/sakia/gui/main_window/controller.py b/src/sakia/gui/main_window/controller.py index 4224c4910e15417e38341cb51944db0d1f6a38a9..18be94e1fe3832e38959ed38853b8da919d5373b 100644 --- a/src/sakia/gui/main_window/controller.py +++ b/src/sakia/gui/main_window/controller.py @@ -108,9 +108,9 @@ class MainWindowController(QObject): latest = self.app.available_version logging.debug("Latest version requested") if not latest[0]: - version_info = QCoreApplication.translate("MainWindowController", "Please get the latest release {version}").format( - version=latest[1] - ) + version_info = QCoreApplication.translate( + "MainWindowController", "Please get the latest release {version}" + ).format(version=latest[1]) version_url = latest[2] if self.app.preferences["notifications"]: @@ -130,7 +130,9 @@ class MainWindowController(QObject): self.status_bar.refresh() display_name = ROOT_SERVERS[currency]["display"] self.view.setWindowTitle( - QCoreApplication.translate("MainWindowController", "sakia {0} - {1}").format(__version__, display_name) + QCoreApplication.translate( + "MainWindowController", "sakia {0} - {1}" + ).format(__version__, display_name) ) def eventFilter(self, target, event): diff --git a/src/sakia/gui/main_window/status_bar/controller.py b/src/sakia/gui/main_window/status_bar/controller.py index 80ab9ca8b2305177cf4d4bd15f4efab5bbfc8eb7..0a7c0cf0390d22679dee0657642979297246edf7 100644 --- a/src/sakia/gui/main_window/status_bar/controller.py +++ b/src/sakia/gui/main_window/status_bar/controller.py @@ -74,9 +74,9 @@ class StatusBarController(QObject): QLocale.dateTimeFormat(QLocale(), QLocale.NarrowFormat), ) self.view.status_label.setText( - QCoreApplication.translate("StatusBarController", "Blockchain sync: {0} BAT ({1})").format( - str_time, str(current_block)[:15] - ) + QCoreApplication.translate( + "StatusBarController", "Blockchain sync: {0} BAT ({1})" + ).format(str_time, str(current_block)[:15]) ) def refresh(self): diff --git a/src/sakia/gui/main_window/toolbar/controller.py b/src/sakia/gui/main_window/toolbar/controller.py index c641d872ed2c96f0f388756e0c8756cd77a11166..c1b988ac7c2fb2334c4f237607b91fab92bb61da 100644 --- a/src/sakia/gui/main_window/toolbar/controller.py +++ b/src/sakia/gui/main_window/toolbar/controller.py @@ -111,10 +111,18 @@ class ToolbarController(QObject): :return: """ self.action_publish_uid.setText( - QCoreApplication.translate("ToolbarController", ToolbarController.action_publish_uid_text) + QCoreApplication.translate( + "ToolbarController", ToolbarController.action_publish_uid_text + ) ) self.action_revoke_uid.setText( - QCoreApplication.translate("ToolbarController", ToolbarController.action_revoke_uid_text) + QCoreApplication.translate( + "ToolbarController", ToolbarController.action_revoke_uid_text + ) + ) + self.action_showinfo.setText( + QCoreApplication.translate( + "ToolbarController", ToolbarController.action_showinfo_text + ) ) - self.action_showinfo.setText(QCoreApplication.translate("ToolbarController", ToolbarController.action_showinfo_text)) super().retranslateUi(self) diff --git a/src/sakia/gui/main_window/toolbar/model.py b/src/sakia/gui/main_window/toolbar/model.py index c26b75d69466da46ba15522c81df9d71e48c6d10..4fa75079fa6fc17e39357d8413a1f897ee421396 100644 --- a/src/sakia/gui/main_window/toolbar/model.py +++ b/src/sakia/gui/main_window/toolbar/model.py @@ -112,7 +112,9 @@ class ToolbarModel(QObject): ).diff_localized(False, True) localized_data["mass"] = self.app.current_ref.instance( - self.blockchain_service.last_monetary_mass(), self.app.currency, self.app + self.blockchain_service.last_monetary_mass(), + self.app.currency, + self.app, ).localized(False, True) ud_median_time = self.blockchain_service.last_ud_time() @@ -154,13 +156,9 @@ class ToolbarModel(QObject): else last_mass / last_members_count ) localized_data["members_count"] = last_members_count - localized_data[ - "mass_per_member" - ] = self.app.current_ref.instance( + localized_data["mass_per_member"] = self.app.current_ref.instance( mass_per_member, self.app.currency, self.app - ).localized( - False, True - ) + ).localized(False, True) # avoid divide by zero ! if last_members_count == 0: localized_data["actual_growth"] = float(0) diff --git a/src/sakia/gui/main_window/toolbar/view.py b/src/sakia/gui/main_window/toolbar/view.py index 71f737312d6ac1f517cd384e71ce9c2f5cd709a7..9097185173a8643c275a2c89bf4dc66d87f2ff07 100644 --- a/src/sakia/gui/main_window/toolbar/view.py +++ b/src/sakia/gui/main_window/toolbar/view.py @@ -32,29 +32,44 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): super().__init__(parent) self.setupUi(self) - tool_menu = QMenu(QCoreApplication.translate("ToolbarView", "Tools"), self.toolbutton_menu) + tool_menu = QMenu( + QCoreApplication.translate("ToolbarView", "Tools"), self.toolbutton_menu + ) self.toolbutton_menu.setMenu(tool_menu) - self.action_add_connection = QAction(QCoreApplication.translate("ToolbarView", "Add an Sakia account"), tool_menu) + self.action_add_connection = QAction( + QCoreApplication.translate("ToolbarView", "Add an Sakia account"), tool_menu + ) tool_menu.addAction(self.action_add_connection) self.action_revoke_uid = QAction( - QCoreApplication.translate("ToolbarView", ToolbarView._action_revoke_uid_text), self + QCoreApplication.translate( + "ToolbarView", ToolbarView._action_revoke_uid_text + ), + self, ) tool_menu.addAction(self.action_revoke_uid) - self.action_parameters = QAction(QCoreApplication.translate("ToolbarView", "Settings"), tool_menu) + self.action_parameters = QAction( + QCoreApplication.translate("ToolbarView", "Settings"), tool_menu + ) tool_menu.addAction(self.action_parameters) - self.action_plugins = QAction(QCoreApplication.translate("ToolbarView", "Plugins manager"), tool_menu) + self.action_plugins = QAction( + QCoreApplication.translate("ToolbarView", "Plugins manager"), tool_menu + ) tool_menu.addAction(self.action_plugins) tool_menu.addSeparator() - about_menu = QMenu(QCoreApplication.translate("ToolbarView", "About"), tool_menu) + about_menu = QMenu( + QCoreApplication.translate("ToolbarView", "About"), tool_menu + ) tool_menu.addMenu(about_menu) - self.action_about_money = QAction(QCoreApplication.translate("ToolbarView", "About Money"), about_menu) + self.action_about_money = QAction( + QCoreApplication.translate("ToolbarView", "About Money"), about_menu + ) about_menu.addAction(self.action_about_money) self.action_about_referentials = QAction( @@ -62,13 +77,19 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): ) about_menu.addAction(self.action_about_referentials) - self.action_about_wot = QAction(QCoreApplication.translate("ToolbarView", "About Web of Trust"), about_menu) + self.action_about_wot = QAction( + QCoreApplication.translate("ToolbarView", "About Web of Trust"), about_menu + ) about_menu.addAction(self.action_about_wot) - self.action_about = QAction(QCoreApplication.translate("ToolbarView", "About Sakia"), about_menu) + self.action_about = QAction( + QCoreApplication.translate("ToolbarView", "About Sakia"), about_menu + ) about_menu.addAction(self.action_about) - self.action_exit = QAction(QCoreApplication.translate("ToolbarView", "Quit"), tool_menu) + self.action_exit = QAction( + QCoreApplication.translate("ToolbarView", "Quit"), tool_menu + ) tool_menu.addAction(self.action_exit) self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Minimum) @@ -98,8 +119,12 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): connections_titles = [c.title() for c in connections] input_dialog = QInputDialog() input_dialog.setComboBoxItems(connections_titles) - input_dialog.setWindowTitle(QCoreApplication.translate("ToolbarView", "Membership")) - input_dialog.setLabelText(QCoreApplication.translate("ToolbarView", "Select an account")) + input_dialog.setWindowTitle( + QCoreApplication.translate("ToolbarView", "Membership") + ) + input_dialog.setLabelText( + QCoreApplication.translate("ToolbarView", "Select an account") + ) await dialog_async_exec(input_dialog) result = input_dialog.textValue() @@ -120,7 +145,8 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): # set infos in label about_dialog.label_wot.setText( - QCoreApplication.translate("ToolbarView", + QCoreApplication.translate( + "ToolbarView", """ <table cellpadding="5"> <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> @@ -132,31 +158,50 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> </table> -""" +""", ).format( QLocale().toString(params.sig_period / 86400, "f", 2), - QCoreApplication.translate("ToolbarView", "Minimum delay between 2 certifications (days)"), + QCoreApplication.translate( + "ToolbarView", "Minimum delay between 2 certifications (days)" + ), QLocale().toString(params.sig_validity / 86400, "f", 2), - QCoreApplication.translate("ToolbarView", "Maximum validity time of a certification (days)"), + QCoreApplication.translate( + "ToolbarView", "Maximum validity time of a certification (days)" + ), params.sig_qty, - QCoreApplication.translate("ToolbarView", "Minimum quantity of certifications to be part of the WoT"), + QCoreApplication.translate( + "ToolbarView", + "Minimum quantity of certifications to be part of the WoT", + ), params.sig_stock, - QCoreApplication.translate("ToolbarView", "Maximum quantity of active certifications per member"), + QCoreApplication.translate( + "ToolbarView", + "Maximum quantity of active certifications per member", + ), QLocale().toString(params.sig_window / 86400, "f", 2), - QCoreApplication.translate("ToolbarView", - "Maximum time a certification can wait before being in blockchain (days)" + QCoreApplication.translate( + "ToolbarView", + "Maximum time a certification can wait before being in blockchain (days)", ), params.xpercent * 100, - QCoreApplication.translate("ToolbarView", - "Minimum percent of sentries to reach to match the distance rule" + QCoreApplication.translate( + "ToolbarView", + "Minimum percent of sentries to reach to match the distance rule", ), params.ms_validity / 86400, - QCoreApplication.translate("ToolbarView", "Maximum validity time of a membership (days)"), + QCoreApplication.translate( + "ToolbarView", "Maximum validity time of a membership (days)" + ), params.step_max, - QCoreApplication.translate("ToolbarView", "Maximum distance between each WoT member and a newcomer"), + QCoreApplication.translate( + "ToolbarView", + "Maximum distance between each WoT member and a newcomer", + ), ) ) - dialog.setWindowTitle(QCoreApplication.translate("ToolbarView", "Web of Trust rules")) + dialog.setWindowTitle( + QCoreApplication.translate("ToolbarView", "Web of Trust rules") + ) dialog.exec() def show_about_money(self, params, currency, localized_data): @@ -190,7 +235,8 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): :return: """ # set infos in label - return QCoreApplication.translate("ToolbarView", + return QCoreApplication.translate( + "ToolbarView", """ <table cellpadding="5"> <tr><td align="right"><b>{:}</b></div></td><td>{:} {:}</td></tr> @@ -202,7 +248,7 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> </table> - """ + """, ).format( localized_data.get("ud", "####"), QCoreApplication.translate("ToolbarView", "Universal Dividend UD(t) in"), @@ -213,11 +259,15 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): localized_data.get("members_count", "####"), QCoreApplication.translate("ToolbarView", "Members N(t)"), localized_data.get("mass_per_member", "####"), - QCoreApplication.translate("ToolbarView", "Monetary Mass per member M(t)/N(t) in"), + QCoreApplication.translate( + "ToolbarView", "Monetary Mass per member M(t)/N(t) in" + ), localized_data["diff_units"], localized_data.get("actual_growth", 0), QCoreApplication.translate("ToolbarView", "day"), - QCoreApplication.translate("ToolbarView", "Actual growth c = UD(t)/[M(t)/N(t)]"), + QCoreApplication.translate( + "ToolbarView", "Actual growth c = UD(t)/[M(t)/N(t)]" + ), # todo: wait for accurate datetime of reevaluation # localized_data.get("ud_median_time_minus_1", "####"), # QCoreApplication.translate("ToolbarView", "Penultimate UD date and time (t-1)"), @@ -236,19 +286,25 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): :return: """ # set infos in label - return QCoreApplication.translate("ToolbarView", + return QCoreApplication.translate( + "ToolbarView", """ <table cellpadding="5"> <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> </table> - """ + """, ).format( QCoreApplication.translate("ToolbarView", "{:2.2%} / {:} days").format( localized_data["growth"], localized_data["dt_reeval_in_days"] ), - QCoreApplication.translate("ToolbarView", "Fundamental growth (c) / Reevaluation delta time (dt_reeval)"), - QCoreApplication.translate("ToolbarView", "UDĞ(t) = UDĞ(t-1) + c²*M(t-1)/N(t)"), + QCoreApplication.translate( + "ToolbarView", + "Fundamental growth (c) / Reevaluation delta time (dt_reeval)", + ), + QCoreApplication.translate( + "ToolbarView", "UDĞ(t) = UDĞ(t-1) + c²*M(t-1)/N(t)" + ), QCoreApplication.translate("ToolbarView", "Universal Dividend (formula)"), # fixme: re-display when the computed dividend will be accurate (need accurate previous monetary mass, # last mass just before reevaluation) @@ -295,16 +351,23 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): dt_dhms = timestamp_to_dhms(params.dt) if dt_dhms[0] > 0: - dt_as_str = QCoreApplication.translate("ToolbarView", "{:} day(s) {:} hour(s)").format(*dt_dhms) + dt_as_str = QCoreApplication.translate( + "ToolbarView", "{:} day(s) {:} hour(s)" + ).format(*dt_dhms) else: - dt_as_str = QCoreApplication.translate("ToolbarView", "{:} hour(s)").format(dt_dhms[1]) + dt_as_str = QCoreApplication.translate("ToolbarView", "{:} hour(s)").format( + dt_dhms[1] + ) if dt_dhms[2] > 0 or dt_dhms[3] > 0: dt_dhms += ", {:} minute(s) and {:} second(s)".format(*dt_dhms[1:]) dt_reeval_dhms = timestamp_to_dhms(params.dt_reeval) - dt_reeval_as_str = QCoreApplication.translate("ToolbarView", "{:} day(s) {:} hour(s)").format(*dt_reeval_dhms) + dt_reeval_as_str = QCoreApplication.translate( + "ToolbarView", "{:} day(s) {:} hour(s)" + ).format(*dt_reeval_dhms) # set infos in label - return QCoreApplication.translate("ToolbarView", + return QCoreApplication.translate( + "ToolbarView", """ <table cellpadding="5"> <tr><td align="right"><b>{:2.2%}</b></td><td>{:}</td></tr> @@ -316,26 +379,39 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> <tr><td align="right"><b>{:2.0%}</b></td><td>{:}</td></tr> </table> - """ + """, ).format( params.c, QCoreApplication.translate("ToolbarView", "Fundamental growth (c)"), params.ud0, - QCoreApplication.translate("ToolbarView", "Initial Universal Dividend UD(0) in"), + QCoreApplication.translate( + "ToolbarView", "Initial Universal Dividend UD(0) in" + ), currency, dt_as_str, QCoreApplication.translate("ToolbarView", "Time period between two UD"), dt_reeval_as_str, - QCoreApplication.translate("ToolbarView", "Time period between two UD reevaluation"), + QCoreApplication.translate( + "ToolbarView", "Time period between two UD reevaluation" + ), params.median_time_blocks, - QCoreApplication.translate("ToolbarView", "Number of blocks used for calculating median time"), + QCoreApplication.translate( + "ToolbarView", "Number of blocks used for calculating median time" + ), params.avg_gen_time, - QCoreApplication.translate("ToolbarView", "The average time in seconds for writing 1 block (wished time)"), + QCoreApplication.translate( + "ToolbarView", + "The average time in seconds for writing 1 block (wished time)", + ), params.dt_diff_eval, - QCoreApplication.translate("ToolbarView", "The number of blocks required to evaluate again PoWMin value"), + QCoreApplication.translate( + "ToolbarView", + "The number of blocks required to evaluate again PoWMin value", + ), params.percent_rot, - QCoreApplication.translate("ToolbarView", - "The percent of previous issuers to reach for personalized difficulty" + QCoreApplication.translate( + "ToolbarView", + "The percent of previous issuers to reach for personalized difficulty", ), ) diff --git a/src/sakia/gui/navigation/controller.py b/src/sakia/gui/navigation/controller.py index 14e9475b1339e060be2967c5cd99fa77c69d4f9e..c51180d0f66bbd3c0564a9dbe97928055001b3b7 100644 --- a/src/sakia/gui/navigation/controller.py +++ b/src/sakia/gui/navigation/controller.py @@ -153,14 +153,22 @@ class NavigationController(QObject): if raw_data: menu = QMenu(self.view) if raw_data["misc"]["connection"].uid: - action_view_in_wot = QAction(QCoreApplication.translate("NavigationController", "View in Web of Trust"), menu) + action_view_in_wot = QAction( + QCoreApplication.translate( + "NavigationController", "View in Web of Trust" + ), + menu, + ) menu.addAction(action_view_in_wot) action_view_in_wot.triggered.connect( lambda c: self.model.view_in_wot(raw_data["misc"]["connection"]) ) action_gen_revocation = QAction( - QCoreApplication.translate("NavigationController", "Save revocation document"), menu + QCoreApplication.translate( + "NavigationController", "Save revocation document" + ), + menu, ) menu.addAction(action_gen_revocation) action_gen_revocation.triggered.connect( @@ -169,7 +177,10 @@ class NavigationController(QObject): ) ) - action_publish_uid = QAction(QCoreApplication.translate("NavigationController", "Publish UID"), menu) + action_publish_uid = QAction( + QCoreApplication.translate("NavigationController", "Publish UID"), + menu, + ) menu.addAction(action_publish_uid) action_publish_uid.triggered.connect( lambda c: self.publish_uid(raw_data["misc"]["connection"]) @@ -180,7 +191,10 @@ class NavigationController(QObject): action_publish_uid.setEnabled(not identity_published) action_export_identity = QAction( - QCoreApplication.translate("NavigationController", "Export identity document"), menu + QCoreApplication.translate( + "NavigationController", "Export identity document" + ), + menu, ) menu.addAction(action_export_identity) action_export_identity.triggered.connect( @@ -189,7 +203,12 @@ class NavigationController(QObject): ) ) - action_leave = QAction(QCoreApplication.translate("NavigationController", "Leave the currency"), menu) + action_leave = QAction( + QCoreApplication.translate( + "NavigationController", "Leave the currency" + ), + menu, + ) menu.addAction(action_leave) action_leave.triggered.connect( lambda c: self.send_leave(raw_data["misc"]["connection"]) @@ -198,7 +217,12 @@ class NavigationController(QObject): self.model.identity_is_member(raw_data["misc"]["connection"]) ) - copy_pubkey = QAction(QCoreApplication.translate("NavigationController", "Copy pubkey to clipboard"), menu.parent()) + copy_pubkey = QAction( + QCoreApplication.translate( + "NavigationController", "Copy pubkey to clipboard" + ), + menu.parent(), + ) copy_pubkey.triggered.connect( lambda checked, c=raw_data["misc"][ "connection" @@ -207,7 +231,10 @@ class NavigationController(QObject): menu.addAction(copy_pubkey) copy_pubkey_crc = QAction( - QCoreApplication.translate("NavigationController", "Copy pubkey to clipboard (with CRC)"), menu.parent() + QCoreApplication.translate( + "NavigationController", "Copy pubkey to clipboard (with CRC)" + ), + menu.parent(), ) copy_pubkey_crc.triggered.connect( lambda checked, c=raw_data["misc"][ @@ -216,7 +243,12 @@ class NavigationController(QObject): ) menu.addAction(copy_pubkey_crc) - action_remove = QAction(QCoreApplication.translate("NavigationController", "Remove the Sakia account"), menu) + action_remove = QAction( + QCoreApplication.translate( + "NavigationController", "Remove the Sakia account" + ), + menu, + ) menu.addAction(action_remove) action_remove.triggered.connect( lambda c: self.remove_connection(raw_data["misc"]["connection"]) @@ -235,7 +267,9 @@ class NavigationController(QObject): ) if not password or not secret_key: return - key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) + key = SigningKey.from_credentials( + secret_key, password, connection.scrypt_params + ) identity_doc.sign([key]) identity.signature = identity_doc.signatures[0] self.model.update_identity(identity) @@ -243,26 +277,42 @@ class NavigationController(QObject): result = await self.model.send_identity(connection, identity_doc) if result[0]: if self.model.notifications(): - toast.display(QCoreApplication.translate("NavigationController", "UID"), QCoreApplication.translate("NavigationController", "Success publishing your UID")) + toast.display( + QCoreApplication.translate("NavigationController", "UID"), + QCoreApplication.translate( + "NavigationController", "Success publishing your UID" + ), + ) else: await QAsyncMessageBox.information( - self.view, QCoreApplication.translate("NavigationController", "UID"), QCoreApplication.translate("NavigationController", "Success publishing your UID") + self.view, + QCoreApplication.translate("NavigationController", "UID"), + QCoreApplication.translate( + "NavigationController", "Success publishing your UID" + ), ) else: if not self.model.notifications(): - toast.display(QCoreApplication.translate("NavigationController", "UID"), result[1]) + toast.display( + QCoreApplication.translate("NavigationController", "UID"), result[1] + ) else: - await QAsyncMessageBox.critical(self.view, QCoreApplication.translate("NavigationController", "UID"), result[1]) + await QAsyncMessageBox.critical( + self.view, + QCoreApplication.translate("NavigationController", "UID"), + result[1], + ) @asyncify async def send_leave(self): reply = await QAsyncMessageBox.warning( self, QCoreApplication.translate("NavigationController", "Warning"), - QCoreApplication.translate("NavigationController", + QCoreApplication.translate( + "NavigationController", """Are you sure? Sending a leaving demand cannot be canceled. -The process to join back the community later will have to be done again.""" +The process to join back the community later will have to be done again.""", ).format(self.account.pubkey), QMessageBox.Ok | QMessageBox.Cancel, ) @@ -277,28 +327,43 @@ The process to join back the community later will have to be done again.""" if result[0]: if self.app.preferences["notifications"]: toast.display( - QCoreApplication.translate("NavigationController", "Revoke"), QCoreApplication.translate("NavigationController", "Success sending Revoke demand") + QCoreApplication.translate("NavigationController", "Revoke"), + QCoreApplication.translate( + "NavigationController", "Success sending Revoke demand" + ), ) else: await QAsyncMessageBox.information( self, QCoreApplication.translate("NavigationController", "Revoke"), - QCoreApplication.translate("NavigationController", "Success sending Revoke demand"), + QCoreApplication.translate( + "NavigationController", "Success sending Revoke demand" + ), ) else: if self.app.preferences["notifications"]: - toast.display(QCoreApplication.translate("NavigationController", "Revoke"), result[1]) + toast.display( + QCoreApplication.translate("NavigationController", "Revoke"), + result[1], + ) else: - await QAsyncMessageBox.critical(self, QCoreApplication.translate("NavigationController", "Revoke"), result[1]) + await QAsyncMessageBox.critical( + self, + QCoreApplication.translate("NavigationController", "Revoke"), + result[1], + ) @asyncify async def remove_connection(self, connection): reply = await QAsyncMessageBox.question( self.view, - QCoreApplication.translate("NavigationController", "Removing the Sakia account"), - QCoreApplication.translate("NavigationController", + QCoreApplication.translate( + "NavigationController", "Removing the Sakia account" + ), + QCoreApplication.translate( + "NavigationController", """Are you sure? This won't remove your money - neither your identity from the network.""" + neither your identity from the network.""", ), QMessageBox.Ok | QMessageBox.Cancel, ) @@ -320,10 +385,17 @@ The process to join back the community later will have to be done again.""" # Testable way of using a QFileDialog selected_files = await QAsyncFileDialog.get_save_filename( self.view, - QCoreApplication.translate("NavigationController", "Save a revocation document"), - "revocation-{uid}-{pubkey}-{currency}.txt".format(uid=connection.uid, pubkey=connection.pubkey[:8], - currency=connection.currency), - QCoreApplication.translate("NavigationController", "All text files (*.txt)"), + QCoreApplication.translate( + "NavigationController", "Save a revocation document" + ), + "revocation-{uid}-{pubkey}-{currency}.txt".format( + uid=connection.uid, + pubkey=connection.pubkey[:8], + currency=connection.currency, + ), + QCoreApplication.translate( + "NavigationController", "All text files (*.txt)" + ), ) if selected_files: path = selected_files[0] @@ -335,10 +407,11 @@ The process to join back the community later will have to be done again.""" dialog = QMessageBox( QMessageBox.Information, QCoreApplication.translate("NavigationController", "Revocation file"), - QCoreApplication.translate("NavigationController", + QCoreApplication.translate( + "NavigationController", """<div>Your revocation document has been saved.</div> <div><b>Please keep it in a safe place.</b></div> -The publication of this document will revoke your identity on the network.</p>""" +The publication of this document will revoke your identity on the network.</p>""", ), QMessageBox.Ok, ) @@ -355,17 +428,26 @@ The publication of this document will revoke your identity on the network.</p>"" ) if not password or not secret_key: return - key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) + key = SigningKey.from_credentials( + secret_key, password, connection.scrypt_params + ) identity_doc.sign([key]) identity.signature = identity_doc.signatures[0] self.model.update_identity(identity) selected_files = await QAsyncFileDialog.get_save_filename( self.view, - QCoreApplication.translate("NavigationController", "Save an identity document"), - "identity-{uid}-{pubkey}-{currency}.txt".format(uid=connection.uid, pubkey=connection.pubkey[:8], - currency=connection.currency), - QCoreApplication.translate("NavigationController", "All text files (*.txt)"), + QCoreApplication.translate( + "NavigationController", "Save an identity document" + ), + "identity-{uid}-{pubkey}-{currency}.txt".format( + uid=connection.uid, + pubkey=connection.pubkey[:8], + currency=connection.currency, + ), + QCoreApplication.translate( + "NavigationController", "All text files (*.txt)" + ), ) if selected_files: path = selected_files[0] @@ -377,9 +459,10 @@ The publication of this document will revoke your identity on the network.</p>"" dialog = QMessageBox( QMessageBox.Information, QCoreApplication.translate("NavigationController", "Identity file"), - QCoreApplication.translate("NavigationController", + QCoreApplication.translate( + "NavigationController", """<div>Your identity document has been saved.</div> -Share this document to your friends for them to certify you.</p>""" +Share this document to your friends for them to certify you.</p>""", ), QMessageBox.Ok, ) diff --git a/src/sakia/gui/navigation/identities/table_model.py b/src/sakia/gui/navigation/identities/table_model.py index 83d45ed77a0951b6b050036d1f4c4d57f056c335..adfe01fac28e8a34e116768dcfa6bde60e3e4b6b 100644 --- a/src/sakia/gui/navigation/identities/table_model.py +++ b/src/sakia/gui/navigation/identities/table_model.py @@ -8,7 +8,8 @@ from PyQt5.QtCore import ( QModelIndex, QLocale, QT_TRANSLATE_NOOP, - QCoreApplication) + QCoreApplication, +) from PyQt5.QtGui import QColor, QIcon, QFont import logging import asyncio @@ -149,9 +150,7 @@ class IdentitiesTableModel(QAbstractTableModel): "pubkey": QT_TRANSLATE_NOOP("IdentitiesTableModel", "Pubkey"), "renewed": QT_TRANSLATE_NOOP("IdentitiesTableModel", "Renewed"), "expiration": QT_TRANSLATE_NOOP("IdentitiesTableModel", "Expiration"), - "publication": QT_TRANSLATE_NOOP( - "IdentitiesTableModel", "Publication" - ), + "publication": QT_TRANSLATE_NOOP("IdentitiesTableModel", "Publication"), "block": QT_TRANSLATE_NOOP("IdentitiesTableModel", "Publication Block"), } columns_ids = ( @@ -248,7 +247,9 @@ class IdentitiesTableModel(QAbstractTableModel): def headerData(self, section, orientation, role): if role == Qt.DisplayRole: col_id = IdentitiesTableModel.columns_ids[section] - return QCoreApplication.translate("IdentitiesTableModel", IdentitiesTableModel.columns_titles[col_id]) + return QCoreApplication.translate( + "IdentitiesTableModel", IdentitiesTableModel.columns_titles[col_id] + ) def data(self, index, role): if index.isValid() and role == Qt.DisplayRole: diff --git a/src/sakia/gui/navigation/identities/view.py b/src/sakia/gui/navigation/identities/view.py index 466081c833e1a0ed73284e569e8044a3f83afcb2..ea16d4833c794b68f10f989c82a0dcbc7e307502 100644 --- a/src/sakia/gui/navigation/identities/view.py +++ b/src/sakia/gui/navigation/identities/view.py @@ -24,7 +24,10 @@ class IdentitiesView(QWidget, Ui_IdentitiesWidget): super().__init__(parent) self.direct_connections = QAction( - QCoreApplication.translate("IdentitiesView", IdentitiesView._direct_connections_text), self + QCoreApplication.translate( + "IdentitiesView", IdentitiesView._direct_connections_text + ), + self, ) self.direct_connections.triggered.connect( self.request_search_direct_connections @@ -35,7 +38,9 @@ class IdentitiesView(QWidget, Ui_IdentitiesWidget): self.table_identities.sortByColumn(0, Qt.AscendingOrder) self.table_identities.resizeColumnsToContents() self.edit_textsearch.setPlaceholderText( - QCoreApplication.translate("IdentitiesView", IdentitiesView._search_placeholder) + QCoreApplication.translate( + "IdentitiesView", IdentitiesView._search_placeholder + ) ) self.edit_textsearch.returnPressed.connect(self.request_search_by_text) # fixme: as it is this menu can not work because the current connection is missing. @@ -67,13 +72,17 @@ class IdentitiesView(QWidget, Ui_IdentitiesWidget): Search members of community and display found members """ self.edit_textsearch.setPlaceholderText( - QCoreApplication.translate("IdentitiesView", IdentitiesView._search_placeholder) + QCoreApplication.translate( + "IdentitiesView", IdentitiesView._search_placeholder + ) ) self.search_directly_connected_requested.emit() def retranslateUi(self, widget): self.direct_connections.setText( - QCoreApplication.translate("IdentitiesView", IdentitiesView._direct_connections_text) + QCoreApplication.translate( + "IdentitiesView", IdentitiesView._direct_connections_text + ) ) super().retranslateUi(self) diff --git a/src/sakia/gui/navigation/identity/controller.py b/src/sakia/gui/navigation/identity/controller.py index 4e1e225f89b00d73f8a8d291961d436804d525aa..8072c364b633f80a4aa0d88c1e05772efd6fbc9f 100644 --- a/src/sakia/gui/navigation/identity/controller.py +++ b/src/sakia/gui/navigation/identity/controller.py @@ -169,18 +169,28 @@ class IdentityController(QObject): if result[0]: if self.model.notifications(): toast.display( - QCoreApplication.translate("IdentityController", "Membership"), QCoreApplication.translate("IdentityController", "Success sending Membership demand") + QCoreApplication.translate("IdentityController", "Membership"), + QCoreApplication.translate( + "IdentityController", "Success sending Membership demand" + ), ) else: await QAsyncMessageBox.information( self.view, QCoreApplication.translate("IdentityController", "Membership"), - QCoreApplication.translate("IdentityController", "Success sending Membership demand"), + QCoreApplication.translate( + "IdentityController", "Success sending Membership demand" + ), ) else: if self.model.notifications(): - toast.display(QCoreApplication.translate("IdentityController", "Membership"), result[1]) + toast.display( + QCoreApplication.translate("IdentityController", "Membership"), + result[1], + ) else: await QAsyncMessageBox.critical( - self.view, QCoreApplication.translate("IdentityController", "Membership"), result[1] + self.view, + QCoreApplication.translate("IdentityController", "Membership"), + result[1], ) diff --git a/src/sakia/gui/navigation/identity/model.py b/src/sakia/gui/navigation/identity/model.py index 4339fd71805a8e0021056336df3c5fa4e77934ae..9366a086097e9dcfb0a17637c80ce8fe610d4224 100644 --- a/src/sakia/gui/navigation/identity/model.py +++ b/src/sakia/gui/navigation/identity/model.py @@ -1,7 +1,15 @@ import logging import math -from PyQt5.QtCore import QLocale, QDateTime, pyqtSignal, QObject, QModelIndex, Qt, QCoreApplication +from PyQt5.QtCore import ( + QLocale, + QDateTime, + pyqtSignal, + QObject, + QModelIndex, + Qt, + QCoreApplication, +) from sakia.errors import NoPeerAvailable from sakia.constants import ROOT_SERVERS from .table_model import CertifiersTableModel, CertifiersFilterProxyModel @@ -243,7 +251,9 @@ class IdentityModel(QObject): self.identities_service.certifications_received(identity.pubkey) ) if not identity.outdistanced: - outdistanced_text = QCoreApplication.translate("IdentityModel", "In WoT range") + outdistanced_text = QCoreApplication.translate( + "IdentityModel", "In WoT range" + ) except errors.DuniterError as e: if e.ucode == errors.NO_MEMBER_MATCHING_PUB_OR_UID: pass diff --git a/src/sakia/gui/navigation/identity/table_model.py b/src/sakia/gui/navigation/identity/table_model.py index d5d7b44c29e67ef152d7fff20923dfb4db2ddb3c..a9300ea326c96be4755d14af07d97e28a486a8b1 100644 --- a/src/sakia/gui/navigation/identity/table_model.py +++ b/src/sakia/gui/navigation/identity/table_model.py @@ -9,7 +9,8 @@ from PyQt5.QtCore import ( QModelIndex, QLocale, QT_TRANSLATE_NOOP, - QCoreApplication) + QCoreApplication, +) from PyQt5.QtGui import QColor, QIcon, QFont import logging import asyncio @@ -123,9 +124,7 @@ class CertifiersTableModel(QAbstractTableModel): columns_titles = { "uid": QT_TRANSLATE_NOOP("CertifiersTableModel", "UID"), "pubkey": QT_TRANSLATE_NOOP("CertifiersTableModel", "Pubkey"), - "publication": QT_TRANSLATE_NOOP( - "CertifiersTableModel", "Publication" - ), + "publication": QT_TRANSLATE_NOOP("CertifiersTableModel", "Publication"), "expiration": QT_TRANSLATE_NOOP("CertifiersTableModel", "Expiration"), "available": QT_TRANSLATE_NOOP("CertifiersTableModel", "available"), } @@ -222,7 +221,9 @@ class CertifiersTableModel(QAbstractTableModel): def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: col_id = CertifiersTableModel.columns_ids[section] - return QCoreApplication.translate("CertifiersTableModel", CertifiersTableModel.columns_titles[col_id]) + return QCoreApplication.translate( + "CertifiersTableModel", CertifiersTableModel.columns_titles[col_id] + ) def data(self, index, role): if index.isValid() and role == Qt.DisplayRole: diff --git a/src/sakia/gui/navigation/identity/view.py b/src/sakia/gui/navigation/identity/view.py index 55811b7c6e08f4ad26932eb14e140e4e585366d3..55842c14a145ba90a1e1f55b17dc926c9b4f4bf4 100644 --- a/src/sakia/gui/navigation/identity/view.py +++ b/src/sakia/gui/navigation/identity/view.py @@ -69,7 +69,9 @@ class IdentityView(QWidget, Ui_IdentityWidget): self.button_membership.hide() else: if data["written"]: - written_value = QCoreApplication.translate("IdentityView", "Identity written in blockchain") + written_value = QCoreApplication.translate( + "IdentityView", "Identity written in blockchain" + ) pass else: expiration_text = QLocale.toString( @@ -78,45 +80,65 @@ class IdentityView(QWidget, Ui_IdentityWidget): QLocale.dateTimeFormat(QLocale(), QLocale.ShortFormat), ) written_value = ( - QCoreApplication.translate("IdentityView", "Identity not written in blockchain") + QCoreApplication.translate( + "IdentityView", "Identity not written in blockchain" + ) + " (" - + QCoreApplication.translate("IdentityView", "Expires on: {0}").format(expiration_text) + + QCoreApplication.translate( + "IdentityView", "Expires on: {0}" + ).format(expiration_text) + " BAT)" ) status_value = ( - QCoreApplication.translate("IdentityView", "Member") if data["membership_state"] else QCoreApplication.translate("IdentityView", "Not a member") + QCoreApplication.translate("IdentityView", "Member") + if data["membership_state"] + else QCoreApplication.translate("IdentityView", "Not a member") ) if data["mstime"] > 0: - membership_action_value = QCoreApplication.translate("IdentityView", "Renew membership") + membership_action_value = QCoreApplication.translate( + "IdentityView", "Renew membership" + ) status_info = "" membership_action_enabled = True elif data["membership_state"]: - membership_action_value = QCoreApplication.translate("IdentityView", "Renew membership") + membership_action_value = QCoreApplication.translate( + "IdentityView", "Renew membership" + ) status_info = "Your membership expired" membership_action_enabled = True else: - membership_action_value = QCoreApplication.translate("IdentityView", "Request membership") + membership_action_value = QCoreApplication.translate( + "IdentityView", "Request membership" + ) if data["nb_certs"] > data["nb_certs_required"]: - status_info = QCoreApplication.translate("IdentityView", "Identity registration ready") + status_info = QCoreApplication.translate( + "IdentityView", "Identity registration ready" + ) membership_action_enabled = True else: - status_info = QCoreApplication.translate("IdentityView", "{0} more certifications required").format( - data["nb_certs_required"] - data["nb_certs"] - ) + status_info = QCoreApplication.translate( + "IdentityView", "{0} more certifications required" + ).format(data["nb_certs_required"] - data["nb_certs"]) membership_action_enabled = True if data["mstime"] > 0: days, hours, minutes, seconds = timestamp_to_dhms(data["mstime"]) - mstime_remaining_text = QCoreApplication.translate("IdentityView", "Expires in ") + mstime_remaining_text = QCoreApplication.translate( + "IdentityView", "Expires in " + ) if days > 0: - mstime_remaining_text += QCoreApplication.translate("IdentityView", "{days} days").format(days=days) + mstime_remaining_text += QCoreApplication.translate( + "IdentityView", "{days} days" + ).format(days=days) else: - mstime_remaining_text += QCoreApplication.translate("IdentityView", "{hours} hours and {min} min.").format( - hours=hours, min=minutes - ) + mstime_remaining_text += QCoreApplication.translate( + "IdentityView", "{hours} hours and {min} min." + ).format(hours=hours, min=minutes) else: - mstime_remaining_text = QCoreApplication.translate("IdentityView", "Expired or never published") + mstime_remaining_text = QCoreApplication.translate( + "IdentityView", "Expired or never published" + ) ms_status_color = "#00AA00" if data["membership_state"] else "#FF0000" outdistanced_status_color = ( @@ -139,7 +161,7 @@ class IdentityView(QWidget, Ui_IdentityWidget): ms_status_color=ms_status_color, status_label=QCoreApplication.translate("IdentityView", "Status"), status=status_value, - status_info=status_info + status_info=status_info, ) description_identity = """<html> <body> @@ -147,11 +169,15 @@ class IdentityView(QWidget, Ui_IdentityWidget): <p><span style="font-weight:600;">{mstime_remaining_label}</span> : {mstime_remaining}</p> </body> </html>""".format( - nb_certs_label=QCoreApplication.translate("IdentityView", "Certs. received"), + nb_certs_label=QCoreApplication.translate( + "IdentityView", "Certs. received" + ), nb_certs=data["nb_certs"], outdistanced_text=data["outdistanced"], outdistanced_status_color=outdistanced_status_color, - mstime_remaining_label=QCoreApplication.translate("IdentityView", "Membership"), + mstime_remaining_label=QCoreApplication.translate( + "IdentityView", "Membership" + ), mstime_remaining=mstime_remaining_text, ) @@ -181,13 +207,19 @@ class IdentityView(QWidget, Ui_IdentityWidget): async def licence_dialog(self, currency, params): dt_dhms = timestamp_to_dhms(params.dt) if dt_dhms[0] > 0: - dt_as_str = QCoreApplication.translate("IdentityView", "{:} day(s) {:} hour(s)").format(*dt_dhms) + dt_as_str = QCoreApplication.translate( + "IdentityView", "{:} day(s) {:} hour(s)" + ).format(*dt_dhms) else: - dt_as_str = QCoreApplication.translate("IdentityView", "{:} hour(s)").format(dt_dhms[1]) + dt_as_str = QCoreApplication.translate( + "IdentityView", "{:} hour(s)" + ).format(dt_dhms[1]) if dt_dhms[2] > 0 or dt_dhms[3] > 0: dt_dhms += ", {:} minute(s) and {:} second(s)".format(*dt_dhms[1:]) dt_reeval_dhms = timestamp_to_dhms(params.dt_reeval) - dt_reeval_as_str = QCoreApplication.translate("IdentityView", "{:} day(s) {:} hour(s)").format(*dt_reeval_dhms) + dt_reeval_as_str = QCoreApplication.translate( + "IdentityView", "{:} day(s) {:} hour(s)" + ).format(*dt_reeval_dhms) message_box = QMessageBox(self) @@ -227,33 +259,55 @@ and that you will only certify persons that you know well enough.</b> QLocale().toString(params.dt / 86400, "f", 2), QCoreApplication.translate("IdentityView", "Fundamental growth (c)"), params.ud0, - QCoreApplication.translate("IdentityView", "Initial Universal Dividend UD(0) in"), + QCoreApplication.translate( + "IdentityView", "Initial Universal Dividend UD(0) in" + ), ROOT_SERVERS[currency]["display"], dt_as_str, - QCoreApplication.translate("IdentityView", "Time period between two UD"), + QCoreApplication.translate( + "IdentityView", "Time period between two UD" + ), dt_reeval_as_str, - QCoreApplication.translate("IdentityView", "Time period between two UD reevaluation"), + QCoreApplication.translate( + "IdentityView", "Time period between two UD reevaluation" + ), ROOT_SERVERS[currency]["display"], QLocale().toString(params.sig_period / 86400, "f", 2), - QCoreApplication.translate("IdentityView", "Minimum delay between 2 certifications (in days)"), + QCoreApplication.translate( + "IdentityView", "Minimum delay between 2 certifications (in days)" + ), QLocale().toString(params.sig_validity / 86400, "f", 2), - QCoreApplication.translate("IdentityView", "Maximum validity time of a certification (in days)"), + QCoreApplication.translate( + "IdentityView", "Maximum validity time of a certification (in days)" + ), params.sig_qty, - QCoreApplication.translate("IdentityView", "Minimum quantity of certifications to be part of the WoT"), + QCoreApplication.translate( + "IdentityView", + "Minimum quantity of certifications to be part of the WoT", + ), params.sig_stock, - QCoreApplication.translate("IdentityView", "Maximum quantity of active certifications per member"), + QCoreApplication.translate( + "IdentityView", + "Maximum quantity of active certifications per member", + ), params.sig_window, - QCoreApplication.translate("IdentityView", - "Maximum time before a pending certification expire" + QCoreApplication.translate( + "IdentityView", "Maximum time before a pending certification expire" ), params.xpercent, - QCoreApplication.translate("IdentityView", - "Minimum percent of sentries to reach to match the distance rule" + QCoreApplication.translate( + "IdentityView", + "Minimum percent of sentries to reach to match the distance rule", ), params.ms_validity / 86400, - QCoreApplication.translate("IdentityView", "Maximum validity time of a membership (in days)"), + QCoreApplication.translate( + "IdentityView", "Maximum validity time of a membership (in days)" + ), params.step_max, - QCoreApplication.translate("IdentityView", "Maximum distance between each WoT member and a newcomer"), + QCoreApplication.translate( + "IdentityView", + "Maximum distance between each WoT member and a newcomer", + ), ) ) message_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) diff --git a/src/sakia/gui/navigation/model.py b/src/sakia/gui/navigation/model.py index 1aa421e46eac73e26fd5a92f2a8770b0a075f91d..214fb53c16b56bceeed3a108a46b9cfd8ab84d6f 100644 --- a/src/sakia/gui/navigation/model.py +++ b/src/sakia/gui/navigation/model.py @@ -66,7 +66,12 @@ class NavigationModel(QObject): }, "misc": {}, }, - {"title": QCoreApplication.translate("NavigationModel", "Personal accounts"), "children": []}, + { + "title": QCoreApplication.translate( + "NavigationModel", "Personal accounts" + ), + "children": [], + }, ] self._current_data = self.navigation[0] @@ -98,7 +103,9 @@ class NavigationModel(QObject): "misc": {"connection": connection}, "children": [ { - "title": QCoreApplication.translate("NavigationModel", "Transfers"), + "title": QCoreApplication.translate( + "NavigationModel", "Transfers" + ), "icon": ":/icons/tx_icon", "component": "TxHistory", "dependencies": { diff --git a/src/sakia/gui/navigation/network/controller.py b/src/sakia/gui/navigation/network/controller.py index 4c1b8fb6b4a5744d3e17f4e3201ed53fb4b506b4..676da3a42fcda01252803ed89c137c7133850418 100644 --- a/src/sakia/gui/navigation/network/controller.py +++ b/src/sakia/gui/navigation/network/controller.py @@ -52,7 +52,9 @@ class NetworkController(QObject): valid, node = self.model.table_model_data(index) if self.model.app.parameters.expert_mode: menu = QMenu() - open_in_browser = QAction(QCoreApplication.translate("NetworkController", "Open in browser"), self) + open_in_browser = QAction( + QCoreApplication.translate("NetworkController", "Open in browser"), self + ) open_in_browser.triggered.connect(self.open_node_in_browser) open_in_browser.setData(node) menu.addAction(open_in_browser) diff --git a/src/sakia/gui/navigation/network/table_model.py b/src/sakia/gui/navigation/network/table_model.py index f6430c976a8310a03290c3f12da1e73c9b964634..691811868ddcd366fbe92aa06b3eb65baddbd14b 100644 --- a/src/sakia/gui/navigation/network/table_model.py +++ b/src/sakia/gui/navigation/network/table_model.py @@ -8,7 +8,8 @@ from PyQt5.QtCore import ( QModelIndex, pyqtSignal, QCoreApplication, - QT_TRANSLATE_NOOP) + QT_TRANSLATE_NOOP, +) from PyQt5.QtGui import QColor, QFont, QIcon from sakia.data.entities import Node from duniterpy.api.endpoint import ( @@ -72,7 +73,9 @@ class NetworkFilterProxyModel(QSortFilterProxyModel): return QVariant() _type = self.sourceModel().headerData(section, orientation, role) - return QCoreApplication.translate("NetworkTableModel", NetworkTableModel.header_names[_type]) + return QCoreApplication.translate( + "NetworkTableModel", NetworkTableModel.header_names[_type] + ) def data(self, index, role): source_index = self.mapToSource(index) @@ -139,6 +142,7 @@ class NetworkTableModel(QAbstractTableModel): """ A Qt abstract item model to display """ + header_names = { "address": QT_TRANSLATE_NOOP("NetworkTableModel", "Address"), "port": QT_TRANSLATE_NOOP("NetworkTableModel", "Port"), @@ -335,9 +339,12 @@ class NetworkTableModel(QAbstractTableModel): ] if role == Qt.ToolTipRole: - return QCoreApplication.translate("NetworkTableModel", NetworkTableModel.node_states[ - node[NetworkTableModel.columns_types.index("state")] - ]) + return QCoreApplication.translate( + "NetworkTableModel", + NetworkTableModel.node_states[ + node[NetworkTableModel.columns_types.index("state")] + ], + ) if role == Qt.DecorationRole and index.column() == 0: return QIcon( diff --git a/src/sakia/gui/navigation/txhistory/controller.py b/src/sakia/gui/navigation/txhistory/controller.py index 0aafae4bf2a885869e5864df4263c8ea0f153cec..fa0a179c6a3c46a607cd3503e5bd4e54a9205b59 100644 --- a/src/sakia/gui/navigation/txhistory/controller.py +++ b/src/sakia/gui/navigation/txhistory/controller.py @@ -92,11 +92,16 @@ class TxHistoryController(QObject): async def notification_reception(self, received_list): if len(received_list) > 0: localized_amount = await self.model.received_amount(received_list) - text = QCoreApplication.translate("TxHistoryController", "Received {amount} from {number} transfers").format( - amount=localized_amount, number=len(received_list) - ) + text = QCoreApplication.translate( + "TxHistoryController", "Received {amount} from {number} transfers" + ).format(amount=localized_amount, number=len(received_list)) if self.model.notifications(): - toast.display(QCoreApplication.translate("TxHistoryController", "New transactions received"), text) + toast.display( + QCoreApplication.translate( + "TxHistoryController", "New transactions received" + ), + text, + ) def refresh_balance(self): localized_amount = self.model.localized_balance() @@ -187,10 +192,12 @@ class TxHistoryController(QObject): ( changed_tx, - new_tx - ) = await self.model.transactions_service.update_transactions_history(pubkey, - self.view.table_history.model().ts_from, - self.view.table_history.model().ts_to) + new_tx, + ) = await self.model.transactions_service.update_transactions_history( + pubkey, + self.view.table_history.model().ts_from, + self.view.table_history.model().ts_to, + ) for tx in changed_tx: self.model.app.transaction_state_changed.emit(tx) @@ -201,7 +208,7 @@ class TxHistoryController(QObject): pubkey, self.view.table_history.model().ts_from, self.view.table_history.model().ts_to, - new_tx + new_tx, ) self._logger.debug("Found {} new dividends".format(len(new_dividends))) diff --git a/src/sakia/gui/navigation/txhistory/table_model.py b/src/sakia/gui/navigation/txhistory/table_model.py index 6f8401e0468247983309fbe6d726262419178afd..22bcc7e10ed637279e9a33819f4f2acdbc08d8c2 100644 --- a/src/sakia/gui/navigation/txhistory/table_model.py +++ b/src/sakia/gui/navigation/txhistory/table_model.py @@ -10,7 +10,8 @@ from PyQt5.QtCore import ( QLocale, QModelIndex, QT_TRANSLATE_NOOP, - QCoreApplication) + QCoreApplication, +) from PyQt5.QtGui import QFont, QColor from sakia.data.entities import Transaction from sakia.constants import MAX_CONFIRMATIONS @@ -185,7 +186,9 @@ class HistoryTableModel(QAbstractTableModel): date_ts, "", 0, - QCoreApplication.translate("HistoryTableModel", "Transactions missing from history"), + QCoreApplication.translate( + "HistoryTableModel", "Transactions missing from history" + ), transfer.state, txid, transfer.issuers, @@ -342,11 +345,17 @@ class HistoryTableModel(QAbstractTableModel): if orientation == Qt.Horizontal and role == Qt.DisplayRole: if HistoryTableModel.columns_types[section] == "amount": dividend, base = self.blockchain_processor.last_ud(self.app.currency) - header = "{:}".format(QCoreApplication.translate("HistoryTableModel", HistoryTableModel.columns_headers[section])) + header = "{:}".format( + QCoreApplication.translate( + "HistoryTableModel", HistoryTableModel.columns_headers[section] + ) + ) if self.app.current_ref.base_str(base): header += " ({:})".format(self.app.current_ref.base_str(base)) return header - return QCoreApplication.translate("HistoryTableModel", HistoryTableModel.columns_headers[section]) + return QCoreApplication.translate( + "HistoryTableModel", HistoryTableModel.columns_headers[section] + ) def data(self, index, role): row = index.row() @@ -462,15 +471,15 @@ class HistoryTableModel(QAbstractTableModel): if current_confirmations >= MAX_CONFIRMATIONS: return None elif self.app.parameters.expert_mode: - return QCoreApplication.translate("HistoryTableModel", "{0} / {1} confirmations").format( - current_confirmations, MAX_CONFIRMATIONS - ) + return QCoreApplication.translate( + "HistoryTableModel", "{0} / {1} confirmations" + ).format(current_confirmations, MAX_CONFIRMATIONS) else: confirmation = current_confirmations / MAX_CONFIRMATIONS * 100 confirmation = 100 if confirmation > 100 else confirmation - return QCoreApplication.translate("HistoryTableModel", "Confirming... {0} %").format( - QLocale().toString(float(confirmation), "f", 0) - ) + return QCoreApplication.translate( + "HistoryTableModel", "Confirming... {0} %" + ).format(QLocale().toString(float(confirmation), "f", 0)) def flags(self, index): return Qt.ItemIsSelectable | Qt.ItemIsEnabled diff --git a/src/sakia/gui/navigation/txhistory/view.py b/src/sakia/gui/navigation/txhistory/view.py index 3b756944fff71bc5f5c414d71ed0fd951e859693..e2dc4b73f1d64602907fd25df0e059def5e57905 100644 --- a/src/sakia/gui/navigation/txhistory/view.py +++ b/src/sakia/gui/navigation/txhistory/view.py @@ -60,7 +60,11 @@ class TxHistoryView(QWidget, Ui_TxHistoryWidget): self.date_to.setMaximumDateTime(maximum) def set_max_pages(self, pages): - self.spin_page.setSuffix(QCoreApplication.translate("TxHistoryView", " / {:} pages").format(pages + 1)) + self.spin_page.setSuffix( + QCoreApplication.translate("TxHistoryView", " / {:} pages").format( + pages + 1 + ) + ) self.spin_page.setMaximum(pages + 1) def set_balance(self, balance): diff --git a/src/sakia/gui/sub/certification/controller.py b/src/sakia/gui/sub/certification/controller.py index 109dc9535db1a1f0be380ed5e6f2931699fc4e75..00a69a0378f9bc070dc3e9c7e79af4b7be68729f 100644 --- a/src/sakia/gui/sub/certification/controller.py +++ b/src/sakia/gui/sub/certification/controller.py @@ -87,7 +87,9 @@ class CertificationController(QObject): """ dialog = QDialog(parent) - dialog.setWindowTitle(QCoreApplication.translate("CertificationController", "Certification")) + dialog.setWindowTitle( + QCoreApplication.translate("CertificationController", "Certification") + ) dialog.setLayout(QVBoxLayout(dialog)) certification = cls.create(parent, app) certification.set_connection(connection) @@ -108,7 +110,9 @@ class CertificationController(QObject): :return: """ dialog = QDialog(parent) - dialog.setWindowTitle(QCoreApplication.translate("CertificationController", "Certification")) + dialog.setWindowTitle( + QCoreApplication.translate("CertificationController", "Certification") + ) dialog.setLayout(QVBoxLayout(dialog)) certification = cls.create(parent, app) if connection: @@ -201,11 +205,13 @@ using cross checking which will help to reveal the problem if needs to be.</br>" ) elif days + hours + minutes > 0: if days > 0: - remaining_localized = QCoreApplication.translate("CertificationController", "{days} days").format(days=days) + remaining_localized = QCoreApplication.translate( + "CertificationController", "{days} days" + ).format(days=days) else: - remaining_localized = QCoreApplication.translate("CertificationController", "{hours}h {min}min").format( - hours=hours, min=minutes - ) + remaining_localized = QCoreApplication.translate( + "CertificationController", "{hours}h {min}min" + ).format(hours=hours, min=minutes) self.view.set_button_process( CertificationView.ButtonsState.REMAINING_TIME_BEFORE_VALIDATION, remaining=remaining_localized, diff --git a/src/sakia/gui/sub/certification/view.py b/src/sakia/gui/sub/certification/view.py index e7a63dc98141f85478aec10222dd8efb299e6c40..ba6bec59985321e59541e9585e25a40bf409bd71 100644 --- a/src/sakia/gui/sub/certification/view.py +++ b/src/sakia/gui/sub/certification/view.py @@ -113,7 +113,9 @@ class CertificationView(QWidget, Ui_CertificationWidget): self, QCoreApplication.translate("CertificationView", "Import identity document"), "", - QCoreApplication.translate("CertificationView", "Duniter documents (*.txt)"), + QCoreApplication.translate( + "CertificationView", "Duniter documents (*.txt)" + ), ) if file_name and file_name[0]: with open(file_name[0], "r") as open_file: @@ -124,8 +126,13 @@ class CertificationView(QWidget, Ui_CertificationWidget): except MalformedDocumentError as e: QMessageBox.warning( self, - QCoreApplication.translate("CertificationView", "Identity document"), - QCoreApplication.translate("CertificationView", "The imported file is not a correct identity document"), + QCoreApplication.translate( + "CertificationView", "Identity document" + ), + QCoreApplication.translate( + "CertificationView", + "The imported file is not a correct identity document", + ), QMessageBox.Ok, ) @@ -141,11 +148,18 @@ class CertificationView(QWidget, Ui_CertificationWidget): async def show_success(self, notification): if notification: toast.display( - QCoreApplication.translate("CertificationView", "Certification"), QCoreApplication.translate("CertificationView", "Success sending certification") + QCoreApplication.translate("CertificationView", "Certification"), + QCoreApplication.translate( + "CertificationView", "Success sending certification" + ), ) else: await QAsyncMessageBox.information( - self, QCoreApplication.translate("CertificationView", "Certification"), QCoreApplication.translate("CertificationView", "Success sending certification") + self, + QCoreApplication.translate("CertificationView", "Certification"), + QCoreApplication.translate( + "CertificationView", "Success sending certification" + ), ) async def show_error(self, notification, error_txt): @@ -153,13 +167,19 @@ class CertificationView(QWidget, Ui_CertificationWidget): if notification: toast.display( QCoreApplication.translate("CertificationView", "Certification"), - QCoreApplication.translate("CertificationView", "Could not broadcast certification: {0}".format(error_txt)), + QCoreApplication.translate( + "CertificationView", + "Could not broadcast certification: {0}".format(error_txt), + ), ) else: await QAsyncMessageBox.critical( self, QCoreApplication.translate("CertificationView", "Certification"), - QCoreApplication.translate("CertificationView", "Could not broadcast certification: {0}".format(error_txt)), + QCoreApplication.translate( + "CertificationView", + "Could not broadcast certification: {0}".format(error_txt), + ), ) def display_cert_stock( @@ -180,25 +200,28 @@ class CertificationView(QWidget, Ui_CertificationWidget): :param int remaining_hours: :param int remaining_minutes: """ - cert_text = QCoreApplication.translate("CertificationView", "Certifications sent: {nb_certifications}/{stock}").format( - nb_certifications=written, stock=stock - ) + cert_text = QCoreApplication.translate( + "CertificationView", "Certifications sent: {nb_certifications}/{stock}" + ).format(nb_certifications=written, stock=stock) if pending > 0: cert_text += " (+{nb_cert_pending} certifications pending)".format( nb_cert_pending=pending ) if remaining_days > 0: - remaining_localized = QCoreApplication.translate("CertificationView", "{days} days").format(days=remaining_days) + remaining_localized = QCoreApplication.translate( + "CertificationView", "{days} days" + ).format(days=remaining_days) else: - remaining_localized = QCoreApplication.translate("CertificationView", "{hours} hours and {min} min.").format( - hours=remaining_hours, min=remaining_minutes - ) + remaining_localized = QCoreApplication.translate( + "CertificationView", "{hours} hours and {min} min." + ).format(hours=remaining_hours, min=remaining_minutes) cert_text += "\n" - cert_text += QCoreApplication.translate("CertificationView", + cert_text += QCoreApplication.translate( + "CertificationView", "Remaining time before next certification validation: {0}".format( remaining_localized - ) + ), ) self.label_cert_stock.setText(cert_text) @@ -212,7 +235,9 @@ class CertificationView(QWidget, Ui_CertificationWidget): button_box_state = CertificationView._button_box_values[state] self.button_box.button(QDialogButtonBox.Ok).setEnabled(button_box_state[0]) self.button_box.button(QDialogButtonBox.Ok).setText( - QCoreApplication.translate("CertificationView", button_box_state[1]).format(**kwargs) + QCoreApplication.translate("CertificationView", button_box_state[1]).format( + **kwargs + ) ) def set_button_process(self, state, **kwargs): @@ -224,4 +249,8 @@ class CertificationView(QWidget, Ui_CertificationWidget): """ button_process_state = CertificationView._button_process_values[state] self.button_process.setEnabled(button_process_state[0]) - self.button_process.setText(QCoreApplication.translate("CertificationView", button_process_state[1]).format(**kwargs)) + self.button_process.setText( + QCoreApplication.translate( + "CertificationView", button_process_state[1] + ).format(**kwargs) + ) diff --git a/src/sakia/gui/sub/password_input/controller.py b/src/sakia/gui/sub/password_input/controller.py index e9fc6ea89b80e553f73214b254571193d284f01d..8c97e99c9f7b835cdf97945a2e0ef48c0b906164 100644 --- a/src/sakia/gui/sub/password_input/controller.py +++ b/src/sakia/gui/sub/password_input/controller.py @@ -47,7 +47,11 @@ class PasswordInputController(QObject): dialog = QDialog(parent.view) dialog.setLayout(QVBoxLayout(dialog)) password_input = cls.create(parent, connection) - dialog.setWindowTitle(QCoreApplication.translate("PasswordInputController", "Please enter your password")) + dialog.setWindowTitle( + QCoreApplication.translate( + "PasswordInputController", "Please enter your password" + ) + ) dialog.layout().addWidget(password_input.view) password_input.view.button_box.accepted.connect(dialog.accept) password_input.view.button_box.rejected.connect(dialog.reject) @@ -64,18 +68,31 @@ class PasswordInputController(QObject): def check_private_key(self, secret_key, password): if detect_non_printable(secret_key): - self.view.error(QCoreApplication.translate("PasswordInputController", "Non printable characters in secret key")) + self.view.error( + QCoreApplication.translate( + "PasswordInputController", "Non printable characters in secret key" + ) + ) return False if detect_non_printable(password): - self.view.error(QCoreApplication.translate("PasswordInputController", "Non printable characters in password")) + self.view.error( + QCoreApplication.translate( + "PasswordInputController", "Non printable characters in password" + ) + ) return False if ( - SigningKey.from_credentials(secret_key, password, self.connection.scrypt_params).pubkey + SigningKey.from_credentials( + secret_key, password, self.connection.scrypt_params + ).pubkey != self.connection.pubkey ): self.view.error( - QCoreApplication.translate("PasswordInputController", "Wrong secret key or password. Cannot open the private key") + QCoreApplication.translate( + "PasswordInputController", + "Wrong secret key or password. Cannot open the private key", + ) ) return False return True diff --git a/src/sakia/gui/sub/password_input/view.py b/src/sakia/gui/sub/password_input/view.py index 175690540189c1eeece42e46b317b6552b37ecaf..97ba9bdd214bf45165740d27e5496712c4f8623c 100644 --- a/src/sakia/gui/sub/password_input/view.py +++ b/src/sakia/gui/sub/password_input/view.py @@ -30,7 +30,9 @@ class PasswordInputView(QWidget, Ui_PasswordInputWidget): self.edit_secret_key.clear() def valid(self): - self.label_info.setText(QCoreApplication.translate("PasswordInputView", "Password is valid")) + self.label_info.setText( + QCoreApplication.translate("PasswordInputView", "Password is valid") + ) self.button_box.button(QDialogButtonBox.Ok).setEnabled(True) def changeEvent(self, event): diff --git a/src/sakia/gui/sub/search_user/view.py b/src/sakia/gui/sub/search_user/view.py index 5511e905b2c7af035bc5e390b23fa0b53925d778..fb5e7a62f4618bd76bdd3734ca0590693bc0c349 100644 --- a/src/sakia/gui/sub/search_user/view.py +++ b/src/sakia/gui/sub/search_user/view.py @@ -1,5 +1,11 @@ from PyQt5.QtWidgets import QWidget, QComboBox, QCompleter -from PyQt5.QtCore import QT_TRANSLATE_NOOP, pyqtSignal, Qt, QStringListModel, QCoreApplication +from PyQt5.QtCore import ( + QT_TRANSLATE_NOOP, + pyqtSignal, + Qt, + QStringListModel, + QCoreApplication, +) from sakia.data.entities import Contact from .search_user_uic import Ui_SearchUserWidget import re @@ -23,10 +29,10 @@ class SearchUserView(QWidget, Ui_SearchUserWidget): super().__init__(parent) self.setupUi(self) # Default text when combo lineEdit is empty - res = QCoreApplication.translate("SearchUserView", SearchUserView._search_placeholder) - self.combobox_search.lineEdit().setPlaceholderText( - res + res = QCoreApplication.translate( + "SearchUserView", SearchUserView._search_placeholder ) + self.combobox_search.lineEdit().setPlaceholderText(res) #  add combobox events self.combobox_search.lineEdit().returnPressed.connect(self.search) self.button_reset.clicked.connect(self.reset_requested) @@ -38,7 +44,9 @@ class SearchUserView(QWidget, Ui_SearchUserWidget): def clear(self): self.combobox_search.clear() self.combobox_search.lineEdit().setPlaceholderText( - QCoreApplication.translate("SearchUserView", SearchUserView._search_placeholder) + QCoreApplication.translate( + "SearchUserView", SearchUserView._search_placeholder + ) ) def search(self, text=""): @@ -53,7 +61,9 @@ class SearchUserView(QWidget, Ui_SearchUserWidget): text = self.combobox_search.lineEdit().text() self.combobox_search.lineEdit().clear() self.combobox_search.lineEdit().setPlaceholderText( - QCoreApplication.translate("SearchUserView", "Looking for {0}...").format(text) + QCoreApplication.translate("SearchUserView", "Looking for {0}...").format( + text + ) ) self.search_requested.emit(text) @@ -77,7 +87,9 @@ class SearchUserView(QWidget, Ui_SearchUserWidget): Retranslate missing widgets from generated code """ self.combobox_search.lineEdit().setPlaceholderText( - QCoreApplication.translate("SearchUserView", SearchUserView._search_placeholder) + QCoreApplication.translate( + "SearchUserView", SearchUserView._search_placeholder + ) ) super().retranslateUi(self) diff --git a/src/sakia/gui/sub/transfer/controller.py b/src/sakia/gui/sub/transfer/controller.py index a8caef78bf4ef408755957f5ca2564d6e7b1daa8..dc47043d0f00782d9bf23c5c5784f7613390ea58 100644 --- a/src/sakia/gui/sub/transfer/controller.py +++ b/src/sakia/gui/sub/transfer/controller.py @@ -106,7 +106,9 @@ class TransferController(QObject): @classmethod def send_money_to_pubkey(cls, parent, app, connection, pubkey): dialog = QDialog(parent) - dialog.setWindowTitle(QCoreApplication.translate("TransferController", "Transfer")) + dialog.setWindowTitle( + QCoreApplication.translate("TransferController", "Transfer") + ) dialog.setLayout(QVBoxLayout(dialog)) transfer = cls.open_transfer_with_pubkey(parent, app, connection, pubkey) @@ -118,7 +120,9 @@ class TransferController(QObject): @classmethod def send_money_to_identity(cls, parent, app, connection, identity): dialog = QDialog(parent) - dialog.setWindowTitle(QCoreApplication.translate("TransferController", "Transfer")) + dialog.setWindowTitle( + QCoreApplication.translate("TransferController", "Transfer") + ) dialog.setLayout(QVBoxLayout(dialog)) transfer = cls.open_transfer_with_pubkey( parent, app, connection, identity.pubkey @@ -134,7 +138,9 @@ class TransferController(QObject): @classmethod def send_transfer_again(cls, parent, app, connection, resent_transfer): dialog = QDialog(parent) - dialog.setWindowTitle(QCoreApplication.translate("TransferController", "Transfer")) + dialog.setWindowTitle( + QCoreApplication.translate("TransferController", "Transfer") + ) dialog.setLayout(QVBoxLayout(dialog)) transfer = cls.create(parent, app) transfer.view.groupbox_connection.show() diff --git a/src/sakia/gui/sub/transfer/view.py b/src/sakia/gui/sub/transfer/view.py index 3585ace189454a4e335667f8c788dfbdec7e5ab6..53c10e63b41e652b6cd72bd4ca27dcf530106cdf 100644 --- a/src/sakia/gui/sub/transfer/view.py +++ b/src/sakia/gui/sub/transfer/view.py @@ -189,27 +189,38 @@ class TransferView(QWidget, Ui_TransferMoneyWidget): button_box_state = TransferView._button_box_values[state] self.button_box.button(QDialogButtonBox.Ok).setEnabled(button_box_state[0]) self.button_box.button(QDialogButtonBox.Ok).setText( - QCoreApplication.translate("TransferView", button_box_state[1]).format(**kwargs) + QCoreApplication.translate("TransferView", button_box_state[1]).format( + **kwargs + ) ) async def show_success(self, notification, recipient): if notification: toast.display( QCoreApplication.translate("TransferView", "Transfer"), - QCoreApplication.translate("TransferView", "Success sending money to {0}").format(recipient), + QCoreApplication.translate( + "TransferView", "Success sending money to {0}" + ).format(recipient), ) else: await QAsyncMessageBox.information( self, QCoreApplication.translate("TransferView", "Transfer"), - QCoreApplication.translate("TransferView", "Success sending money to {0}").format(recipient), + QCoreApplication.translate( + "TransferView", "Success sending money to {0}" + ).format(recipient), ) async def show_error(self, notification, error_txt): if notification: - toast.display(QCoreApplication.translate("TransferView", "Transfer"), "Error: {0}".format(error_txt)) + toast.display( + QCoreApplication.translate("TransferView", "Transfer"), + "Error: {0}".format(error_txt), + ) else: - await QAsyncMessageBox.critical(self, QCoreApplication.translate("TransferView", "Transfer"), error_txt) + await QAsyncMessageBox.critical( + self, QCoreApplication.translate("TransferView", "Transfer"), error_txt + ) def pubkey_value(self): return self.edit_pubkey.text() diff --git a/src/sakia/gui/sub/user_information/view.py b/src/sakia/gui/sub/user_information/view.py index 6718d5d10e629fa504bfe14b13178cd536fd6547..5fc4b9a9c7afb48805c5dc34a5b4f7f8be398d66 100644 --- a/src/sakia/gui/sub/user_information/view.py +++ b/src/sakia/gui/sub/user_information/view.py @@ -59,7 +59,8 @@ class UserInformationView(QWidget, Ui_UserInformationWidget): else: localized_mstime_remaining = "###" - text = QCoreApplication.translate("UserInformationView", + text = QCoreApplication.translate( + "UserInformationView", """ <table cellpadding="5"> <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> @@ -67,7 +68,7 @@ class UserInformationView(QWidget, Ui_UserInformationWidget): <tr><td align="right"><b>{:}</b></td><td>{:} BAT</td></tr> <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> - """ + """, ).format( QCoreApplication.translate("UserInformationView", "Public key"), pubkey, @@ -92,8 +93,16 @@ class UserInformationView(QWidget, Ui_UserInformationWidget): Display the uid in the label :param str uid: """ - status_label = QCoreApplication.translate("UserInformationView", "Member") if member else QCoreApplication.translate("UserInformationView", "Not a member") - status_color = "#00AA00" if member else QCoreApplication.translate("UserInformationView", "#FF0000") + status_label = ( + QCoreApplication.translate("UserInformationView", "Member") + if member + else QCoreApplication.translate("UserInformationView", "Not a member") + ) + status_color = ( + "#00AA00" + if member + else QCoreApplication.translate("UserInformationView", "#FF0000") + ) text = "<b>{uid}</b> <p style='color: {status_color};'>({status_label})</p>".format( uid=uid, status_color=status_color, status_label=status_label ) diff --git a/src/sakia/gui/widgets/context_menu.py b/src/sakia/gui/widgets/context_menu.py index 105c3576f62f48b8c34a5107ef32e2386bb0959b..6f01348d7092c9e11c4a9f639288ec46bf644b6d 100644 --- a/src/sakia/gui/widgets/context_menu.py +++ b/src/sakia/gui/widgets/context_menu.py @@ -38,31 +38,42 @@ class ContextMenu(QObject): identity.uid if identity.uid else identity.pubkey[:7] ) - informations = QAction(QCoreApplication.translate("ContextMenu", "Informations"), menu.qmenu.parent()) + informations = QAction( + QCoreApplication.translate("ContextMenu", "Informations"), + menu.qmenu.parent(), + ) informations.triggered.connect(lambda checked, i=identity: menu.informations(i)) menu.qmenu.addAction(informations) if identity.uid and ( not menu._connection or menu._connection.pubkey != identity.pubkey ): - certify = QAction(QCoreApplication.translate("ContextMenu", "Certify identity"), menu.qmenu.parent()) + certify = QAction( + QCoreApplication.translate("ContextMenu", "Certify identity"), + menu.qmenu.parent(), + ) certify.triggered.connect( lambda checked, i=identity: menu.certify_identity(i) ) menu.qmenu.addAction(certify) view_wot = QAction( - QCoreApplication.translate("ContextMenu", "View in Web of Trust"), menu.qmenu.parent() + QCoreApplication.translate("ContextMenu", "View in Web of Trust"), + menu.qmenu.parent(), ) view_wot.triggered.connect(lambda checked, i=identity: menu.view_wot(i)) menu.qmenu.addAction(view_wot) - send_money = QAction(QCoreApplication.translate("ContextMenu", "Send money"), menu.qmenu.parent()) + send_money = QAction( + QCoreApplication.translate("ContextMenu", "Send money"), + menu.qmenu.parent(), + ) send_money.triggered.connect(lambda checked, i=identity: menu.send_money(i)) menu.qmenu.addAction(send_money) copy_pubkey = QAction( - QCoreApplication.translate("ContextMenu", "Copy pubkey to clipboard"), menu.qmenu.parent() + QCoreApplication.translate("ContextMenu", "Copy pubkey to clipboard"), + menu.qmenu.parent(), ) copy_pubkey.triggered.connect( lambda checked, i=identity: ContextMenu.copy_pubkey_to_clipboard(i) @@ -70,7 +81,10 @@ class ContextMenu(QObject): menu.qmenu.addAction(copy_pubkey) copy_pubkey = QAction( - QCoreApplication.translate("ContextMenu", "Copy pubkey to clipboard (with CRC)"), menu.qmenu.parent() + QCoreApplication.translate( + "ContextMenu", "Copy pubkey to clipboard (with CRC)" + ), + menu.qmenu.parent(), ) copy_pubkey.triggered.connect( lambda checked, i=identity: ContextMenu.copy_pubkey_to_clipboard_with_crc(i) @@ -79,7 +93,9 @@ class ContextMenu(QObject): if identity.uid and menu._app.parameters.expert_mode: copy_selfcert = QAction( - QCoreApplication.translate("ContextMenu", "Copy self-certification document to clipboard"), + QCoreApplication.translate( + "ContextMenu", "Copy self-certification document to clipboard" + ), menu.qmenu.parent(), ) copy_selfcert.triggered.connect( @@ -93,15 +109,22 @@ class ContextMenu(QObject): :param ContextMenu menu: the qmenu to add actions to :param Transfer transfer: the transfer """ - menu.qmenu.addSeparator().setText(QCoreApplication.translate("ContextMenu", "Transfer")) + menu.qmenu.addSeparator().setText( + QCoreApplication.translate("ContextMenu", "Transfer") + ) if transfer.state in (Transaction.REFUSED, Transaction.TO_SEND): - send_back = QAction(QCoreApplication.translate("ContextMenu", "Send again"), menu.qmenu.parent()) + send_back = QAction( + QCoreApplication.translate("ContextMenu", "Send again"), + menu.qmenu.parent(), + ) send_back.triggered.connect( lambda checked, tr=transfer: menu.send_again(tr) ) menu.qmenu.addAction(send_back) - cancel = QAction(QCoreApplication.translate("ContextMenu", "Cancel"), menu.qmenu.parent()) + cancel = QAction( + QCoreApplication.translate("ContextMenu", "Cancel"), menu.qmenu.parent() + ) cancel.triggered.connect( lambda checked, tr=transfer: menu.cancel_transfer(tr) ) @@ -109,7 +132,10 @@ class ContextMenu(QObject): if menu._app.parameters.expert_mode: copy_doc = QAction( - QCoreApplication.translate("ContextMenu", "Copy raw transaction to clipboard"), menu.qmenu.parent() + QCoreApplication.translate( + "ContextMenu", "Copy raw transaction to clipboard" + ), + menu.qmenu.parent(), ) copy_doc.triggered.connect( lambda checked, tx=transfer: menu.copy_transaction_to_clipboard(tx) @@ -118,7 +144,9 @@ class ContextMenu(QObject): if transfer.blockstamp: copy_doc = QAction( - QCoreApplication.translate("ContextMenu", "Copy transaction block to clipboard"), + QCoreApplication.translate( + "ContextMenu", "Copy transaction block to clipboard" + ), menu.qmenu.parent(), ) copy_doc.triggered.connect( @@ -133,7 +161,8 @@ class ContextMenu(QObject): if re.match(PUBKEY_REGEX, str_value): menu.qmenu.addSeparator().setText(str_value[:7]) copy_pubkey = QAction( - QCoreApplication.translate("ContextMenu", "Copy pubkey to clipboard"), menu.qmenu.parent() + QCoreApplication.translate("ContextMenu", "Copy pubkey to clipboard"), + menu.qmenu.parent(), ) copy_pubkey.triggered.connect( lambda checked, p=str_value: ContextMenu.copy_pubkey_to_clipboard(p) @@ -141,7 +170,9 @@ class ContextMenu(QObject): menu.qmenu.addAction(copy_pubkey) copy_pubkey = QAction( - QCoreApplication.translate("ContextMenu", "Copy pubkey to clipboard (with CRC)"), + QCoreApplication.translate( + "ContextMenu", "Copy pubkey to clipboard (with CRC)" + ), menu.qmenu.parent(), ) copy_pubkey.triggered.connect( @@ -152,7 +183,10 @@ class ContextMenu(QObject): menu.qmenu.addAction(copy_pubkey) if menu._connection.pubkey != str_value: - send_money = QAction(QCoreApplication.translate("ContextMenu", "Send money"), menu.qmenu.parent()) + send_money = QAction( + QCoreApplication.translate("ContextMenu", "Send money"), + menu.qmenu.parent(), + ) send_money.triggered.connect( lambda checked, p=str_value: menu.send_money(p) ) @@ -236,9 +270,10 @@ class ContextMenu(QObject): reply = QMessageBox.warning( self.qmenu, QCoreApplication.translate("ContextMenu", "Warning"), - QCoreApplication.translate("ContextMenu", + QCoreApplication.translate( + "ContextMenu", """Are you sure? -This money transfer will be removed and not sent.""" +This money transfer will be removed and not sent.""", ), QMessageBox.Ok | QMessageBox.Cancel, ) diff --git a/src/sakia/main.py b/src/sakia/main.py index 16a46f68fb0cc851736215726c788939da8c2214..cc220e0d847cac16bc0fc0c096ac013410f0068b 100755 --- a/src/sakia/main.py +++ b/src/sakia/main.py @@ -163,9 +163,7 @@ def main(): reply = QMessageBox.critical( None, "Error", - "Error connecting to the network: {:}. Keep Trying?".format( - str(e) - ), + "Error connecting to the network: {:}. Keep Trying?".format(str(e)), QMessageBox.Ok | QMessageBox.Abort, ) if reply == QMessageBox.Ok: diff --git a/src/sakia/money/quant_zerosum.py b/src/sakia/money/quant_zerosum.py index d14d3e360d0957d2926f3d702d8746e75271f5e4..33eb08416ec39b044058942692a761db7c460673 100644 --- a/src/sakia/money/quant_zerosum.py +++ b/src/sakia/money/quant_zerosum.py @@ -20,7 +20,7 @@ class QuantitativeZSum(BaseReferential): <tr><td>N</td><td>Members count</td></tr> <tr><td>t</td><td>Last UD time</td></tr> <tr><td>t-1</td><td>Penultimate UD time</td></tr> - </table>""" + </table>""", ) _DESCRIPTION_STR_ = QT_TRANSLATE_NOOP( "QuantitativeZSum", @@ -28,7 +28,7 @@ class QuantitativeZSum(BaseReferential): the quantitative value and the average quantitative value.<br /> If it is positive, the value is above the average value, and if it is negative,<br /> the value is under the average value.<br /> - """ + """, ) def __init__(self, amount, currency, app, block_number=None): diff --git a/src/sakia/money/quantitative.py b/src/sakia/money/quantitative.py index e621cbf46c5d42831fe33abaeae0406abd2961f4..17cd719690830b5233a1b0ea6866cfd5e5484dd6 100644 --- a/src/sakia/money/quantitative.py +++ b/src/sakia/money/quantitative.py @@ -15,7 +15,7 @@ class Quantitative(BaseReferential): <table> <tr><td>Q</td><td>Quantitative value</td></tr> </table> - """ + """, ) _DESCRIPTION_STR_ = QT_TRANSLATE_NOOP( "Quantitative", "Base referential of the money. Units values are used here." @@ -31,10 +31,9 @@ class Quantitative(BaseReferential): @property def units(self): - res = QCoreApplication.translate( - "Quantitative", Quantitative._UNITS_STR_ - ) + res = QCoreApplication.translate("Quantitative", Quantitative._UNITS_STR_) return res + @property def formula(self): return QCoreApplication.translate("Quantitative", Quantitative._FORMULA_STR_) diff --git a/src/sakia/money/relative.py b/src/sakia/money/relative.py index f0f2d2a0b351d2df0b18caff172976fe1918626e..8402fc8e5ef296f249d286b6bdb07c8f8220ec8b 100644 --- a/src/sakia/money/relative.py +++ b/src/sakia/money/relative.py @@ -18,7 +18,7 @@ class Relative(BaseReferential): <tr><td>Q</td><td>Quantitative value</td></tr> <tr><td>UD</td><td>Universal Dividend</td></tr> <tr><td>t</td><td>Last UD time</td></tr> - </table>""" + </table>""", ) _DESCRIPTION_STR_ = QT_TRANSLATE_NOOP( "Relative", @@ -28,7 +28,7 @@ class Relative(BaseReferential): This referential is the most practical one to display prices and accounts.<br /> No money creation or destruction is apparent here and every account tend to<br /> the average. - """ + """, ) def __init__(self, amount, currency, app, block_number=None): diff --git a/src/sakia/money/relative_zerosum.py b/src/sakia/money/relative_zerosum.py index 346127a85e94b7757d2b7e386aef52037b27c944..82748a9b5ced096d215ffb1059adae1ecce2ebac 100644 --- a/src/sakia/money/relative_zerosum.py +++ b/src/sakia/money/relative_zerosum.py @@ -20,7 +20,7 @@ class RelativeZSum(BaseReferential): <tr><td>N</td><td>Members count</td></tr> <tr><td>t</td><td>Last UD time</td></tr> <tr><td>t-1</td><td>Penultimate UD time</td></tr> - </table>""" + </table>""", ) _DESCRIPTION_STR_ = QT_TRANSLATE_NOOP( "RelativeZSum", @@ -28,7 +28,7 @@ class RelativeZSum(BaseReferential): the relative value and the average relative value.<br /> If it is positive, the value is above the average value, and if it is negative,<br /> the value is under the average value.<br /> - """ + """, ) def __init__(self, amount, currency, app, block_number=None): diff --git a/src/sakia/services/documents.py b/src/sakia/services/documents.py index b04d1246a4dca449805a1c7b7776a4d0b83922c1..35726cb09e14631936eb8877b0221678c7f287b8 100644 --- a/src/sakia/services/documents.py +++ b/src/sakia/services/documents.py @@ -152,7 +152,9 @@ class DocumentsService: connection.blockstamp, None, ) - key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) + key = SigningKey.from_credentials( + secret_key, password, connection.scrypt_params + ) membership.sign([key]) self._logger.debug("Membership: {0}".format(membership.signed_raw())) responses = await self._bma_connector.broadcast( @@ -196,16 +198,25 @@ class DocumentsService: return False, "Could not find certified identity signature" certification = Certification( - 10, connection.currency, connection.pubkey, identity.document(), blockUID, "" + 10, + connection.currency, + connection.pubkey, + identity.document(), + blockUID, + "", ) - key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) + key = SigningKey.from_credentials( + secret_key, password, connection.scrypt_params + ) certification.sign([key]) signed_cert = certification.signed_raw() self._logger.debug("Certification: {0}".format(signed_cert)) timestamp = self._blockchain_processor.time(connection.currency) responses = await self._bma_connector.broadcast( - connection.currency, bma.wot.certify, req_args={"certification_signed_raw": signed_cert} + connection.currency, + bma.wot.certify, + req_args={"certification_signed_raw": signed_cert}, ) result = await parse_bma_responses(responses) if result[0]: @@ -231,9 +242,7 @@ class DocumentsService: key = SigningKey.from_credentials(salt, password) revocation.sign([key]) - self._logger.debug( - "Self-Revocation Document: \n{0}".format(revocation.raw()) - ) + self._logger.debug("Self-Revocation Document: \n{0}".format(revocation.raw())) self._logger.debug("Signature: \n{0}".format(revocation.signatures[0])) data = { @@ -242,9 +251,7 @@ class DocumentsService: "sig": revocation.signatures[0], } self._logger.debug("Posted data: {0}".format(data)) - responses = await self._bma_connector.broadcast( - currency, bma.wot.revoke, data - ) + responses = await self._bma_connector.broadcast(currency, bma.wot.revoke, data) result = await parse_bma_responses(responses) return result @@ -271,7 +278,9 @@ class DocumentsService: document = Revocation(10, connection.currency, identity.document(), "") - key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) + key = SigningKey.from_credentials( + secret_key, password, connection.scrypt_params + ) document.sign([key]) @@ -393,7 +402,11 @@ class DocumentsService: # it is not to the user to construct the condition script, but to the dedicated classes total.append( OutputSource( - output_sum, base, output.Condition.token(output.SIG.token(receiver)).compose(output.Condition()) + output_sum, + base, + output.Condition.token(output.SIG.token(receiver)).compose( + output.Condition() + ), ) ) @@ -409,7 +422,9 @@ class DocumentsService: OutputSource( overheads_sum, base, - output.Condition.token(output.SIG.token(issuer)).compose(output.Condition()), + output.Condition.token(output.SIG.token(issuer)).compose( + output.Condition() + ), ) ) @@ -531,7 +546,9 @@ class DocumentsService: :param str message: The message to send with the transfer """ blockstamp = self._blockchain_processor.current_buid(connection.currency) - key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) + key = SigningKey.from_credentials( + secret_key, password, connection.scrypt_params + ) logging.debug("Sender pubkey:{0}".format(key.pubkey)) tx_entities = [] result = (True, ""), tx_entities diff --git a/src/sakia/services/network.py b/src/sakia/services/network.py index 7c55ef458d14a34dc343b0ba18b195b4eb137651..4ffe1ebe96b4ccdfaaf0344f9966eb0865a4dcdf 100644 --- a/src/sakia/services/network.py +++ b/src/sakia/services/network.py @@ -273,9 +273,7 @@ class NetworkService(QObject): ) self._discovery_stack.append(peer) else: - self._logger.debug( - "Wrong document received: {0}".format(peer.signed_raw()) - ) + self._logger.debug("Wrong document received: {0}".format(peer.signed_raw())) @pyqtSlot() def handle_identity_change(self): diff --git a/src/sakia/services/transactions.py b/src/sakia/services/transactions.py index 1db7fda6a864ad86f925028fc2350b8db364027b..637bff4cce5fc82945366529a569b0476247b9d6 100644 --- a/src/sakia/services/transactions.py +++ b/src/sakia/services/transactions.py @@ -223,9 +223,7 @@ class TransactionsService(QObject): req_args={"pubkey": pubkey, "start": start, "end": end}, ) for tx_data in history_data["history"]["sent"]: - for tx in [ - t for t in self._transactions_processor.awaiting(self.currency) - ]: + for tx in [t for t in self._transactions_processor.awaiting(self.currency)]: if self._transactions_processor.run_state_transitions( tx, tx_data["hash"], tx_data["block_number"] ): @@ -234,18 +232,12 @@ class TransactionsService(QObject): "New transaction validated: {0}".format(tx.sha_hash) ) for tx_data in history_data["history"]["received"]: - tx_doc = TransactionDoc.from_bma_history( - history_data["currency"], tx_data - ) + tx_doc = TransactionDoc.from_bma_history(history_data["currency"], tx_data) if not self._transactions_processor.find_by_hash( pubkey, tx_doc.sha_hash ) and SimpleTransaction.is_simple(tx_doc): tx = parse_transaction_doc( - tx_doc, - pubkey, - tx_data["block_number"], - tx_data["time"], - txid, + tx_doc, pubkey, tx_data["block_number"], tx_data["time"], txid, ) if tx: new_transfers.append(tx) @@ -283,9 +275,10 @@ class TransactionsService(QObject): ) if start <= dividend.timestamp <= end: self._logger.debug( - "Dividend from transaction input of block {0} ({1})".format(dividend.block_number, - datetime.fromtimestamp( - dividend.timestamp)) + "Dividend from transaction input of block {0} ({1})".format( + dividend.block_number, + datetime.fromtimestamp(dividend.timestamp), + ) ) block_timestamps.append(dividend.timestamp) block_numbers.append(dividend.block_number) @@ -318,7 +311,10 @@ class TransactionsService(QObject): base=block.unit_base, ) self._logger.debug( - "Dividend from transaction input of block {0} ({1})".format(dividend.block_number, datetime.fromtimestamp(dividend.timestamp)) + "Dividend from transaction input of block {0} ({1})".format( + dividend.block_number, + datetime.fromtimestamp(dividend.timestamp), + ) ) if self._dividends_processor.commit(dividend): dividends.append(dividend)