From 5a815f97de0f02a3cecf933072d86f3e6c61eb6d Mon Sep 17 00:00:00 2001 From: kossak Date: Thu, 23 May 2019 17:13:04 +0200 Subject: [PATCH 1/2] CommandBase duplicate removed, pretty dict printing moved to the only one --- paperspace/commands/__init__.py | 17 ----------------- paperspace/commands/common.py | 8 ++++++++ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/paperspace/commands/__init__.py b/paperspace/commands/__init__.py index 6d63b5e..e69de29 100644 --- a/paperspace/commands/__init__.py +++ b/paperspace/commands/__init__.py @@ -1,17 +0,0 @@ -from collections import OrderedDict - -from paperspace import logger - - -class CommandBase(object): - def __init__(self, api=None, logger_=logger): - self.api = api - self.logger = logger_ - - def _print_dict_recursive(self, input_dict, indent=0, tabulator=" "): - for key, val in input_dict.items(): - self.logger.log("%s%s:" % (tabulator * indent, key)) - if type(val) is dict: - self._print_dict_recursive(OrderedDict(val), indent + 1) - else: - self.logger.log("%s%s" % (tabulator * (indent + 1), val)) diff --git a/paperspace/commands/common.py b/paperspace/commands/common.py index 28a236e..cfb5e65 100644 --- a/paperspace/commands/common.py +++ b/paperspace/commands/common.py @@ -1,4 +1,5 @@ import pydoc +from collections import OrderedDict import terminaltables @@ -11,6 +12,13 @@ def __init__(self, api=None, logger_=logger): self.api = api self.logger = logger_ + def _print_dict_recursive(self, input_dict, indent=0, tabulator=" "): + for key, val in input_dict.items(): + self.logger.log("%s%s:" % (tabulator * indent, key)) + if type(val) is dict: + self._print_dict_recursive(OrderedDict(val), indent + 1) + else: + self.logger.log("%s%s" % (tabulator * (indent + 1), val)) class ListCommand(CommandBase): @property From 532cbf9b9c15039a604f15423f934d5362fab1b7 Mon Sep 17 00:00:00 2001 From: kossak Date: Thu, 23 May 2019 17:16:52 +0200 Subject: [PATCH 2/2] test fix --- tests/unit/test_base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unit/test_base.py b/tests/unit/test_base.py index c1fdd3f..aeacda2 100644 --- a/tests/unit/test_base.py +++ b/tests/unit/test_base.py @@ -1,9 +1,8 @@ from collections import OrderedDict import mock -import pytest -from paperspace.commands import CommandBase +from paperspace.commands.common import CommandBase output_response = ""