fix formatting

This commit is contained in:
Alex Grintsvayg 2019-10-04 09:52:29 -04:00
parent 3a3a9b5f4e
commit 2c73c80c9f
No known key found for this signature in database
GPG key ID: AEB3F089F86A22B5

View file

@ -41,7 +41,6 @@ from lbry.wallet.dewies import dewies_to_lbc, lbc_to_dewies
from lbry.schema.claim import Claim from lbry.schema.claim import Claim
from lbry.schema.url import URL from lbry.schema.url import URL
if typing.TYPE_CHECKING: if typing.TYPE_CHECKING:
from lbry.blob.blob_manager import BlobManager from lbry.blob.blob_manager import BlobManager
from lbry.dht.node import Node from lbry.dht.node import Node
@ -72,7 +71,9 @@ def requires(*components, **conditions):
raise ComponentsNotStarted("the following required components have not yet started: " raise ComponentsNotStarted("the following required components have not yet started: "
"%s" % json.dumps(components)) "%s" % json.dumps(components))
return fn(*args, **kwargs) return fn(*args, **kwargs)
return _inner return _inner
return _wrap return _wrap
@ -81,6 +82,7 @@ def deprecated(new_command=None):
f.new_command = new_command f.new_command = new_command
f._deprecated = True f._deprecated = True
return f return f
return _deprecated_wrapper return _deprecated_wrapper
@ -124,13 +126,13 @@ async def maybe_paginate(get_records: Callable, get_record_count: Callable,
page: Optional[int], page_size: Optional[int], **constraints): page: Optional[int], page_size: Optional[int], **constraints):
if None not in (page, page_size): if None not in (page, page_size):
constraints.update({ constraints.update({
"offset": page_size * (page-1), "offset": page_size * (page - 1),
"limit": page_size "limit": page_size
}) })
total_items = await get_record_count(**constraints) total_items = await get_record_count(**constraints)
return { return {
"items": await get_records(**constraints), "items": await get_records(**constraints),
"total_pages": int((total_items + (page_size-1)) / page_size), "total_pages": int((total_items + (page_size - 1)) / page_size),
"total_items": total_items, "total_items": total_items,
"page": page, "page_size": page_size "page": page, "page_size": page_size
} }
@ -208,7 +210,7 @@ class JSONRPCError:
for i, t in enumerate(trace_lines): for i, t in enumerate(trace_lines):
if "--- <exception caught here> ---" in t: if "--- <exception caught here> ---" in t:
if len(trace_lines) > i + 1: if len(trace_lines) > i + 1:
self.traceback = [j for j in trace_lines[i+1:] if j] self.traceback = [j for j in trace_lines[i + 1:] if j]
break break
def to_dict(self): def to_dict(self):
@ -338,7 +340,7 @@ class Daemon(metaclass=JSONRPCServerType):
name, = name_parts name, = name_parts
elif len(name_parts) == 2: elif len(name_parts) == 2:
group, name = name_parts group, name = name_parts
assert group in api['groups'],\ assert group in api['groups'], \
f"Group {group} does not have doc string for command {full_name}." f"Group {group} does not have doc string for command {full_name}."
else: else:
raise NameError(f'Could not parse method name: {jsonrpc_method}') raise NameError(f'Could not parse method name: {jsonrpc_method}')
@ -621,7 +623,7 @@ class Daemon(metaclass=JSONRPCServerType):
missing_required_params = [ missing_required_params = [
required_param required_param
for required_param in argspec.args[len(args_tup)+1:-num_optional_params] for required_param in argspec.args[len(args_tup) + 1:-num_optional_params]
if required_param not in args_dict if required_param not in args_dict
] ]
if len(missing_required_params): if len(missing_required_params):
@ -2032,11 +2034,11 @@ class Daemon(metaclass=JSONRPCServerType):
if kwargs.pop('invalid_channel_signature', False): if kwargs.pop('invalid_channel_signature', False):
kwargs['signature_valid'] = 0 kwargs['signature_valid'] = 0
page_num, page_size = abs(kwargs.pop('page', 1)), min(abs(kwargs.pop('page_size', 10)), 50) page_num, page_size = abs(kwargs.pop('page', 1)), min(abs(kwargs.pop('page_size', 10)), 50)
kwargs.update({'offset': page_size * (page_num-1), 'limit': page_size}) kwargs.update({'offset': page_size * (page_num - 1), 'limit': page_size})
txos, offset, total = await self.ledger.claim_search(**kwargs) txos, offset, total = await self.ledger.claim_search(**kwargs)
result = {"items": txos, "page": page_num, "page_size": page_size} result = {"items": txos, "page": page_num, "page_size": page_size}
if not kwargs.pop('no_totals', False): if not kwargs.pop('no_totals', False):
result['total_pages'] = int((total + (page_size-1)) / page_size) result['total_pages'] = int((total + (page_size - 1)) / page_size)
result['total_items'] = total result['total_items'] = total
return result return result
@ -2717,7 +2719,7 @@ class Daemon(metaclass=JSONRPCServerType):
) )
claim = Claim() claim = Claim()
claim.stream.update(file_path=file_path, sd_hash='0'*96, **kwargs) claim.stream.update(file_path=file_path, sd_hash='0' * 96, **kwargs)
tx = await Transaction.claim_create( tx = await Transaction.claim_create(
name, claim, amount, claim_address, funding_accounts, funding_accounts[0], channel name, claim, amount, claim_address, funding_accounts, funding_accounts[0], channel
) )