From 0d57510471e7b333227c2ec69132a0bdf72f9391 Mon Sep 17 00:00:00 2001 From: Phoenix Zerin Date: Tue, 12 Jun 2018 08:24:29 +1200 Subject: [PATCH] [#145] Reformat core commands for PEP-8. --- iota/commands/core/add_neighbors.py | 31 +-- iota/commands/core/attach_to_tangle.py | 65 ++++--- iota/commands/core/broadcast_transactions.py | 44 ++--- iota/commands/core/check_consistency.py | 40 ++-- iota/commands/core/find_transactions.py | 178 +++++++++--------- iota/commands/core/get_balances.py | 80 ++++---- iota/commands/core/get_inclusion_states.py | 77 ++++---- iota/commands/core/get_neighbors.py | 30 +-- iota/commands/core/get_node_info.py | 47 ++--- iota/commands/core/get_tips.py | 47 +++-- .../core/get_transactions_to_approve.py | 77 ++++---- iota/commands/core/get_trytes.py | 58 +++--- .../core/interrupt_attaching_to_tangle.py | 30 +-- iota/commands/core/remove_neighbors.py | 33 ++-- iota/commands/core/store_transactions.py | 43 +++-- .../core/were_addresses_spent_from.py | 45 ++--- 16 files changed, 453 insertions(+), 472 deletions(-) diff --git a/iota/commands/core/add_neighbors.py b/iota/commands/core/add_neighbors.py index 5943b4e..85e1ff1 100644 --- a/iota/commands/core/add_neighbors.py +++ b/iota/commands/core/add_neighbors.py @@ -1,6 +1,6 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f @@ -8,27 +8,28 @@ from iota.filters import NodeUri __all__ = [ - 'AddNeighborsCommand', + 'AddNeighborsCommand', ] class AddNeighborsCommand(FilterCommand): - """ - Executes `addNeighbors` command. + """ + Executes `addNeighbors` command. - See :py:meth:`iota.api.StrictIota.add_neighbors`. - """ - command = 'addNeighbors' + See :py:meth:`iota.api.StrictIota.add_neighbors`. + """ + command = 'addNeighbors' - def get_request_filter(self): - return AddNeighborsRequestFilter() + def get_request_filter(self): + return AddNeighborsRequestFilter() - def get_response_filter(self): - pass + def get_response_filter(self): + pass class AddNeighborsRequestFilter(RequestFilter): - def __init__(self): - super(AddNeighborsRequestFilter, self).__init__({ - 'uris': f.Required | f.Array | f.FilterRepeater(f.Required | NodeUri), - }) + def __init__(self): + super(AddNeighborsRequestFilter, self).__init__({ + 'uris': + f.Required | f.Array | f.FilterRepeater(f.Required | NodeUri), + }) diff --git a/iota/commands/core/attach_to_tangle.py b/iota/commands/core/attach_to_tangle.py index e0ad1b0..daefec5 100644 --- a/iota/commands/core/attach_to_tangle.py +++ b/iota/commands/core/attach_to_tangle.py @@ -1,55 +1,58 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f + from iota import TransactionHash, TransactionTrytes from iota.commands import FilterCommand, RequestFilter, ResponseFilter from iota.filters import Trytes __all__ = [ - 'AttachToTangleCommand', + 'AttachToTangleCommand', ] class AttachToTangleCommand(FilterCommand): - """ - Executes ``attachToTangle`` command. + """ + Executes ``attachToTangle`` command. - See :py:meth:`iota.api.StrictIota.attach_to_tangle` for more info. - """ - command = 'attachToTangle' + See :py:meth:`iota.api.StrictIota.attach_to_tangle` for more info. + """ + command = 'attachToTangle' - def get_request_filter(self): - return AttachToTangleRequestFilter() + def get_request_filter(self): + return AttachToTangleRequestFilter() - def get_response_filter(self): - return AttachToTangleResponseFilter() + def get_response_filter(self): + return AttachToTangleResponseFilter() class AttachToTangleRequestFilter(RequestFilter): - def __init__(self): - super(AttachToTangleRequestFilter, self).__init__({ - 'branchTransaction': f.Required | Trytes(result_type=TransactionHash), - 'trunkTransaction': f.Required | Trytes(result_type=TransactionHash), + def __init__(self): + super(AttachToTangleRequestFilter, self).__init__({ + 'branchTransaction': f.Required | Trytes(TransactionHash), + 'trunkTransaction': f.Required | Trytes(TransactionHash), - 'trytes': - f.Required - | f.Array - | f.FilterRepeater(f.Required | Trytes(result_type=TransactionTrytes)), + 'trytes': + f.Required | + f.Array | + f.FilterRepeater( + f.Required | Trytes(result_type=TransactionTrytes), + ), - # Loosely-validated; testnet nodes require a different value than - # mainnet. - 'minWeightMagnitude': f.Required| f.Type(int) | f.Min(1), - }) + # Loosely-validated; testnet nodes require a different value + # than mainnet. + 'minWeightMagnitude': f.Required | f.Type(int) | f.Min(1), + }) class AttachToTangleResponseFilter(ResponseFilter): - def __init__(self): - super(AttachToTangleResponseFilter, self).__init__({ - 'trytes': - f.FilterRepeater( - f.ByteString(encoding='ascii') - | Trytes(result_type=TransactionTrytes) - ), - }) + def __init__(self): + super(AttachToTangleResponseFilter, self).__init__({ + 'trytes': + f.FilterRepeater( + f.ByteString(encoding='ascii') | + Trytes(TransactionTrytes), + ), + }) diff --git a/iota/commands/core/broadcast_transactions.py b/iota/commands/core/broadcast_transactions.py index 70da1c5..77625c7 100644 --- a/iota/commands/core/broadcast_transactions.py +++ b/iota/commands/core/broadcast_transactions.py @@ -1,6 +1,6 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f @@ -9,34 +9,34 @@ from iota.filters import Trytes __all__ = [ - 'BroadcastTransactionsCommand', + 'BroadcastTransactionsCommand', ] class BroadcastTransactionsCommand(FilterCommand): - """ - Executes `broadcastTransactions` command. + """ + Executes `broadcastTransactions` command. - See :py:meth:`iota.api.StrictIota.broadcast_transactions`. - """ - command = 'broadcastTransactions' + See :py:meth:`iota.api.StrictIota.broadcast_transactions`. + """ + command = 'broadcastTransactions' - def get_request_filter(self): - return BroadcastTransactionsRequestFilter() + def get_request_filter(self): + return BroadcastTransactionsRequestFilter() - def get_response_filter(self): - pass + def get_response_filter(self): + pass class BroadcastTransactionsRequestFilter(RequestFilter): - def __init__(self): - super(BroadcastTransactionsRequestFilter, self).__init__({ - 'trytes': - f.Required - | f.Array - | f.FilterRepeater( - f.Required - | Trytes(result_type=TransactionTrytes) - | f.Unicode(encoding='ascii', normalize=False) - ), - }) + def __init__(self): + super(BroadcastTransactionsRequestFilter, self).__init__({ + 'trytes': + f.Required | + f.Array | + f.FilterRepeater( + f.Required | + Trytes(TransactionTrytes) | + f.Unicode(encoding='ascii', normalize=False), + ), + }) diff --git a/iota/commands/core/check_consistency.py b/iota/commands/core/check_consistency.py index 09c3f41..598322e 100644 --- a/iota/commands/core/check_consistency.py +++ b/iota/commands/core/check_consistency.py @@ -1,38 +1,38 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f -from iota import Transaction, TransactionHash + +from iota import TransactionHash from iota.commands import FilterCommand, RequestFilter from iota.filters import Trytes __all__ = [ - 'CheckConsistencyCommand', + 'CheckConsistencyCommand', ] class CheckConsistencyCommand(FilterCommand): - """ - Executes ``checkConsistency`` extended API command. + """ + Executes ``checkConsistency`` extended API command. - See :py:meth:`iota.api.Iota.check_consistency` for more info. - """ - command = 'checkConsistency' + See :py:meth:`iota.api.Iota.check_consistency` for more info. + """ + command = 'checkConsistency' - def get_request_filter(self): - return CheckConsistencyRequestFilter() + def get_request_filter(self): + return CheckConsistencyRequestFilter() - def get_response_filter(self): - pass + def get_response_filter(self): + pass class CheckConsistencyRequestFilter(RequestFilter): - def __init__(self): - super(CheckConsistencyRequestFilter, self).__init__({ - 'tails': ( - f.Required - | f.Array - | f.FilterRepeater(f.Required | Trytes(result_type=TransactionHash)) - ), - }) + def __init__(self): + super(CheckConsistencyRequestFilter, self).__init__({ + 'tails': + f.Required | + f.Array | + f.FilterRepeater(f.Required | Trytes(TransactionHash)), + }) diff --git a/iota/commands/core/find_transactions.py b/iota/commands/core/find_transactions.py index 0071586..a8411fb 100644 --- a/iota/commands/core/find_transactions.py +++ b/iota/commands/core/find_transactions.py @@ -1,117 +1,111 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f from six import iteritems -from iota import Address, Tag, TransactionHash +from iota import Tag, TransactionHash from iota.commands import FilterCommand, RequestFilter, ResponseFilter from iota.filters import AddressNoChecksum, Trytes __all__ = [ - 'FindTransactionsCommand', + 'FindTransactionsCommand', ] class FindTransactionsCommand(FilterCommand): - """ - Executes `findTransactions` command. + """ + Executes `findTransactions` command. - See :py:meth:`iota.api.StrictIota.find_transactions`. - """ - command = 'findTransactions' + See :py:meth:`iota.api.StrictIota.find_transactions`. + """ + command = 'findTransactions' - def get_request_filter(self): - return FindTransactionsRequestFilter() + def get_request_filter(self): + return FindTransactionsRequestFilter() - def get_response_filter(self): - return FindTransactionsResponseFilter() + def get_response_filter(self): + return FindTransactionsResponseFilter() class FindTransactionsRequestFilter(RequestFilter): - CODE_NO_SEARCH_VALUES = 'no_search_values' - - templates = { - CODE_NO_SEARCH_VALUES: 'No search values specified.', - } - - def __init__(self): - super(FindTransactionsRequestFilter, self).__init__( - { - 'addresses': ( - f.Array - | f.FilterRepeater( - f.Required - | AddressNoChecksum() - | f.Unicode(encoding='ascii', normalize=False) - ) - ), - - 'approvees': ( - f.Array - | f.FilterRepeater( - f.Required - | Trytes(result_type=TransactionHash) - | f.Unicode(encoding='ascii', normalize=False) - ) - ), - - 'bundles': ( - f.Array - | f.FilterRepeater( - f.Required - | Trytes(result_type=TransactionHash) - | f.Unicode(encoding='ascii', normalize=False) - ) - ), - - 'tags': ( - f.Array - | f.FilterRepeater( - f.Required - | Trytes(result_type=Tag) - | f.Unicode(encoding='ascii', normalize=False) - ) - ), - }, - - # Technically, all of the parameters for this command are - # optional, so long as at least one of them is present and not - # empty. - allow_missing_keys = True, - ) - - def _apply(self, value): - value = super(FindTransactionsRequestFilter, self)._apply(value) # type: dict - - if self._has_errors: - return value - - # Remove null search terms. - # Note: We will assume that empty lists are intentional. - # https://github.com/iotaledger/iota.lib.py/issues/96 - search_terms = { - term: query - for term, query in iteritems(value) - if query is not None - } + CODE_NO_SEARCH_VALUES = 'no_search_values' - # At least one search term is required. - if not search_terms: - # Include unfiltered ``value`` in filter error context. - return self._invalid_value(value, self.CODE_NO_SEARCH_VALUES) + templates = { + CODE_NO_SEARCH_VALUES: 'No search values specified.', + } - return search_terms + def __init__(self): + super(FindTransactionsRequestFilter, self).__init__( + { + 'addresses': + f.Array | f.FilterRepeater( + f.Required | + AddressNoChecksum() | + f.Unicode(encoding='ascii', normalize=False), + ), + + 'approvees': + f.Array | f.FilterRepeater( + f.Required | + Trytes(TransactionHash) | + f.Unicode(encoding='ascii', normalize=False), + ), + + 'bundles': + f.Array | f.FilterRepeater( + f.Required | + Trytes(TransactionHash) | + f.Unicode(encoding='ascii', normalize=False), + ), + + 'tags': + f.Array | f.FilterRepeater( + f.Required | + Trytes(Tag) | + f.Unicode(encoding='ascii', normalize=False), + ), + }, + + # Technically, all of the parameters for this command are + # optional, so long as at least one of them is present and + # not empty. + allow_missing_keys=True, + ) + + def _apply(self, value): + value = super(FindTransactionsRequestFilter, self)._apply( + value + ) # type: dict + + if self._has_errors: + return value + + # Remove null search terms. + # Note: We will assume that empty lists are intentional. + # https://github.com/iotaledger/iota.lib.py/issues/96 + search_terms = { + term: query + for term, query in iteritems(value) + if query is not None + } + + # At least one search term is required. + if not search_terms: + # Include unfiltered ``value`` in filter error context. + return self._invalid_value(value, self.CODE_NO_SEARCH_VALUES) + + return search_terms class FindTransactionsResponseFilter(ResponseFilter): - def __init__(self): - super(FindTransactionsResponseFilter, self).__init__({ - 'hashes': - f.FilterRepeater( - f.ByteString(encoding='ascii') - | Trytes(result_type=TransactionHash) - ) - | f.Optional(default=[]), - }) + def __init__(self): + super(FindTransactionsResponseFilter, self).__init__({ + 'hashes': + f.FilterRepeater( + f.ByteString(encoding='ascii') | + Trytes(TransactionHash) + ) | + f.Optional(default=[]), + }) diff --git a/iota/commands/core/get_balances.py b/iota/commands/core/get_balances.py index a109b58..423e9ca 100644 --- a/iota/commands/core/get_balances.py +++ b/iota/commands/core/get_balances.py @@ -1,6 +1,6 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f @@ -9,58 +9,54 @@ from iota.filters import AddressNoChecksum, Trytes __all__ = [ - 'GetBalancesCommand', + 'GetBalancesCommand', ] class GetBalancesCommand(FilterCommand): - """ - Executes `getBalances` command. + """ + Executes `getBalances` command. - See :py:meth:`iota.api.StrictIota.get_balances`. - """ - command = 'getBalances' + See :py:meth:`iota.api.StrictIota.get_balances`. + """ + command = 'getBalances' - def get_request_filter(self): - return GetBalancesRequestFilter() + def get_request_filter(self): + return GetBalancesRequestFilter() - def get_response_filter(self): - return GetBalancesResponseFilter() + def get_response_filter(self): + return GetBalancesResponseFilter() class GetBalancesRequestFilter(RequestFilter): - def __init__(self): - super(GetBalancesRequestFilter, self).__init__( - { - 'addresses': ( - f.Required - | f.Array - | f.FilterRepeater( - f.Required - | AddressNoChecksum() - | f.Unicode(encoding='ascii', normalize=False) - ) - ), - - 'threshold': ( - f.Type(int) - | f.Min(0) - | f.Max(100) - | f.Optional(default=100) - ), - }, - - allow_missing_keys = { - 'threshold', - }, - ) + def __init__(self): + super(GetBalancesRequestFilter, self).__init__( + { + 'addresses': + f.Required | f.Array | f.FilterRepeater( + f.Required | + AddressNoChecksum() | + f.Unicode(encoding='ascii', normalize=False), + ), + + 'threshold': + f.Type(int) | + f.Min(0) | + f.Max(100) | + f.Optional(default=100), + }, + + allow_missing_keys={ + 'threshold', + }, + ) class GetBalancesResponseFilter(ResponseFilter): - def __init__(self): - super(GetBalancesResponseFilter, self).__init__({ - 'balances': f.Array | f.FilterRepeater(f.Int), + def __init__(self): + super(GetBalancesResponseFilter, self).__init__({ + 'balances': f.Array | f.FilterRepeater(f.Int), - 'milestone': - f.ByteString(encoding='ascii') | Trytes(result_type=Address), - }) + 'milestone': + f.ByteString(encoding='ascii') | Trytes(Address), + }) diff --git a/iota/commands/core/get_inclusion_states.py b/iota/commands/core/get_inclusion_states.py index f5309c8..bc3066e 100644 --- a/iota/commands/core/get_inclusion_states.py +++ b/iota/commands/core/get_inclusion_states.py @@ -1,6 +1,6 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f @@ -9,53 +9,48 @@ from iota.filters import Trytes __all__ = [ - 'GetInclusionStatesCommand', + 'GetInclusionStatesCommand', ] class GetInclusionStatesCommand(FilterCommand): - """ - Executes ``getInclusionStates`` command. + """ + Executes ``getInclusionStates`` command. - See :py:meth:`iota.api.StrictIota.get_inclusion_states`. - """ - command = 'getInclusionStates' + See :py:meth:`iota.api.StrictIota.get_inclusion_states`. + """ + command = 'getInclusionStates' - def get_request_filter(self): - return GetInclusionStatesRequestFilter() + def get_request_filter(self): + return GetInclusionStatesRequestFilter() - def get_response_filter(self): - pass + def get_response_filter(self): + pass class GetInclusionStatesRequestFilter(RequestFilter): - def __init__(self): - super(GetInclusionStatesRequestFilter, self).__init__( - { - # Required parameters. - 'transactions': ( - f.Required - | f.Array - | f.FilterRepeater( - f.Required - | Trytes(result_type=TransactionHash) - | f.Unicode(encoding='ascii', normalize=False) - ) - ), - - # Optional parameters. - 'tips': ( - f.Array - | f.FilterRepeater( - f.Required - | Trytes(result_type=TransactionHash) - | f.Unicode(encoding='ascii', normalize=False) - ) - | f.Optional(default=[]) - ), - }, - - allow_missing_keys = { - 'tips', - }, - ) + def __init__(self): + super(GetInclusionStatesRequestFilter, self).__init__( + { + # Required parameters. + 'transactions': + f.Required | f.Array | f.FilterRepeater( + f.Required | + Trytes(TransactionHash) | + f.Unicode(encoding='ascii', normalize=False), + ), + + # Optional parameters. + 'tips': + f.Array | f.FilterRepeater( + f.Required | + Trytes(TransactionHash) | + f.Unicode(encoding='ascii', normalize=False), + ) | + f.Optional(default=[]), + }, + + allow_missing_keys={ + 'tips', + }, + ) diff --git a/iota/commands/core/get_neighbors.py b/iota/commands/core/get_neighbors.py index d717bb9..9d074f4 100644 --- a/iota/commands/core/get_neighbors.py +++ b/iota/commands/core/get_neighbors.py @@ -1,31 +1,31 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals from iota.commands import FilterCommand, RequestFilter __all__ = [ - 'GetNeighborsCommand', + 'GetNeighborsCommand', ] class GetNeighborsCommand(FilterCommand): - """ - Executes ``getNeighbors`` command. + """ + Executes ``getNeighbors`` command. - See :py:meth:`iota.api.StrictIota.get_neighbors`. - """ - command = 'getNeighbors' + See :py:meth:`iota.api.StrictIota.get_neighbors`. + """ + command = 'getNeighbors' - def get_request_filter(self): - return GetNeighborsRequestFilter() + def get_request_filter(self): + return GetNeighborsRequestFilter() - def get_response_filter(self): - pass + def get_response_filter(self): + pass class GetNeighborsRequestFilter(RequestFilter): - def __init__(self): - # `getNeighbors` does not accept any parameters. - # Using a filter here just to enforce that the request is empty. - super(GetNeighborsRequestFilter, self).__init__({}) + def __init__(self): + # ``getNeighbors`` does not accept any parameters. + # Using a filter here just to enforce that the request is empty. + super(GetNeighborsRequestFilter, self).__init__({}) diff --git a/iota/commands/core/get_node_info.py b/iota/commands/core/get_node_info.py index b642b93..85d4386 100644 --- a/iota/commands/core/get_node_info.py +++ b/iota/commands/core/get_node_info.py @@ -1,45 +1,46 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f + from iota import TransactionHash from iota.commands import FilterCommand, RequestFilter, ResponseFilter from iota.filters import Trytes __all__ = [ - 'GetNodeInfoCommand', + 'GetNodeInfoCommand', ] class GetNodeInfoCommand(FilterCommand): - """ - Executes `getNodeInfo` command. + """ + Executes `getNodeInfo` command. - See :py:meth:`iota.api.StrictIota.get_node_info`. - """ - command = 'getNodeInfo' + See :py:meth:`iota.api.StrictIota.get_node_info`. + """ + command = 'getNodeInfo' - def get_request_filter(self): - return GetNodeInfoRequestFilter() + def get_request_filter(self): + return GetNodeInfoRequestFilter() - def get_response_filter(self): - return GetNodeInfoResponseFilter() + def get_response_filter(self): + return GetNodeInfoResponseFilter() class GetNodeInfoRequestFilter(RequestFilter): - def __init__(self): - # `getNodeInfo` does not accept any parameters. - # Using a filter here just to enforce that the request is empty. - super(GetNodeInfoRequestFilter, self).__init__({}) + def __init__(self): + # ``getNodeInfo`` does not accept any parameters. + # Using a filter here just to enforce that the request is empty. + super(GetNodeInfoRequestFilter, self).__init__({}) class GetNodeInfoResponseFilter(ResponseFilter): - def __init__(self): - super(GetNodeInfoResponseFilter, self).__init__({ - 'latestMilestone': - f.ByteString(encoding='ascii') | Trytes(result_type=TransactionHash), - - 'latestSolidSubtangleMilestone': - f.ByteString(encoding='ascii') | Trytes(result_type=TransactionHash), - }) + def __init__(self): + super(GetNodeInfoResponseFilter, self).__init__({ + 'latestMilestone': + f.ByteString(encoding='ascii') | Trytes(TransactionHash), + + 'latestSolidSubtangleMilestone': + f.ByteString(encoding='ascii') | Trytes(TransactionHash), + }) diff --git a/iota/commands/core/get_tips.py b/iota/commands/core/get_tips.py index b97e9f8..f4ab15a 100644 --- a/iota/commands/core/get_tips.py +++ b/iota/commands/core/get_tips.py @@ -1,6 +1,6 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f @@ -9,40 +9,37 @@ from iota.transaction.types import TransactionHash __all__ = [ - 'GetTipsCommand', + 'GetTipsCommand', ] class GetTipsCommand(FilterCommand): - """ - Executes ``getTips`` command. + """ + Executes ``getTips`` command. - See :py:meth:`iota.api.StrictIota.get_tips`. - """ - command = 'getTips' + See :py:meth:`iota.api.StrictIota.get_tips`. + """ + command = 'getTips' - def get_request_filter(self): - return GetTipsRequestFilter() + def get_request_filter(self): + return GetTipsRequestFilter() - def get_response_filter(self): - return GetTipsResponseFilter() + def get_response_filter(self): + return GetTipsResponseFilter() class GetTipsRequestFilter(RequestFilter): - def __init__(self): - # `getTips` doesn't accept any parameters. - # Using a filter here just to enforce that the request is empty. - super(GetTipsRequestFilter, self).__init__({}) + def __init__(self): + # ``getTips`` doesn't accept any parameters. + # Using a filter here just to enforce that the request is empty. + super(GetTipsRequestFilter, self).__init__({}) class GetTipsResponseFilter(ResponseFilter): - def __init__(self): - super(GetTipsResponseFilter, self).__init__({ - 'hashes': ( - f.Array - | f.FilterRepeater( - f.ByteString(encoding='ascii') - | Trytes(result_type=TransactionHash) - ) - ), - }) + def __init__(self): + super(GetTipsResponseFilter, self).__init__({ + 'hashes': + f.Array | f.FilterRepeater( + f.ByteString(encoding='ascii') | Trytes(TransactionHash), + ), + }) diff --git a/iota/commands/core/get_transactions_to_approve.py b/iota/commands/core/get_transactions_to_approve.py index 7ab0b86..d9f9ac5 100644 --- a/iota/commands/core/get_transactions_to_approve.py +++ b/iota/commands/core/get_transactions_to_approve.py @@ -1,6 +1,6 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f @@ -9,60 +9,59 @@ from iota.filters import Trytes __all__ = [ - 'GetTransactionsToApproveCommand', + 'GetTransactionsToApproveCommand', ] class GetTransactionsToApproveCommand(FilterCommand): - """ - Executes ``getTransactionsToApprove`` command. + """ + Executes ``getTransactionsToApprove`` command. - See :py:meth:`iota.api.StrictIota.get_transactions_to_approve`. - """ - command = 'getTransactionsToApprove' + See :py:meth:`iota.api.StrictIota.get_transactions_to_approve`. + """ + command = 'getTransactionsToApprove' - def get_request_filter(self): - return GetTransactionsToApproveRequestFilter() + def get_request_filter(self): + return GetTransactionsToApproveRequestFilter() - def get_response_filter(self): - return GetTransactionsToApproveResponseFilter() + def get_response_filter(self): + return GetTransactionsToApproveResponseFilter() class GetTransactionsToApproveRequestFilter(RequestFilter): - def __init__(self): - super(GetTransactionsToApproveRequestFilter, self).__init__({ - 'depth': f.Required | f.Type(int) | f.Min(1), + def __init__(self): + super(GetTransactionsToApproveRequestFilter, self).__init__( + { + 'depth': f.Required | f.Type(int) | f.Min(1), - 'reference': Trytes(result_type=TransactionHash), - }, + 'reference': Trytes(result_type=TransactionHash), + }, - allow_missing_keys = { - 'reference', - }) + allow_missing_keys={ + 'reference', + }) - def _apply(self, value): - value = super(GetTransactionsToApproveRequestFilter, self)._apply(value) # type: dict + def _apply(self, value): + value = super(GetTransactionsToApproveRequestFilter, self)._apply( + value, + ) # type: dict - if self._has_errors: - return value + if self._has_errors: + return value - # Remove reference if null. - if value['reference'] is None: - del value['reference'] + # Remove reference if null. + if value['reference'] is None: + del value['reference'] - return value + return value class GetTransactionsToApproveResponseFilter(ResponseFilter): - def __init__(self): - super(GetTransactionsToApproveResponseFilter, self).__init__({ - 'branchTransaction': ( - f.ByteString(encoding='ascii') - | Trytes(result_type=TransactionHash) - ), - - 'trunkTransaction': ( - f.ByteString(encoding='ascii') - | Trytes(result_type=TransactionHash) - ), - }) + def __init__(self): + super(GetTransactionsToApproveResponseFilter, self).__init__({ + 'branchTransaction': + f.ByteString(encoding='ascii') | Trytes(TransactionHash), + + 'trunkTransaction': + f.ByteString(encoding='ascii') | Trytes(TransactionHash), + }) diff --git a/iota/commands/core/get_trytes.py b/iota/commands/core/get_trytes.py index e6aabde..3915b59 100644 --- a/iota/commands/core/get_trytes.py +++ b/iota/commands/core/get_trytes.py @@ -1,6 +1,6 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f @@ -9,45 +9,43 @@ from iota.filters import Trytes __all__ = [ - 'GetTrytesCommand', + 'GetTrytesCommand', ] class GetTrytesCommand(FilterCommand): - """ - Executes ``getTrytes`` command. + """ + Executes ``getTrytes`` command. - See :py:meth:`iota.api.StrictIota.get_trytes`. - """ - command = 'getTrytes' + See :py:meth:`iota.api.StrictIota.get_trytes`. + """ + command = 'getTrytes' - def get_request_filter(self): - return GetTrytesRequestFilter() + def get_request_filter(self): + return GetTrytesRequestFilter() - def get_response_filter(self): - return GetTrytesResponseFilter() + def get_response_filter(self): + return GetTrytesResponseFilter() class GetTrytesRequestFilter(RequestFilter): - def __init__(self): - super(GetTrytesRequestFilter, self).__init__({ - 'hashes': ( - f.Required - | f.Array - | f.FilterRepeater( - f.Required - | Trytes(result_type=TransactionHash) - | f.Unicode(encoding='ascii', normalize=False) - ) - ), - }) + def __init__(self): + super(GetTrytesRequestFilter, self).__init__({ + 'hashes': + f.Required | f.Array | f.FilterRepeater( + f.Required | + Trytes(TransactionHash) | + f.Unicode(encoding='ascii', normalize=False), + ), + }) class GetTrytesResponseFilter(ResponseFilter): - def __init__(self): - super(GetTrytesResponseFilter, self).__init__({ - 'trytes': ( - f.Array - | f.FilterRepeater(f.ByteString(encoding='ascii') | Trytes) - ), - }) + def __init__(self): + super(GetTrytesResponseFilter, self).__init__({ + 'trytes': + f.Array | f.FilterRepeater( + f.ByteString(encoding='ascii') | + Trytes + ), + }) diff --git a/iota/commands/core/interrupt_attaching_to_tangle.py b/iota/commands/core/interrupt_attaching_to_tangle.py index d1fffe3..837e87e 100644 --- a/iota/commands/core/interrupt_attaching_to_tangle.py +++ b/iota/commands/core/interrupt_attaching_to_tangle.py @@ -1,31 +1,31 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals from iota.commands import FilterCommand, RequestFilter __all__ = [ - 'InterruptAttachingToTangleCommand', + 'InterruptAttachingToTangleCommand', ] class InterruptAttachingToTangleCommand(FilterCommand): - """ - Executes ``interruptAttachingToTangle`` command. + """ + Executes ``interruptAttachingToTangle`` command. - See :py:meth:`iota.api.StrictIota.interrupt_attaching_to_tangle`. - """ - command = 'interruptAttachingToTangle' + See :py:meth:`iota.api.StrictIota.interrupt_attaching_to_tangle`. + """ + command = 'interruptAttachingToTangle' - def get_request_filter(self): - return InterruptAttachingToTangleRequestFilter() + def get_request_filter(self): + return InterruptAttachingToTangleRequestFilter() - def get_response_filter(self): - pass + def get_response_filter(self): + pass class InterruptAttachingToTangleRequestFilter(RequestFilter): - def __init__(self): - # `interruptAttachingToTangle` takes no parameters. - # Using a filter here just to enforce that the request is empty. - super(InterruptAttachingToTangleRequestFilter, self).__init__({}) + def __init__(self): + # ``interruptAttachingToTangle`` takes no parameters. + # Using a filter here just to enforce that the request is empty. + super(InterruptAttachingToTangleRequestFilter, self).__init__({}) diff --git a/iota/commands/core/remove_neighbors.py b/iota/commands/core/remove_neighbors.py index 057db1c..6e0896c 100644 --- a/iota/commands/core/remove_neighbors.py +++ b/iota/commands/core/remove_neighbors.py @@ -1,6 +1,6 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f @@ -8,27 +8,30 @@ from iota.filters import NodeUri __all__ = [ - 'RemoveNeighborsCommand', + 'RemoveNeighborsCommand', ] class RemoveNeighborsCommand(FilterCommand): - """ - Executes ``removeNeighbors`` command. + """ + Executes ``removeNeighbors`` command. - See :py:meth:`iota.api.StrictIota.remove_neighbors`. - """ - command = 'removeNeighbors' + See :py:meth:`iota.api.StrictIota.remove_neighbors`. + """ + command = 'removeNeighbors' - def get_request_filter(self): - return RemoveNeighborsRequestFilter() + def get_request_filter(self): + return RemoveNeighborsRequestFilter() - def get_response_filter(self): - pass + def get_response_filter(self): + pass class RemoveNeighborsRequestFilter(RequestFilter): - def __init__(self): - super(RemoveNeighborsRequestFilter, self).__init__({ - 'uris': f.Required | f.Array | f.FilterRepeater(f.Required | NodeUri), - }) + def __init__(self): + super(RemoveNeighborsRequestFilter, self).__init__({ + 'uris': f.Required | f.Array | f.FilterRepeater( + f.Required | + NodeUri, + ), + }) diff --git a/iota/commands/core/store_transactions.py b/iota/commands/core/store_transactions.py index 3a6f7c4..0412eec 100644 --- a/iota/commands/core/store_transactions.py +++ b/iota/commands/core/store_transactions.py @@ -1,41 +1,40 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f + from iota import TransactionTrytes from iota.commands import FilterCommand, RequestFilter from iota.filters import Trytes __all__ = [ - 'StoreTransactionsCommand', + 'StoreTransactionsCommand', ] class StoreTransactionsCommand(FilterCommand): - """ - Executes ``storeTransactions`` command. + """ + Executes ``storeTransactions`` command. - See :py:meth:`iota.api.StrictIota.store_transactions`. - """ - command = 'storeTransactions' + See :py:meth:`iota.api.StrictIota.store_transactions`. + """ + command = 'storeTransactions' - def get_request_filter(self): - return StoreTransactionsRequestFilter() + def get_request_filter(self): + return StoreTransactionsRequestFilter() - def get_response_filter(self): - pass + def get_response_filter(self): + pass class StoreTransactionsRequestFilter(RequestFilter): - def __init__(self): - super(StoreTransactionsRequestFilter, self).__init__({ - 'trytes': - f.Required - | f.Array - | f.FilterRepeater( - f.Required - | Trytes(result_type=TransactionTrytes) - | f.Unicode(encoding='ascii', normalize=False) - ), - }) + def __init__(self): + super(StoreTransactionsRequestFilter, self).__init__({ + 'trytes': + f.Required | f.Array | f.FilterRepeater( + f.Required | + Trytes(TransactionTrytes) | + f.Unicode(encoding='ascii', normalize=False), + ), + }) diff --git a/iota/commands/core/were_addresses_spent_from.py b/iota/commands/core/were_addresses_spent_from.py index 317ee99..0d41e17 100644 --- a/iota/commands/core/were_addresses_spent_from.py +++ b/iota/commands/core/were_addresses_spent_from.py @@ -1,6 +1,6 @@ # coding=utf-8 from __future__ import absolute_import, division, print_function, \ - unicode_literals + unicode_literals import filters as f @@ -8,37 +8,32 @@ from iota.filters import AddressNoChecksum __all__ = [ - 'WereAddressesSpentFromCommand', + 'WereAddressesSpentFromCommand', ] class WereAddressesSpentFromCommand(FilterCommand): - """ - Executes `wereAddressesSpentFrom` command. + """ + Executes `wereAddressesSpentFrom` command. - See :py:meth:`iota.api.StrictIota.were_addresses_spent_from`. - """ - command = 'wereAddressesSpentFrom' + See :py:meth:`iota.api.StrictIota.were_addresses_spent_from`. + """ + command = 'wereAddressesSpentFrom' - def get_request_filter(self): - return WereAddressesSpentFromRequestFilter() + def get_request_filter(self): + return WereAddressesSpentFromRequestFilter() - def get_response_filter(self): - pass + def get_response_filter(self): + pass class WereAddressesSpentFromRequestFilter(RequestFilter): - def __init__(self): - super(WereAddressesSpentFromRequestFilter, self).__init__( - { - 'addresses': ( - f.Required - | f.Array - | f.FilterRepeater( - f.Required - | AddressNoChecksum() - | f.Unicode(encoding='ascii', normalize=False) - ) - ), - } - ) + def __init__(self): + super(WereAddressesSpentFromRequestFilter, self).__init__({ + 'addresses': + f.Required | f.Array | f.FilterRepeater( + f.Required | + AddressNoChecksum() | + f.Unicode(encoding='ascii', normalize=False), + ), + })