Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
[#145] Reformat core commands for PEP-8.
Browse files Browse the repository at this point in the history
  • Loading branch information
todofixthis committed Jun 11, 2018
1 parent e5f3f82 commit 0d57510
Show file tree
Hide file tree
Showing 16 changed files with 453 additions and 472 deletions.
31 changes: 16 additions & 15 deletions iota/commands/core/add_neighbors.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
# coding=utf-8
from __future__ import absolute_import, division, print_function, \
unicode_literals
unicode_literals

import filters as f

from iota.commands import FilterCommand, RequestFilter
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),
})
65 changes: 34 additions & 31 deletions iota/commands/core/attach_to_tangle.py
Original file line number Diff line number Diff line change
@@ -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),
),
})
44 changes: 22 additions & 22 deletions iota/commands/core/broadcast_transactions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
from __future__ import absolute_import, division, print_function, \
unicode_literals
unicode_literals

import filters as f

Expand All @@ -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),
),
})
40 changes: 20 additions & 20 deletions iota/commands/core/check_consistency.py
Original file line number Diff line number Diff line change
@@ -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)),
})
Loading

0 comments on commit 0d57510

Please sign in to comment.