Skip to content

Commit

Permalink
Merge branch 'develop' into f-list-batches
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Saprykin committed May 10, 2019
2 parents 751cf24 + 50bf56e commit 82e9951
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 131 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ $ remme batch get-list \
--head=57a7944497ca41f424932ae6b70897e7086652ab98450d4aba6a02a2d891501460947812a41028b8041f087066df6dc7e1100c4b0e5cc94bb58b002f6950eb02 \
--node-url=node-6-testnet.remme.io \
--reverse
"result": {
{
"result": {
"data": [
{
"header": {
Expand Down
10 changes: 5 additions & 5 deletions cli/batch/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from cli.batch.forms import GetBatchesListForm
from cli.batch.help import (
BATCH_HEAD_ARGUMENT_HELP_MESSAGE,
BATCH_IDS_ARGUMENT_HELP_MESSAGE,
BATCH_IDENTIFIERS_ARGUMENT_HELP_MESSAGE,
BATCH_LIMIT_ARGUMENT_HELP_MESSAGE,
BATCH_REVERSE_ARGUMENT_HELP_MESSAGE,
BATCH_START_ARGUMENT_HELP_MESSAGE,
Expand All @@ -34,7 +34,7 @@ def batch_commands():
pass


@click.option('--ids', required=False, type=str, help=BATCH_IDS_ARGUMENT_HELP_MESSAGE)
@click.option('--ids', required=False, type=str, help=BATCH_IDENTIFIERS_ARGUMENT_HELP_MESSAGE)
@click.option('--start', required=False, type=str, help=BATCH_START_ARGUMENT_HELP_MESSAGE)
@click.option('--limit', required=False, type=int, help=BATCH_LIMIT_ARGUMENT_HELP_MESSAGE)
@click.option('--head', required=False, type=str, help=BATCH_HEAD_ARGUMENT_HELP_MESSAGE)
Expand Down Expand Up @@ -68,8 +68,8 @@ def get_batches(ids, start, limit, head, reverse, node_url):
'node_address': str(node_url) + ':8080',
})

batches, errors = Batch(service=remme).get_list(
batch_ids=batch_ids,
result, errors = Batch(service=remme).get_list(
ids=batch_ids,
start=start,
limit=limit,
head=head,
Expand All @@ -80,4 +80,4 @@ def get_batches(ids, start, limit, head, reverse, node_url):
print_errors(errors=errors)
sys.exit(FAILED_EXIT_FROM_COMMAND_CODE)

print_result(result=batches)
print_result(result=result)
2 changes: 1 addition & 1 deletion cli/batch/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class GetBatchesListForm(Schema):
"""
Get a list of batch form.
Get a list of batches form.
"""

ids = BatchIdentifiersListField(allow_none=True, required=False)
Expand Down
2 changes: 1 addition & 1 deletion cli/batch/help.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Provide help messages for command line interface's batch commands.
"""
BATCH_IDS_ARGUMENT_HELP_MESSAGE = 'Identifiers to get a list of batches by.'
BATCH_IDENTIFIERS_ARGUMENT_HELP_MESSAGE = 'Identifiers to get a list of batches by.'
BATCH_START_ARGUMENT_HELP_MESSAGE = 'Batch identifier to get a list of batches starting from.'
BATCH_LIMIT_ARGUMENT_HELP_MESSAGE = 'Maximum amount of batches to return.'
BATCH_HEAD_ARGUMENT_HELP_MESSAGE = 'Block identifier to get a list of batches from.'
Expand Down
6 changes: 3 additions & 3 deletions cli/batch/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ class BatchInterface:
Implements batch interface.
"""

def get_list(self, batch_ids, start, limit, head, reverse):
def get_list(self, ids, start, limit, head, reverse):
"""
Get a list of batches.
A list of batches could be filtered by batch identifiers, start identifier, limit, head identifier,
reverse.
Arguments:
batch_ids (list, optional): identifiers to get a list of batches by.
ids (list, optional): identifiers to get a list of batches by.
start (string, optional): batch identifier to get a list of batches starting from.
limit (int, optional): maximum amount of batches to return.
head (string, optional): block identifier to get a list of batches from.
reverse (string, optional): parameter to reverse result.
reverse (bool, optional): parameter to reverse result.
"""
pass
12 changes: 5 additions & 7 deletions cli/batch/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@ def __init__(self, service):
"""
self.service = service

def get_list(self, batch_ids, start, limit, head, reverse):
def get_list(self, ids, start, limit, head, reverse):
"""
Get a list of batches.
Arguments:
batch_ids (list, optional): identifiers to get a list of batches by.
ids (list, optional): identifiers to get a list of batches by.
start (string, optional): batch identifier to get a list of batches starting from.
limit (int, optional): maximum amount of batches to return.
head (string, optional): block identifier to get a list of batches from.
reverse (string, optional): parameter to reverse result.
reverse (bool, optional): parameter to reverse result.
"""
reverse = '' if reverse else 'false'

try:
batches = loop.run_until_complete(
self.service.blockchain_info.get_batches(query={
'ids': batch_ids,
'ids': ids,
'start': start,
'limit': limit,
'head': head,
Expand All @@ -56,4 +54,4 @@ def get_list(self, batch_ids, start, limit, head, reverse):
except Exception as error:
return None, str(error)

return batches, None
return batches.get('data'), None
8 changes: 5 additions & 3 deletions cli/generic/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,14 @@ class BatchIdentifierField(fields.Field):

def _deserialize(self, value, attr, obj, **kwargs):
"""
Validate data (identifier) that was passed to field.
Validate data (batch identifier) that was passed to field.
"""
if re.match(pattern=HEADER_SIGNATURE_REGEXP, string=value) is None:
batch_identifier = value

if re.match(pattern=HEADER_SIGNATURE_REGEXP, string=batch_identifier) is None:
raise ValidationError(f'The following identifier `{value}` is invalid.')

return value
return batch_identifier


class NodeUrlField(fields.Field):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
requirements = f.read().splitlines()

setup(
version='0.2.0',
version='0.3.0',
name='remme-core-cli',
description='The command-line interface (CLI) that provides a set of commands to interact with Remme-core.',
long_description=long_description,
Expand Down
Loading

0 comments on commit 82e9951

Please sign in to comment.