From 2a323424eebcfdcca4add405b94037b12e8d1489 Mon Sep 17 00:00:00 2001 From: "Ian H. Pittwood" Date: Thu, 2 May 2019 09:58:58 -0500 Subject: [PATCH] Added YAPF configuration Added YAPF config recently implemented into Spyglass. Reformatted code using YAPF. --- .style.yapf | 6 ++++++ setup.py | 1 + spyglass-plugin-xls/check_exceptions.py | 2 ++ spyglass-plugin-xls/excel.py | 10 ++++------ tox.ini | 4 ++-- 5 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 .style.yapf diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 0000000..7dca927 --- /dev/null +++ b/.style.yapf @@ -0,0 +1,6 @@ +[style] +based_on_style = pep8 +allow_split_before_dict_value = false +blank_line_before_nested_class_or_def = true +blank_line_before_module_docstring = true +split_before_logical_operator = false diff --git a/setup.py b/setup.py index 54d731a..8cb64e8 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ setup( license='Apache 2.0', packages=find_packages(), install_requires=[ + 'click==7.0', 'PyYAML==3.12', 'openpyxl==2.5.4', ], diff --git a/spyglass-plugin-xls/check_exceptions.py b/spyglass-plugin-xls/check_exceptions.py index f09ebe5..94bc0f2 100644 --- a/spyglass-plugin-xls/check_exceptions.py +++ b/spyglass-plugin-xls/check_exceptions.py @@ -18,6 +18,7 @@ class BaseError(Exception): class NotEnoughIp(BaseError): + def __init__(self, cidr, total_nodes): self.cidr = cidr self.total_nodes = total_nodes @@ -27,6 +28,7 @@ class NotEnoughIp(BaseError): class NoSpecMatched(BaseError): + def __init__(self, excel_specs): self.specs = excel_specs diff --git a/spyglass-plugin-xls/excel.py b/spyglass-plugin-xls/excel.py index 12274d6..b46dbce 100644 --- a/spyglass-plugin-xls/excel.py +++ b/spyglass-plugin-xls/excel.py @@ -23,6 +23,7 @@ LOG = logging.getLogger(__name__) class ExcelPlugin(BaseDataSourcePlugin): + def __init__(self, region): LOG.info("Excel Plugin Initializing") self.source_type = "excel" @@ -107,12 +108,9 @@ class ExcelPlugin(BaseDataSourcePlugin): for rack in rackwise_hosts.keys(): for host in rackwise_hosts[rack]: host_list.append({ - "rack_name": - rack, - "name": - host, - "host_profile": - ipmi_data[host]["host_profile"], + "rack_name": rack, + "name": host, + "host_profile": ipmi_data[host]["host_profile"], }) return host_list diff --git a/tox.ini b/tox.ini index 822df86..32c3048 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pep8, bandit, docs +envlist = pep8, docs minversion = 2.3.1 skipsdist = True @@ -24,7 +24,7 @@ basepython = python3 deps = -r{toxinidir}/test-requirements.txt commands = - yapf -ir {toxinidir}/spyglass-plugin-xls + yapf -ir {toxinidir}/spyglass-plugin-xls {toxinidir}/setup.py [testenv:pep8] basepython = python3