From 93e78c472d2cf1a0455c842266577ec205b3e688 Mon Sep 17 00:00:00 2001 From: "Ian H. Pittwood" Date: Wed, 29 May 2019 10:27:07 -0500 Subject: [PATCH] Fixes issues with tox A recent change updated the settings of yapf in Spyglass. This change matches this recent change and fixes the directory used in tox. It also fixes the directories used in tox.ini and removes unnecessary flake8 ignores. Change-Id: I7036f885a3c45880b7b9be604bc6c1c533622134 --- spyglass_plugin_xls/check_exceptions.py | 5 +++-- spyglass_plugin_xls/cli.py | 25 ++++++++++++++----------- spyglass_plugin_xls/excel.py | 24 +++++++++++++----------- spyglass_plugin_xls/excel_parser.py | 24 ++++++++++++++---------- test-requirements.txt | 1 + tox.ini | 12 ++++++------ 6 files changed, 51 insertions(+), 40 deletions(-) diff --git a/spyglass_plugin_xls/check_exceptions.py b/spyglass_plugin_xls/check_exceptions.py index 94bc0f2..49ac3b4 100644 --- a/spyglass_plugin_xls/check_exceptions.py +++ b/spyglass_plugin_xls/check_exceptions.py @@ -33,5 +33,6 @@ class NoSpecMatched(BaseError): self.specs = excel_specs def display_error(self): - print("No spec matched. Following are the available specs:\n".format( - self.specs)) + print( + "No spec matched. Following are the available specs:\n".format( + self.specs)) diff --git a/spyglass_plugin_xls/cli.py b/spyglass_plugin_xls/cli.py index 31835f4..7cdc3ea 100644 --- a/spyglass_plugin_xls/cli.py +++ b/spyglass_plugin_xls/cli.py @@ -24,11 +24,12 @@ LOG_FORMAT = '%(asctime)s %(levelname)-8s %(name)s:' \ '%(funcName)s [%(lineno)3d] %(message)s' -@click.option('-v', - '--verbose', - is_flag=True, - default=False, - help='Enable debug messages in log.') +@click.option( + '-v', + '--verbose', + is_flag=True, + default=False, + help='Enable debug messages in log.') @click.group() def excel(*, verbose): """Plugin for extracting site data from Excel spreadsheets""" @@ -108,9 +109,10 @@ FORCE_OPTION = click.option( help="Forces manifests to be written, regardless of undefined data.") -@excel.command('intermediary', - short_help='generate intermediary', - help='Generates an intermediary file from passed excel data.') +@excel.command( + 'intermediary', + short_help='generate intermediary', + help='Generates an intermediary file from passed excel data.') @EXCEL_FILE_OPTION @EXCEL_SPEC_OPTION @SITE_CONFIGURATION_FILE_OPTION @@ -124,9 +126,10 @@ def generate_intermediary(*args, **kwargs): process_input_ob.dump_intermediary_file(kwargs['intermediary_dir']) -@excel.command('documents', - short_help='generates manifest documents and intermediary', - help='Generates manifest documents and intermediary file.') +@excel.command( + 'documents', + short_help='generates manifest documents and intermediary', + help='Generates manifest documents and intermediary file.') @click.option( '-i', '--generate-intermediary', diff --git a/spyglass_plugin_xls/excel.py b/spyglass_plugin_xls/excel.py index b46dbce..8757ee1 100644 --- a/spyglass_plugin_xls/excel.py +++ b/spyglass_plugin_xls/excel.py @@ -107,11 +107,12 @@ class ExcelPlugin(BaseDataSourcePlugin): host_list = [] 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"], - }) + host_list.append( + { + "rack_name": rack, + "name": host, + "host_profile": ipmi_data[host]["host_profile"], + }) return host_list def get_networks(self, region): @@ -151,8 +152,9 @@ class ExcelPlugin(BaseDataSourcePlugin): tmp_vlan["name"] = "ingress" tmp_vlan["subnet"] = net_val vlan_list.append(tmp_vlan) - LOG.debug("vlan list extracted from spyglass-plugin-xls:\n{}".format( - pprint.pformat(vlan_list))) + LOG.debug( + "vlan list extracted from spyglass-plugin-xls:\n{}".format( + pprint.pformat(vlan_list))) return vlan_list def get_ips(self, region, host=None): @@ -194,8 +196,8 @@ class ExcelPlugin(BaseDataSourcePlugin): ldap_info["domain"] = url.split(".")[1] except IndexError as e: LOG.error("url.split:{}".format(e)) - ldap_info["common_name"] = ldap_raw_data.get("common_name", - "#CHANGE_ME") + ldap_info["common_name"] = ldap_raw_data.get( + "common_name", "#CHANGE_ME") ldap_info["subdomain"] = ldap_raw_data.get("subdomain", "#CHANGE_ME") return ldap_info @@ -227,8 +229,8 @@ class ExcelPlugin(BaseDataSourcePlugin): location_data = self.parsed_xl_data["site_info"]["location"] corridor_pattern = r"\d+" - corridor_number = re.findall(corridor_pattern, - location_data["corridor"])[0] + corridor_number = re.findall( + corridor_pattern, location_data["corridor"])[0] name = location_data.get("name", "#CHANGE_ME") state = location_data.get("state", "#CHANGE_ME") country = location_data.get("country", "#CHANGE_ME") diff --git a/spyglass_plugin_xls/excel_parser.py b/spyglass_plugin_xls/excel_parser.py index ac42926..f3703f1 100644 --- a/spyglass_plugin_xls/excel_parser.py +++ b/spyglass_plugin_xls/excel_parser.py @@ -127,10 +127,12 @@ class ExcelParser(object): "type": type, } row += 1 - LOG.debug("ipmi data extracted from excel:\n{}".format( - pprint.pformat(ipmi_data))) - LOG.debug("host data extracted from excel:\n{}".format( - pprint.pformat(hosts))) + LOG.debug( + "ipmi data extracted from excel:\n{}".format( + pprint.pformat(ipmi_data))) + LOG.debug( + "host data extracted from excel:\n{}".format( + pprint.pformat(hosts))) return [ipmi_data, hosts] def get_private_vlan_data(self, ws): @@ -149,8 +151,8 @@ class ExcelParser(object): vlan = vlan.lower() vlan_data[vlan] = cell_value row += 1 - LOG.debug("vlan data extracted from excel:\n%s", - pprint.pformat(vlan_data)) + LOG.debug( + "vlan data extracted from excel:\n%s", pprint.pformat(vlan_data)) return vlan_data def get_private_network_data(self): @@ -270,10 +272,12 @@ class ExcelParser(object): ntp_servers = ws.cell(row=ntp_row, column=ntp_col).value try: if dns_servers is None: - raise RuntimeError(( - "No value for dns_server from:{} Sheet:'{}' ", - "Row:{} Col:{}", - ).format(self.file_name, provided_sheetname, dns_row, dns_col)) + raise RuntimeError( + ( + "No value for dns_server from:{} Sheet:'{}' ", + "Row:{} Col:{}", + ).format( + self.file_name, provided_sheetname, dns_row, dns_col)) except RuntimeError as rerror: LOG.critical(rerror) sys.exit("Tugboat exited!!") diff --git a/test-requirements.txt b/test-requirements.txt index b4c3e4b..fa50bf3 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,6 +6,7 @@ hacking==1.1.0 # Security bandit==1.6.0 +safety==1.8.5 # Installs Spyglass for independent tests, but not in requirements.txt since Spyglass will always install this plugin git+https://opendev.org/airship/spyglass.git#egg=spyglass diff --git a/tox.ini b/tox.ini index a8480e1..9c887a6 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ basepython = python3 deps = -r{toxinidir}/test-requirements.txt commands = - yapf -ir {toxinidir}/spyglass-plugin-xls {toxinidir}/setup.py + yapf -ir {toxinidir}/spyglass_plugin_xls {toxinidir}/setup.py [testenv:pep8] basepython = python3 @@ -32,9 +32,9 @@ deps = -r{toxinidir}/test-requirements.txt commands = bash -c "{toxinidir}/tools/gate/whitespace-linter.sh" - yapf -dr {toxinidir}/spyglass-plugin-xls {toxinidir}/setup.py - flake8 {toxinidir}/spyglass-plugin-xls - bandit -r spyglass-plugin-xls -n 5 + yapf -dr {toxinidir}/spyglass_plugin_xls {toxinidir}/setup.py + flake8 {toxinidir}/spyglass_plugin_xls + bandit -r spyglass_plugin_xls -n 5 safety check -r requirements.txt --bare whitelist_externals = bash @@ -49,10 +49,10 @@ commands = [testenv:bandit] deps = bandit -commands = bandit -r spyglass-plugin-xls -n 5 +commands = bandit -r spyglass_plugin_xls -n 5 [flake8] -ignore = E125,E251,W503 +ignore = W503 [testenv:docs] basepython = python3