Code cleanup

This commit is contained in:
hroff-1902 2019-10-17 04:34:05 +03:00
parent 837d4d82b4
commit bf4e9a5dbb

View File

@ -125,7 +125,7 @@ def start_list_timeframes(args: Dict[str, Any]) -> None:
f"{', '.join(exchange.timeframes)}.") f"{', '.join(exchange.timeframes)}.")
def start_list_pairs(args: Dict[str, Any], pairs_only: bool = False) -> None: # noqa: C901 def start_list_pairs(args: Dict[str, Any], pairs_only: bool = False) -> None:
""" """
Print pairs on the exchange Print pairs on the exchange
:param args: Cli args from Arguments() :param args: Cli args from Arguments()
@ -180,24 +180,23 @@ def start_list_pairs(args: Dict[str, Any], pairs_only: bool = False) -> None: #
args.get('print_csv', False)): args.get('print_csv', False)):
logger.info(f"{summary_str}.") logger.info(f"{summary_str}.")
if len(pairs):
if args.get('print_list', False): if args.get('print_list', False):
# print data as a list, with human-readable summary # print data as a list, with human-readable summary
print(summary_str + print(f"{summary_str}: {', '.join(pairs.keys())}.")
(f": {', '.join(pairs.keys())}" if len(pairs) else "") + ".")
elif args.get('print_one_column', False): elif args.get('print_one_column', False):
if len(pairs):
print('\n'.join(pairs.keys())) print('\n'.join(pairs.keys()))
elif args.get('list_pairs_print_json', False): elif args.get('list_pairs_print_json', False):
if len(pairs): print(rapidjson.dumps(list(pairs.keys()), default=str))
print(rapidjson.dumps(pairs.keys(), default=str))
elif args.get('print_csv', False): elif args.get('print_csv', False):
if len(pairs):
writer = csv.DictWriter(sys.stdout, fieldnames=headers) writer = csv.DictWriter(sys.stdout, fieldnames=headers)
writer.writeheader() writer.writeheader()
writer.writerows(tabular_data) writer.writerows(tabular_data)
else: else:
print(summary_str + # print data as a table, with the human-readable summary
(":" if len(pairs) else ".")) print(f"{summary_str}:")
if len(pairs):
# print data as a table
print(tabulate(tabular_data, headers='keys', tablefmt='pipe')) print(tabulate(tabular_data, headers='keys', tablefmt='pipe'))
elif not (args.get('print_one_column', False) or
args.get('list_pairs_print_json', False) or
args.get('print_csv', False)):
print(f"{summary_str}.")